forked from mirrors_public/oddlama_nix-config
fix: distributed-config now works across microvms and colmena nodes
This commit is contained in:
parent
69bd2a71ce
commit
5bd65732f5
3 changed files with 20 additions and 16 deletions
|
@ -28,7 +28,6 @@
|
|||
};
|
||||
|
||||
nodes.sentinel.age.secrets.loki-basic-auth-hashes.generator.dependencies = [
|
||||
aaa not wokring
|
||||
config.age.secrets.grafana-loki-basic-auth-password
|
||||
];
|
||||
|
||||
|
|
|
@ -10,12 +10,13 @@
|
|||
(lib)
|
||||
attrNames
|
||||
concatMap
|
||||
elem
|
||||
filter
|
||||
mdDoc
|
||||
mkOption
|
||||
mkOptionType
|
||||
optionalAttrs
|
||||
types
|
||||
unique
|
||||
subtractLists
|
||||
;
|
||||
|
||||
inherit
|
||||
|
@ -24,24 +25,24 @@
|
|||
;
|
||||
in {
|
||||
options.nodes = mkOption {
|
||||
type = types.attrsOf types.unspecified;
|
||||
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
|
||||
isColmenaNode = elem nodeName (attrNames colmenaNodes);
|
||||
otherNodes = filter (n: n != nodeName) (attrNames colmenaNodes);
|
||||
foreignConfigs = map (n: colmenaNodes.${n}.config.nodes.${nodeName} or {}) otherNodes;
|
||||
foreignConfigs = concatMap (n: colmenaNodes.${n}.config.nodes.${nodeName} or []) otherNodes;
|
||||
toplevelAttrs = ["age" "networking" "systemd" "services"];
|
||||
in
|
||||
todo wrong, currently extension FROM microvms is not possible
|
||||
{
|
||||
assertions =
|
||||
map (n: {
|
||||
assertion = false;
|
||||
message = "Cannot extend configuration using nodes.${n} because the given node is not a registered or not a first-class nixos node (microvm's can't be extended right now).";
|
||||
})
|
||||
(subtractLists (attrNames colmenaNodes) (attrNames config.nodes));
|
||||
}
|
||||
// mergeToplevelConfigs toplevelAttrs foreignConfigs;
|
||||
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 {}]
|
||||
));
|
||||
}
|
||||
|
|
|
@ -87,6 +87,10 @@
|
|||
};
|
||||
};
|
||||
|
||||
# Propagate node expansions, since doing this directly in the
|
||||
# distributed-config module would cause infinite recursion.
|
||||
nodes = mkMerge config.microvm.vms.${vmName}.config.options.nodes.definitions;
|
||||
|
||||
microvm.vms.${vmName} = let
|
||||
node = import ../nix/generate-node.nix inputs vmCfg.nodeName {
|
||||
inherit (vmCfg) system configPath;
|
||||
|
@ -360,6 +364,6 @@ in {
|
|||
ipv6 = net.cidr.host 1 cfg.networking.wireguard.cidrv6;
|
||||
};
|
||||
}
|
||||
// extraLib.mergeToplevelConfigs ["disko" "microvm" "systemd"] (mapAttrsToList microvmConfig vms)
|
||||
// extraLib.mergeToplevelConfigs ["nodes" "disko" "microvm" "systemd"] (mapAttrsToList microvmConfig vms)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue