mirror of
https://github.com/donovanglover/nix-config.git
synced 2025-01-23 22:28:36 +01:00
feat(nix): Use single expression for module/overlay outputs
This makes the code much DRYer overall.
This commit is contained in:
parent
e84d3bbf02
commit
c421fe245f
32
flake.nix
32
flake.nix
@ -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"]));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user