feat(flake): refactor configuration definitions
Now a bunch of configurations may be created from two functions and a set: `pred` - a validator that says whether a configuration is valid `mkHost` - a generator for that system's configuration `machines` - a nested attrset containing all the info for the machines
This commit is contained in:
parent
f510679c2f
commit
9a9524a71e
1 changed files with 62 additions and 64 deletions
100
flake.nix
100
flake.nix
|
@ -166,9 +166,9 @@
|
|||
extraSpecialArgs = { inherit inputs outputs; };
|
||||
};
|
||||
|
||||
# Final configurations
|
||||
|
||||
nixosConfigurations =
|
||||
createConfigurations =
|
||||
pred: mkHost: machines:
|
||||
nixpkgs.lib.foldAttrs
|
||||
(acc: x: acc)
|
||||
[]
|
||||
|
@ -179,64 +179,62 @@
|
|||
(host: config: config != null)
|
||||
(builtins.mapAttrs
|
||||
(host: config:
|
||||
if (hasFiles [ "configuration.nix" ] config)
|
||||
then mkNixosHost system host
|
||||
if (pred system host config)
|
||||
then mkHost system host config
|
||||
else null)
|
||||
hosts))
|
||||
nixosMachines));
|
||||
machines));
|
||||
|
||||
# Final configurations
|
||||
nixosConfigurations =
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
[ "configuration.nix" ]
|
||||
config)
|
||||
(system: host: config:
|
||||
mkNixosHost
|
||||
system
|
||||
host)
|
||||
nixosMachines;
|
||||
|
||||
nixOnDroidConfigurations =
|
||||
nixpkgs.lib.foldAttrs
|
||||
(acc: x: acc)
|
||||
[]
|
||||
(builtins.attrValues
|
||||
(builtins.mapAttrs
|
||||
(system: hosts:
|
||||
nixpkgs.lib.attrsets.filterAttrs
|
||||
(host: config: config != null)
|
||||
(builtins.mapAttrs
|
||||
(host: config:
|
||||
if (hasFiles [ "configuration.nix" "home.nix" ] config)
|
||||
then mkNixOnDroidHost system host
|
||||
else null)
|
||||
hosts))
|
||||
nixOnDroidMachines));
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
[ "configuration.nix" "home.nix" ]
|
||||
config)
|
||||
(system: host: config:
|
||||
mkNixOnDroidHost
|
||||
system
|
||||
host)
|
||||
nixOnDroidMachines;
|
||||
|
||||
darwinConfigurations =
|
||||
nixpkgs.lib.foldAttrs
|
||||
(acc: x: acc)
|
||||
[]
|
||||
(builtins.attrValues
|
||||
(builtins.mapAttrs
|
||||
(system: hosts:
|
||||
nixpkgs.lib.attrsets.filterAttrs
|
||||
(host: config: config != null)
|
||||
(builtins.mapAttrs
|
||||
(host: config:
|
||||
if (hasFiles [ "configuration.nix" ] config)
|
||||
then mkNixDarwinHost system host
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
[ "configuration.nix" ]
|
||||
config)
|
||||
(system: host: config:
|
||||
mkNixDarwinHost
|
||||
system
|
||||
host
|
||||
(builtins.map
|
||||
(nixpkgs.lib.strings.removeSuffix ".nix")
|
||||
(builtins.attrNames (config."home" or {})))
|
||||
else null)
|
||||
hosts))
|
||||
nixDarwinMachines));
|
||||
(builtins.attrNames (config."home" or {}))))
|
||||
nixDarwinMachines;
|
||||
|
||||
homeConfigurations =
|
||||
nixpkgs.lib.foldAttrs
|
||||
(acc: x: acc)
|
||||
[]
|
||||
(builtins.attrValues
|
||||
(builtins.mapAttrs
|
||||
(system: hosts:
|
||||
nixpkgs.lib.attrsets.filterAttrs
|
||||
(host: config: config != null)
|
||||
(builtins.mapAttrs
|
||||
(host: config:
|
||||
if (hasFiles [ "home.nix" ] config)
|
||||
then mkNixOnDroidHost system host
|
||||
else null)
|
||||
hosts))
|
||||
homeManagerMachines));
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
[ "home.nix" ]
|
||||
config)
|
||||
(system: host: config:
|
||||
mkHomeManagerHost
|
||||
system
|
||||
host)
|
||||
homeManagerMachines;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue