From 18c1fa1ddd1da6c1f227713306abb41aeb13a6a5 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 2 Oct 2023 21:48:57 +0200 Subject: [PATCH] feat(lib): Declare instance specific function here instead of nix-lib --- lib/default.nix | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index de03c3e..c4fe4b2 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,9 +1,23 @@ _: let - inherit ((import sources.nixpkgs { })) lib; - sources = import ../npins; -in -import sources.nix-lib { inherit lib; keysRoot = ../keys; metaRoot = ../meta; } + nix-lib = import sources.nix-lib { + inherit ((import sources.nixpkgs { })) lib; + + keysRoot = ../keys; + metaRoot = ../meta; + }; + +in nix-lib // (with nix-lib; { + # Get publickeys associated to a node + getNodeKeys = node: + let + meta = import ../meta; + names = + builtins.foldl' (names: group: names ++ meta.members.groups.${group}) + (meta.nodes.${node}.admins ++ [ "/machines/${node}" ]) + (meta.nodes.${node}.adminGroups ++ [ "root" ]); + in getAllKeys names; +})