pass nodes to config and have defaults for the IPs

This commit is contained in:
CherryKitten 2024-04-15 19:04:08 +02:00
parent a5eaff1a63
commit d6304ab783
Signed by: sammy
GPG key ID: 98D8F75FB0658276

View file

@ -53,14 +53,33 @@
description = "All my NixoS machines"; description = "All my NixoS machines";
specialArgs = { specialArgs = {
inherit inputs outputs; inherit inputs outputs;
nodes = colmenaHive.nodes;
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; }; pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; };
}; };
nixpkgs = import nixpkgs { system = "x86_64-linux"; }; nixpkgs = import nixpkgs { system = "x86_64-linux"; };
}; };
defaults = { lib, config, name, ... }: { defaults = { lib, config, name, nodes, ... }: {
imports = [ ./hosts/${name} ./profiles/base ]; imports = [ ./hosts/${name} ./profiles/base ];
options.cherrykitten = {
primaryIPv4 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address
else null;
};
primaryIPv6 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv6.addresses 0).address
else null;
};
};
config = {
networking.hostName = name; networking.hostName = name;
networking.domain = "cherrykitten.xyz"; networking.domain = "cherrykitten.xyz";
@ -69,6 +88,7 @@
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; }; pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; };
}; };
}; };
};
} // hosts; } // hosts;
colmenaHive = inputs.colmena.lib.makeHive colmena; colmenaHive = inputs.colmena.lib.makeHive colmena;