automatically import ${namespace}.${class(es)} as modules

Allow to specify a list of classes in the host/<hostname>.nix (by
default the class <hostname> is used) that will automatically load
specified outputs of inputs.
This commit is contained in:
Jonas Rabenstein 2025-11-26 02:40:42 +01:00
commit 01106110fe

View file

@ -15,6 +15,7 @@ let
{
namespace ? "fbs42",
nixpkgs ? "nixpkgs",
classes ? [ hostname ],
}:
inputs.${nixpkgs}.lib.nixosSystem {
specialArgs = { inherit inputs flake namespace; };
@ -24,6 +25,9 @@ let
base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${hostname}"; })
) flake.lib.schema.base
)
++ map (class: {
imports = map (input: input.${namespace}.${class} or { }) (builtins.attrValues inputs);
}) classes
++ [ { config.networking.hostName = hostname; } ]
++ [ nixosModules.default ]
++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) {