mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 07:10:39 +02:00
refactor: major refactor into proper reusable modules. No logical changes.
This commit is contained in:
parent
04872f6ec5
commit
84ac34cb6c
80 changed files with 761 additions and 776 deletions
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
config,
|
||||
extraLib,
|
||||
lib,
|
||||
nodeName,
|
||||
colmenaNodes,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
attrNames
|
||||
concatMap
|
||||
elem
|
||||
filter
|
||||
mdDoc
|
||||
mkOption
|
||||
mkOptionType
|
||||
optionalAttrs
|
||||
types
|
||||
;
|
||||
|
||||
inherit
|
||||
(extraLib)
|
||||
mergeToplevelConfigs
|
||||
;
|
||||
in {
|
||||
options.nodes = mkOption {
|
||||
type = types.attrsOf (mkOptionType {
|
||||
name = "Toplevel NixOS config";
|
||||
merge = loc: map (x: x.value);
|
||||
});
|
||||
default = {};
|
||||
description = mdDoc "Allows extending the configuration of other machines.";
|
||||
};
|
||||
|
||||
config = let
|
||||
allNodes = attrNames colmenaNodes;
|
||||
isColmenaNode = elem nodeName allNodes;
|
||||
foreignConfigs = concatMap (n: colmenaNodes.${n}.config.nodes.${nodeName} or []) allNodes;
|
||||
toplevelAttrs = ["age" "providedDomains" "networking" "systemd" "services"];
|
||||
in
|
||||
optionalAttrs isColmenaNode (mergeToplevelConfigs toplevelAttrs (
|
||||
foreignConfigs
|
||||
# Also allow extending ourselves, in case some attributes from depenent
|
||||
# configurations such as containers or microvms are merged to the host
|
||||
++ [config.nodes.${nodeName} or {}]
|
||||
));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue