From a76abd2a7b826c4e7fa7a48ec4a9ceb5d976f622 Mon Sep 17 00:00:00 2001 From: nicoo Date: Thu, 12 Dec 2024 18:02:21 +0000 Subject: [PATCH] lib.packagesFromDirectoryRecursive: let-bind functions called from `lib` I was told it is better for eval performance: https://github.com/NixOS/nixpkgs/pull/361424#discussion_r1879975642 --- lib/filesystem.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/filesystem.nix b/lib/filesystem.nix index 753088f75..e54776ba9 100644 --- a/lib/filesystem.nix +++ b/lib/filesystem.nix @@ -364,13 +364,14 @@ in ... }: let + inherit (lib) concatMapAttrs removeSuffix; inherit (lib.path) append; defaultPath = append directory "package.nix"; in if pathExists defaultPath then # if `${directory}/package.nix` exists, call it directly callPackage defaultPath {} - else lib.concatMapAttrs (name: type: + else concatMapAttrs (name: type: # otherwise, for each directory entry let path = append directory name; in if type == "directory" then { @@ -381,7 +382,7 @@ in }; } else if type == "regular" && hasSuffix ".nix" name then { # call .nix files - "${lib.removeSuffix ".nix" name}" = callPackage path {}; + "${removeSuffix ".nix" name}" = callPackage path {}; } else if type == "regular" then { # ignore non-nix files } else throw ''