diff --git a/cluster/lib/service-module.nix b/cluster/lib/service-module.nix index 4b30d77..a9dfee8 100644 --- a/cluster/lib/service-module.nix +++ b/cluster/lib/service-module.nix @@ -1,6 +1,13 @@ +vars: { name, config, lib, ... }: with lib; +let + notSelf = x: x != vars.hostName; + + filterGroup = builtins.filter notSelf; +in + { options = { nodes = mkOption { @@ -17,10 +24,16 @@ with lib; type = with types; attrsOf (oneOf [ str (listOf str) ]); default = []; }; + otherNodes = mkOption { + description = "Other nodes in the group."; + type = with types; attrsOf (listOf str); + default = []; + }; nixos = mkOption { description = "NixOS configurations per node group."; type = with types; attrs; default = {}; }; }; + config.otherNodes = builtins.mapAttrs (_: filterGroup) config.nodes; } diff --git a/cluster/lib/services.nix b/cluster/lib/services.nix index 80c60c6..68f6ca9 100644 --- a/cluster/lib/services.nix +++ b/cluster/lib/services.nix @@ -12,7 +12,7 @@ in { options.services = mkOption { description = "Cluster services."; - type = with types; attrsOf (submodule (import ./service-module.nix )); + type = with types; attrsOf (submodule (import ./service-module.nix config.vars)); default = {}; }; config.out.injectedNixosConfig = lib.flatten (lib.mapAttrsToList (_: getServiceConfigurations) config.services);