feat(nix): Use single expression for module/overlay outputs

This makes the code much DRYer overall.
This commit is contained in:
Donovan Glover 2024-03-31 22:22:22 -04:00
parent e84d3bbf02
commit c421fe245f
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -39,18 +39,22 @@
packages."x86_64-linux" = with nixpkgs.legacyPackages."x86_64-linux";
builtins.mapAttrs (name: value: callPackage ./packages/${name}) (builtins.readDir ./packages);
overlays = builtins.mapAttrs (name: value: import ./overlays/${name}) (builtins.readDir ./overlays);
nixosModules =
(builtins.listToAttrs
(builtins.map
(string: {
name = builtins.replaceStrings [".nix"] [""] string;
value = import ./modules/${string}; })
(builtins.attrNames
(builtins.readDir ./modules))));
homeManagerModules = builtins.mapAttrs (name: value: import ./home/${name}) (builtins.readDir ./home);
};
} //
(builtins.listToAttrs
(builtins.map
(attr: {
name = attr;
value = let
directory = builtins.replaceStrings
["nixosModules" "homeManagerModules"]
["modules" "home"]
attr;
in (builtins.listToAttrs
(builtins.map
(filename: {
name = builtins.replaceStrings [".nix"] [""] filename;
value = import ./${directory}/${filename}; })
(builtins.attrNames
(builtins.readDir ./${directory})))); })
["overlays" "nixosModules" "homeManagerModules"]));
}