forked from DGNum/infrastructure
34 lines
942 B
Nix
34 lines
942 B
Nix
{ lib, ... }:
|
|
|
|
let
|
|
trivial = import ./trivial.nix;
|
|
in
|
|
|
|
trivial // (with trivial; rec {
|
|
recursiveFuse = builtins.foldl' lib.recursiveUpdate { };
|
|
|
|
mkImport = root: file:
|
|
let path = mkRel root file; in
|
|
path + (lib.optionalString (!lib.pathIsDirectory path) ".nix");
|
|
|
|
mkImports = root: builtins.map (mkImport root);
|
|
|
|
getKeys = name: builtins.filter
|
|
(k: k != "")
|
|
(lib.splitString "\n" (builtins.readFile (mkRel ../keys "${name}.keys")));
|
|
|
|
/* List version of getKeys */
|
|
getAllKeys = names: builtins.concatLists (builtins.map getKeys names);
|
|
|
|
getKeyFiles = builtins.map (compose (n: "${n}.keys") (mkRel ../keys));
|
|
|
|
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;
|
|
})
|