refactor(nixos): simplify configurations.nix and lib
This commit refactors configurations.nix and lib/default.nix by removing the extractConfigurations function and related code from lib/default.nix, and moving the NixOS system building logic directly into configurations.nix. It also changes the structure of hosts in manifest.nix to use a hosts.nixos attribute.
This commit is contained in:
parent
99f984a523
commit
f7873d54d3
3 changed files with 32 additions and 59 deletions
|
@ -1,9 +1,31 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (cfg.lib) extractConfigurations;
|
||||
inherit (lib) nixosSystem;
|
||||
inherit (cfg.lib) flattenAttrs;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
cfg = config.flake;
|
||||
hosts = cfg.manifest.hosts or { };
|
||||
mkConfigurations =
|
||||
class: hosts:
|
||||
mapAttrs (
|
||||
_: value:
|
||||
if class == "nixos" then
|
||||
nixosSystem {
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
(flattenAttrs cfg.modules.nixos)
|
||||
(value.extraCfg or { })
|
||||
];
|
||||
}
|
||||
else
|
||||
{ }
|
||||
) hosts;
|
||||
in
|
||||
{
|
||||
flake.nixosConfigurations = extractConfigurations "nixos/" hosts;
|
||||
flake.nixosConfigurations = mkConfigurations "nixos" hosts.nixos;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue