feat(flake.nix): Drastically simplify output generation

This makes it much easier to read the output expression.
This commit is contained in:
Donovan Glover 2024-04-01 11:05:08 -04:00
parent dd171006b2
commit 918f0dc44a
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -21,7 +21,7 @@
};
};
outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs: with nixpkgs.lib; {
outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs: with nixpkgs.lib; with nixpkgs.legacyPackages.x86_64-linux; {
nixosConfigurations = {
nixos = nixosSystem {
system = "x86_64-linux";
@ -47,37 +47,21 @@
};
};
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
formatter.x86_64-linux = nixpkgs-fmt;
} //
(builtins.listToAttrs
(builtins.map
(attr: {
name = attr;
(attributeName: {
name = attributeName;
value = let
directory = builtins.replaceStrings
["nixosModules" "homeManagerModules"]
["modules" "home"]
attr;
function = if directory == "packages"
then nixpkgs.legacyPackages.x86_64-linux.callPackage
else import;
filesMap = (builtins.listToAttrs
directory = builtins.replaceStrings ["nixosModules" "homeManagerModules"] ["modules" "home"] attributeName;
attributeValue = (builtins.listToAttrs
(builtins.map
(filename: {
name = builtins.replaceStrings [".nix"] [""] filename;
value = function ./${directory}/${filename}; })
(builtins.attrNames
(builtins.readDir ./${directory}))));
callP = (builtins.listToAttrs
(builtins.map
(filename: {
name = builtins.replaceStrings [".nix"] [""] filename;
value = function ./${directory}/${filename} { }; })
(builtins.attrNames
(builtins.readDir ./${directory}))));
val = if directory == "packages"
then { x86_64-linux = callP; }
else filesMap;
in (val); })
(file: {
name = builtins.replaceStrings [".nix"] [""] file;
value = if directory == "packages" then callPackage ./${directory}/${file} { } else import ./${directory}/${file}; })
(builtins.attrNames (builtins.readDir ./${directory}))));
attributeSet = if directory == "packages" then { x86_64-linux = attributeValue; } else attributeValue;
in (attributeSet); })
["overlays" "nixosModules" "homeManagerModules" "packages"]));
}