Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib.getAttrFromPath: Don't use errorMessage variable
|
|
lib.mapAttrsRecursiveCond: Eliminate intermediate one intermediate variable environment
|
|
lib.zipAttrs: Remove needless function wrapping
|
|
lib.chooseDevOutputs: Remove needless function wrapping
|
|
* doc: add details on `mapAttrsRecursive[Cond]`
from first reading it wasn't clear that `f` also takes the current
attribute path. also the value f receives is tricky due to how the
condition is evaluated.
Co-authored-by: Daniel Sidhion <DanielSidhion@users.noreply.github.com>
|
|
We can just pass the error message on without creating an environment.
|
|
environment
|
|
Returning the partially applied `zipAttrsWith fn` is the same as `sets: zipAttrsWith fn sets`.
|
|
Returning the partially applied `map getDev` is the same as `drvs: map getDev drvs`.
|
|
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
|
|
The deprecation warnings in lib were wildly inconsistent. Different
formulations were used in different places for the same meaning. Some warnings
used builtins.trace instead of lib.warn, which prevents silencing; one even
only had a comment instead. Make everything more uniform.
|
|
|
|
|
|
Allows finding the most specific path that exists.
This is useful for error messages relating to attribute paths.
|
|
lib.attrsets.matchAttrs: Avoid some list allocations when walking structure
|
|
Using `tail` in a recursive loop like this needlessly allocates.
This changes the loop to look up by list index instead.
|
|
Using `tail` in a recursive loop like this needlessly allocates.
This changes the loop to look up by list index instead.
|
|
Benchmarks (`nix-instantiate ./. -A python3`):
- Before:
``` json
{
"cpuTime": 0.29049500823020935,
"envs": {
"bytes": 4484216,
"elements": 221443,
"number": 169542
},
"gc": {
"heapSize": 402915328,
"totalBytes": 53086800
},
"list": {
"bytes": 749424,
"concats": 4242,
"elements": 93678
},
"nrAvoided": 253991,
"nrFunctionCalls": 149848,
"nrLookups": 49612,
"nrOpUpdateValuesCopied": 1587837,
"nrOpUpdates": 10104,
"nrPrimOpCalls": 130356,
"nrThunks": 358981,
"sets": {
"bytes": 30423600,
"elements": 1859999,
"number": 41476
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 236145,
"number": 24453
},
"values": {
"bytes": 10502520,
"number": 437605
}
}
```
- After:
``` json
{
"cpuTime": 0.2946169972419739,
"envs": {
"bytes": 3315224,
"elements": 172735,
"number": 120834
},
"gc": {
"heapSize": 402915328,
"totalBytes": 48718432
},
"list": {
"bytes": 347568,
"concats": 4242,
"elements": 43446
},
"nrAvoided": 173252,
"nrFunctionCalls": 101140,
"nrLookups": 73595,
"nrOpUpdateValuesCopied": 1587837,
"nrOpUpdates": 10104,
"nrPrimOpCalls": 83067,
"nrThunks": 304216,
"sets": {
"bytes": 29704096,
"elements": 1831673,
"number": 24833
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 236145,
"number": 24453
},
"values": {
"bytes": 8961552,
"number": 373398
}
}
```
|
|
See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0
|
|
lib.attrsets.attrsToList: add function
|
|
For transforming back between lists and attrsets, it makes sense to have
a quasi-inverse of `builtins.listToAttrs` available as a library
function.
Co-authored-by: Silvan Mosberger <github@infinisil.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
|
|
See the parent commit for the same change to lib.lists.foldl'
|
|
To maintain backwards compatibility, this can't be changed in the Nix language.
We can however ensure that the version Nixpkgs has the more intuitive behavior.
|
|
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
|
|
|
|
|
|
I'm expecting all the builtins.* functions to be available in lib.*
|
|
- provide comprehensive example
- add unit test
|
|
There are a number of different syntaxes used for attrset type
signatures in our doc strings, this change standardises upon one that
uses :: for specifying attribute type, and ; terminators to be
consistent with nix syntax. There are no bugs in the functions
themselves, just that different syntaxes may confuse new users.
|
|
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
|
|
|
|
caused problems for automated rich text generation such as
https://teu5us.github.io/nix-lib.html#customisation-functions
|
|
|
|
|
|
If all the docs are auto-generated, it should be easier to convert
them to Commonmark.
Co-Authored-By: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
|
|
|
|
|
|
This brings two benefits:
1. The complete list of collisions is printed in the whenever any colliding
attribute is accessed.
2. The sets are intersected using a C++ primitive, which runs in O(n) time
(intersecting pre-sorted lists) with small constants rather than interpreted
Nix code.
Thanks to @toonn for prompting this improvement.
|
|
|
|
|
|
|
|
Introduce `lib.updateManyAttrsByPath`
|
|
|