From e2da73261300c6f027f067d95477c7967584aafb Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 3 Aug 2022 22:53:14 +0200 Subject: [PATCH] cluster/lib: add otherNodes in services --- cluster/lib/service-module.nix | 13 +++++++++++++ cluster/lib/services.nix | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) 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);