hive.nix: Switch dgn-lib to nix-lib
This commit is contained in:
parent
98f2077568
commit
9b5f39d7f2
4 changed files with 17 additions and 81 deletions
4
hive.nix
4
hive.nix
|
@ -2,7 +2,7 @@ let
|
|||
sources = import ./npins;
|
||||
metadata = import ./meta;
|
||||
|
||||
lib = import ./lib/trivial.nix;
|
||||
lib = import (sources.nix-lib + "/trivial.nix");
|
||||
|
||||
mkNode = node: { name, nodes, ... }: {
|
||||
# Import the base configuration for each node
|
||||
|
@ -35,7 +35,7 @@ let
|
|||
mkNixpkgs' = node: import (mkNixpkgs node) { };
|
||||
|
||||
mkArgs = node: {
|
||||
dgn-lib = import ./lib { inherit ((mkNixpkgs' node)) lib; };
|
||||
dgn-lib = import sources.nix-lib { inherit ((mkNixpkgs' node)) lib; keysRoot = ./keys; };
|
||||
};
|
||||
|
||||
nodes = builtins.attrNames metadata.nodes;
|
||||
|
|
|
@ -1,34 +1,7 @@
|
|||
{ lib, ... }:
|
||||
|
||||
let
|
||||
trivial = import ./trivial.nix;
|
||||
sources = import ../npins;
|
||||
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;
|
||||
})
|
||||
import sources.nix-lib { inherit lib; keysRoot = ../keys; }
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
rec {
|
||||
/* Fuses a list of attribute sets into a single attribute set.
|
||||
|
||||
Example:
|
||||
x = [ { a = 1; } { b = 2; } ]
|
||||
fuseAttrs x
|
||||
=> { a = 1; b = 2; }
|
||||
*/
|
||||
fuseAttrs = builtins.foldl' (attrs: x: attrs // x) { };
|
||||
|
||||
/* Maps then fuses a list of attribute sets into a single attribute set.
|
||||
|
||||
Example:
|
||||
x = [ "a" "b" ]
|
||||
mapFuse (c: { ${c} = 42; }) x
|
||||
=> { a = 42; b = 42; }
|
||||
*/
|
||||
mapFuse = f: attrsList: fuseAttrs (builtins.map f attrsList);
|
||||
|
||||
/* Equivalent of lib.singleton but for an attribute set.
|
||||
|
||||
Example:
|
||||
singleAttr "a" 1
|
||||
=> { a = 1; }
|
||||
*/
|
||||
singleAttr = name: value: { ${name} = value; };
|
||||
|
||||
/* Enables a list of modules. */
|
||||
enableAttrs' = enable: mapFuse (m: { ${m}.${enable} = true; });
|
||||
|
||||
enableModules = enableAttrs' "enable";
|
||||
|
||||
mapSingleFuse = f: mapFuse (x: singleAttr x (f x));
|
||||
|
||||
setDefault = default: mapFuse (name: { ${name} = default; });
|
||||
|
||||
/* Creates a relative path as a string
|
||||
|
||||
Example:
|
||||
mkRel /home/test/ "file.txt"
|
||||
=> "/home/test/file.txt"
|
||||
*/
|
||||
mkRel = path: file: path + "/${file}";
|
||||
|
||||
compose = f: g: (x: g (f x));
|
||||
|
||||
mkBaseSecrets = root: mapFuse (secret: { ${secret}.file = mkRel root secret; });
|
||||
|
||||
getSecrets = dir: builtins.attrNames (import (mkRel dir "secrets.nix"));
|
||||
}
|
|
@ -41,6 +41,19 @@
|
|||
"url": null,
|
||||
"hash": "1bashjbh71dqs32yld7ihw2vz0vrad73pc35crf3qck8ssgpzv7d"
|
||||
},
|
||||
"nix-lib": {
|
||||
"type": "GitRelease",
|
||||
"repository": {
|
||||
"type": "Git",
|
||||
"url": "https://git.hubrecht.ovh/hubrecht/nix-lib"
|
||||
},
|
||||
"pre_releases": false,
|
||||
"version_upper_bound": null,
|
||||
"version": "0.1.1",
|
||||
"revision": "5db2443e2cb18335375ad84ffbc066a239c054de",
|
||||
"url": null,
|
||||
"hash": "18xzi2yn2vk7zq79pgz8z2s1ijhyjcx5866mp21rrdi9gz37yiif"
|
||||
},
|
||||
"nixos-23.05": {
|
||||
"type": "Channel",
|
||||
"name": "nixos-23.05",
|
||||
|
|
Loading…
Reference in a new issue