diff --git a/cluster/lib/mesh.nix b/cluster/lib/mesh.nix index 821512c..2cd5cb4 100644 --- a/cluster/lib/mesh.nix +++ b/cluster/lib/mesh.nix @@ -3,12 +3,14 @@ { hostLinks = lib.pipe config.services [ (lib.filterAttrs (_: svc: svc.meshLinks != {})) - (lib.mapAttrsToList (svcName: svc: lib.mapAttrsToList (name: cfg: lib.genAttrs svc.nodes.${name} (hostName: { - ${cfg.name} = { ... }: { - imports = [ cfg.link ]; - ipv4 = config.vars.mesh.${hostName}.meshIp; - }; - })) svc.meshLinks)) + (lib.mapAttrsToList (svcName: svc: + lib.mapAttrsToList (groupName: links: + lib.genAttrs svc.nodes.${groupName} (hostName: lib.mapAttrs (_: cfg: { ... }: { + imports = [ cfg.link ]; + ipv4 = config.vars.mesh.${hostName}.meshIp; + }) links) + ) svc.meshLinks + )) (map lib.mkMerge) lib.mkMerge ]; diff --git a/cluster/lib/service-module.nix b/cluster/lib/service-module.nix index 2fb07e7..ce20019 100644 --- a/cluster/lib/service-module.nix +++ b/cluster/lib/service-module.nix @@ -38,12 +38,8 @@ in }; meshLinks = mkOption { description = "Create host links on the mesh network."; - type = types.attrsOf (types.submodule ({ name, ... }: { + type = types.attrsOf (types.attrsOf (types.submodule { options = { - name = mkOption { - type = types.str; - default = "${serviceName}-${name}"; - }; link = mkOption { type = types.deferredModule; default = {}; diff --git a/cluster/services/attic/default.nix b/cluster/services/attic/default.nix index 814e8f6..454152d 100644 --- a/cluster/services/attic/default.nix +++ b/cluster/services/attic/default.nix @@ -16,10 +16,7 @@ ./nar-serve.nix ]; }; - meshLinks.server = { - name = "attic"; - link.protocol = "http"; - }; + meshLinks.server.attic.link.protocol = "http"; secrets = let inherit (config.services.attic) nodes; in { diff --git a/cluster/services/forge/default.nix b/cluster/services/forge/default.nix index d4a5640..9dd31a9 100644 --- a/cluster/services/forge/default.nix +++ b/cluster/services/forge/default.nix @@ -4,10 +4,7 @@ services.forge = { nodes.server = [ "VEGAS" ]; nixos.server = ./server.nix; - meshLinks.server = { - name = "forge"; - link.protocol = "http"; - }; + meshLinks.server.forge.link.protocol = "http"; secrets = with config.services.forge.nodes; { oidcSecret = { nodes = server; diff --git a/cluster/services/ipfs/default.nix b/cluster/services/ipfs/default.nix index 1d7679a..938b8f8 100644 --- a/cluster/services/ipfs/default.nix +++ b/cluster/services/ipfs/default.nix @@ -29,10 +29,7 @@ io-tweaks = [ "VEGAS" ]; remote-api = [ "VEGAS" ]; }; - meshLinks.gateway = { - name = "ipfsGateway"; - link.protocol = "http"; - }; + meshLinks.gateway.ipfsGateway.link.protocol = "http"; nixos = { node = [ ./node.nix diff --git a/cluster/services/monitoring/default.nix b/cluster/services/monitoring/default.nix index 49af8f6..6dfffc8 100644 --- a/cluster/services/monitoring/default.nix +++ b/cluster/services/monitoring/default.nix @@ -66,10 +66,7 @@ in ./tracing.nix ]; }; - meshLinks.logging = { - name = "loki"; - link.protocol = "http"; - }; + meshLinks.logging.loki.link.protocol = "http"; }; garage = config.lib.forService "monitoring" {