diff options
author | Robert Hensing <robert@roberthensing.nl> | 2020-10-20 13:47:24 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2020-10-22 13:46:47 +0200 |
commit | afa6c51f27fb86fda71f91a51b093a5fc3de797d (patch) | |
tree | 99dc279dd61c53c85643f66a1c0c83e7004a9c3b /lib/strings-with-deps.nix | |
parent | 5aa2a98dfa0b54fef1b5cc7059ac8c4b1248a739 (diff) | |
download | nixpkgs-afa6c51f27fb86fda71f91a51b093a5fc3de797d.tar nixpkgs-afa6c51f27fb86fda71f91a51b093a5fc3de797d.tar.gz nixpkgs-afa6c51f27fb86fda71f91a51b093a5fc3de797d.tar.bz2 nixpkgs-afa6c51f27fb86fda71f91a51b093a5fc3de797d.tar.lz nixpkgs-afa6c51f27fb86fda71f91a51b093a5fc3de797d.tar.xz nixpkgs-afa6c51f27fb86fda71f91a51b093a5fc3de797d.tar.zst nixpkgs-afa6c51f27fb86fda71f91a51b093a5fc3de797d.zip |
lib: Use Nix's static scope checking, fix error message, optimize
Nix can perform static scope checking, but whenever code is inside a `with` expression, the analysis breaks down, because it can't know statically what's in the attribute set whose attributes were brought into scope. In those cases, Nix has to assume that everything works out. Except it doesnt. Removing `with` from lib/ revealed an undefined variable in an error message. If that doesn't convince you that we're better off without `with`, I can tell you that this PR results in a 3% evaluation performance improvement because Nix can look up local variables by index. This adds up with applications like the module system. Furthermore, removing `with` makes the binding site of each variable obvious, which helps with comprehension.
Diffstat (limited to 'lib/strings-with-deps.nix')
-rw-r--r-- | lib/strings-with-deps.nix | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/strings-with-deps.nix b/lib/strings-with-deps.nix index e3336983428..7b88b018da5 100644 --- a/lib/strings-with-deps.nix +++ b/lib/strings-with-deps.nix @@ -41,10 +41,15 @@ Usage: [1] maybe this behaviour should be removed to keep things simple (?) */ -with lib.lists; -with lib.attrsets; -with lib.strings; - +let + inherit (lib) + concatStringsSep + head + isAttrs + listToAttrs + tail + ; +in rec { /* !!! The interface of this function is kind of messed up, since |