cluster: restructure meshLinks

This commit is contained in:
Max Headroom 2024-08-23 01:06:38 +02:00
parent 4713febf4b
commit f55a60d0bb
6 changed files with 13 additions and 27 deletions

View file

@ -3,12 +3,14 @@
{ {
hostLinks = lib.pipe config.services [ hostLinks = lib.pipe config.services [
(lib.filterAttrs (_: svc: svc.meshLinks != {})) (lib.filterAttrs (_: svc: svc.meshLinks != {}))
(lib.mapAttrsToList (svcName: svc: lib.mapAttrsToList (name: cfg: lib.genAttrs svc.nodes.${name} (hostName: { (lib.mapAttrsToList (svcName: svc:
${cfg.name} = { ... }: { lib.mapAttrsToList (groupName: links:
imports = [ cfg.link ]; lib.genAttrs svc.nodes.${groupName} (hostName: lib.mapAttrs (_: cfg: { ... }: {
ipv4 = config.vars.mesh.${hostName}.meshIp; imports = [ cfg.link ];
}; ipv4 = config.vars.mesh.${hostName}.meshIp;
})) svc.meshLinks)) }) links)
) svc.meshLinks
))
(map lib.mkMerge) (map lib.mkMerge)
lib.mkMerge lib.mkMerge
]; ];

View file

@ -38,12 +38,8 @@ in
}; };
meshLinks = mkOption { meshLinks = mkOption {
description = "Create host links on the mesh network."; description = "Create host links on the mesh network.";
type = types.attrsOf (types.submodule ({ name, ... }: { type = types.attrsOf (types.attrsOf (types.submodule {
options = { options = {
name = mkOption {
type = types.str;
default = "${serviceName}-${name}";
};
link = mkOption { link = mkOption {
type = types.deferredModule; type = types.deferredModule;
default = {}; default = {};

View file

@ -16,10 +16,7 @@
./nar-serve.nix ./nar-serve.nix
]; ];
}; };
meshLinks.server = { meshLinks.server.attic.link.protocol = "http";
name = "attic";
link.protocol = "http";
};
secrets = let secrets = let
inherit (config.services.attic) nodes; inherit (config.services.attic) nodes;
in { in {

View file

@ -4,10 +4,7 @@
services.forge = { services.forge = {
nodes.server = [ "VEGAS" ]; nodes.server = [ "VEGAS" ];
nixos.server = ./server.nix; nixos.server = ./server.nix;
meshLinks.server = { meshLinks.server.forge.link.protocol = "http";
name = "forge";
link.protocol = "http";
};
secrets = with config.services.forge.nodes; { secrets = with config.services.forge.nodes; {
oidcSecret = { oidcSecret = {
nodes = server; nodes = server;

View file

@ -29,10 +29,7 @@
io-tweaks = [ "VEGAS" ]; io-tweaks = [ "VEGAS" ];
remote-api = [ "VEGAS" ]; remote-api = [ "VEGAS" ];
}; };
meshLinks.gateway = { meshLinks.gateway.ipfsGateway.link.protocol = "http";
name = "ipfsGateway";
link.protocol = "http";
};
nixos = { nixos = {
node = [ node = [
./node.nix ./node.nix

View file

@ -66,10 +66,7 @@ in
./tracing.nix ./tracing.nix
]; ];
}; };
meshLinks.logging = { meshLinks.logging.loki.link.protocol = "http";
name = "loki";
link.protocol = "http";
};
}; };
garage = config.lib.forService "monitoring" { garage = config.lib.forService "monitoring" {