pantheon/modules/configurations/nixos.nix

28 lines
612 B
Nix

{ config, lib, ... }:
let
inherit (lib.trivial) pipe;
inherit (lib.attrsets) filterAttrs mapAttrs';
inherit (lib.strings) removePrefix hasPrefix;
prefix = "nixos/";
hosts = config.flake.hostSpec.hosts or { };
mkSystem =
name: value:
let
hostName = removePrefix prefix name;
in
{
name = hostName;
value = lib.nixosSystem {
modules = [
value
{ networking = { inherit hostName; }; }
];
};
};
in
{
flake.nixosConfigurations = pipe hosts [
(filterAttrs (name: _: hasPrefix prefix name))
(mapAttrs' mkSystem)
];
}