outputs: merge pipe expression
add comments too
This commit is contained in:
parent
37f4ff706a
commit
08c9fa5545
1 changed files with 13 additions and 15 deletions
28
outputs.nix
28
outputs.nix
|
@ -19,26 +19,24 @@ self = {
|
||||||
versionInfoFixup = import ./pkgs/overlays/version-info-fixup.nix { inherit inputs; };
|
versionInfoFixup = import ./pkgs/overlays/version-info-fixup.nix { inherit inputs; };
|
||||||
};
|
};
|
||||||
nixosConfigurations = let
|
nixosConfigurations = let
|
||||||
# list nix file paths in ./hosts to attributes in nixosConfigurations
|
|
||||||
filePaths = lib.pipe ./hosts [
|
|
||||||
builtins.readDir
|
|
||||||
( lib.filterAttrs (name: type:
|
|
||||||
( # regular .nix files
|
|
||||||
(type == "regular" && lib.hasSuffix ".nix" name)
|
|
||||||
|| # directories that contain a default.nix file
|
|
||||||
(type == "directory" && builtins.pathExists "${./.}/hosts/${name}/default.nix")
|
|
||||||
)
|
|
||||||
# filter out files that start with .
|
|
||||||
&& !lib.hasPrefix "." name
|
|
||||||
))
|
|
||||||
];
|
|
||||||
nixosSystem = import "${inputs.nixpkgs}/nixos/lib/eval-config.nix";
|
nixosSystem = import "${inputs.nixpkgs}/nixos/lib/eval-config.nix";
|
||||||
in
|
in
|
||||||
# mapped list of nix file paths to attrSet with initialized NixOS configurations,
|
# mapped atrrsed of nix file paths to attrSet with initialized NixOS configurations,
|
||||||
# whose names are derived from file names
|
# whose names are derived from file names
|
||||||
lib.pipe filePaths [
|
lib.pipe ./hosts [
|
||||||
|
builtins.readDir
|
||||||
|
# filter out files that are not .nix files, directories with default.nix or starting with . (dot, hidden files)
|
||||||
|
( lib.filterAttrs (name: type:
|
||||||
|
(
|
||||||
|
(type == "regular" && lib.hasSuffix ".nix" name)
|
||||||
|
|| (type == "directory" && builtins.pathExists "${./.}/hosts/${name}/default.nix")
|
||||||
|
)
|
||||||
|
&& !lib.hasPrefix "." name
|
||||||
|
))
|
||||||
(builtins.mapAttrs (name: type: {
|
(builtins.mapAttrs (name: type: {
|
||||||
|
# remove .nix extension
|
||||||
name = if type == "directory" then name else builtins.substring 0 (builtins.stringLength name - 4) name;
|
name = if type == "directory" then name else builtins.substring 0 (builtins.stringLength name - 4) name;
|
||||||
|
# initialize NixOS configuration
|
||||||
value = nixosSystem {
|
value = nixosSystem {
|
||||||
inherit lib;
|
inherit lib;
|
||||||
modules = [
|
modules = [
|
||||||
|
|
Loading…
Add table
Reference in a new issue