outputs: use lib.pipe in nixosConfigurations

This commit is contained in:
Wroclaw 2024-07-02 23:24:19 +02:00
parent f39c0b54d0
commit 4f10f70c70

View file

@ -14,22 +14,25 @@ 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
dir = builtins.readDir ./hosts;
# list nix file paths in ./hosts to attributes in nixosConfigurations # list nix file paths in ./hosts to attributes in nixosConfigurations
filePaths = lib.mapAttrsToList (name: _: name) (lib.filterAttrs (name: type: filePaths = lib.pipe ./hosts [
builtins.readDir
( lib.filterAttrs (name: type:
# filter out non-nix files # filter out non-nix files
type == "regular" type == "regular"
# filter out files that don't end in .nix # filter out files that don't end in .nix
&& lib.hasSuffix ".nix" name && lib.hasSuffix ".nix" name
# filter out files that start with . # filter out files that start with .
&& !lib.hasPrefix "." name && !lib.hasPrefix "." name
) dir ))
); (lib.mapAttrsToList (name: _: 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 list of nix file paths to attrSet with initialized NixOS configurations,
# whose names are derived from file names # whose names are derived from file names
builtins.listToAttrs (builtins.map (name: { lib.pipe filePaths [
(builtins.map (name: {
name = builtins.substring 0 (builtins.stringLength name - 4) name; name = builtins.substring 0 (builtins.stringLength name - 4) name;
value = nixosSystem { value = nixosSystem {
inherit lib; inherit lib;
@ -45,8 +48,9 @@ self = {
]; ];
specialArgs = { inherit self inputs; }; specialArgs = { inherit self inputs; };
}; };
}) filePaths }))
); builtins.listToAttrs
];
}; };
in self in self