mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
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
This commit is contained in:
parent
1db8650fb4
commit
065b48084f
1 changed files with 3 additions and 2 deletions
|
@ -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 ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue