flake: abstract nameOf for path to name conversion

This commit is contained in:
Donovan Glover 2024-10-09 19:50:18 -04:00
parent de8791ea22
commit 786bbcf03a
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -39,6 +39,7 @@
inherit (nixpkgs.legacyPackages) x86_64-linux aarch64-linux; inherit (nixpkgs.legacyPackages) x86_64-linux aarch64-linux;
inherit (builtins) listToAttrs map replaceStrings; inherit (builtins) listToAttrs map replaceStrings;
nameOf = path: replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString path));
forAllSystems = function: forAllSystems = function:
nixpkgs.lib.genAttrs [ nixpkgs.lib.genAttrs [
"x86_64-linux" "x86_64-linux"
@ -53,27 +54,27 @@
nixosModules = listToAttrs ( nixosModules = listToAttrs (
map (file: { map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file)); name = nameOf file;
value = import file; value = import file;
}) (listFilesRecursive ./modules) }) (listFilesRecursive ./modules)
); );
homeModules = listToAttrs ( homeModules = listToAttrs (
map (file: { map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file)); name = nameOf file;
value = import file; value = import file;
}) (listFilesRecursive ./home) }) (listFilesRecursive ./home)
); );
overlays = listToAttrs ( overlays = listToAttrs (
map (file: { map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file)); name = nameOf file;
value = import file; value = import file;
}) (listFilesRecursive ./overlays) }) (listFilesRecursive ./overlays)
); );
checks.x86_64-linux = listToAttrs (map (file: { checks.x86_64-linux = listToAttrs (map (file: {
name = replaceStrings [ ".nix" ] [ "" ] (baseNameOf (toString file)); name = nameOf file;
value = import file { value = import file {
inherit self; inherit self;