refactor(nixos): change hostSpec to define top level option
This commit is contained in:
parent
6aa5096172
commit
b43476ccee
3 changed files with 31 additions and 29 deletions
28
modules/configurations/nixos.nix
Normal file
28
modules/configurations/nixos.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{ 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)
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue