flake: remove attribute name map

Reduces complexity a bit now that we're using listFilesRecursive.
This commit is contained in:
Donovan Glover 2024-10-09 19:44:40 -04:00
parent 723c5c6f0d
commit de8791ea22
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -39,18 +39,6 @@
inherit (nixpkgs.legacyPackages) x86_64-linux aarch64-linux;
inherit (builtins) listToAttrs map replaceStrings;
flakeOutputs = [
"overlays"
"nixosModules"
"homeModules"
];
flakeDirectories = [
"overlays"
"modules"
"home"
];
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
@ -63,6 +51,27 @@
directory = ./packages;
});
nixosModules = listToAttrs (
map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file));
value = import file;
}) (listFilesRecursive ./modules)
);
homeModules = listToAttrs (
map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file));
value = import file;
}) (listFilesRecursive ./home)
);
overlays = listToAttrs (
map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file));
value = import file;
}) (listFilesRecursive ./overlays)
);
checks.x86_64-linux = listToAttrs (map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file));
@ -129,20 +138,5 @@
x86_64-linux = x86_64-linux.nixfmt-rfc-style;
aarch64-linux = aarch64-linux.nixfmt-rfc-style;
};
}
// (listToAttrs (
map (attributeName: {
name = attributeName;
value =
let
directory = replaceStrings flakeOutputs flakeDirectories attributeName;
in
listToAttrs (
map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file));
value = import file;
}) (listFilesRecursive ./${directory})
);
}) flakeOutputs
));
};
}