summaryrefslogtreecommitdiff
path: root/lib/attrsets.nix (follow)
Commit message (Expand)AuthorAgeFilesLines
* lib.getAttrFromPath: fix docsSilvan Mosberger2025-04-221-2/+2
* treewide: Format all Nix files•••Format all Nix files using the officially approved formatter, making the CI check introduced in the previous commit succeed: nix-build ci -A fmt.check This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153) of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166). This commit will lead to merge conflicts for a number of PRs, up to an estimated ~1100 (~33%) among the PRs with activity in the past 2 months, but that should be lower than what it would be without the previous [partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537). Merge conflicts caused by this commit can now automatically be resolved while rebasing using the [auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase). If you run into any problems regarding any of this, please reach out to the [formatting team](https://nixos.org/community/teams/formatting/) by pinging @NixOS/nix-formatting. Silvan Mosberger2025-04-011-322/+265
* docs(lib): fix weird structures in attrsets docstringsDaniel Flanagan2025-02-141-2/+2
* lib: improve filterAttrs (#345547)Silvan Mosberger2024-11-011-3/+2
|\
| * lib: refactor `filterAttrs`•••`filter` is a primop which is designed for this task, and it saves the allocation of some singleton lists here. Robert Hensing2024-10-311-2/+2
| * lib: improve `filterAttrs`•••Co-authored-by: Silvan Mosberger <contact@infinisil.com> h7x42024-10-251-2/+1
* | treewide: lib.isInOldestRelease -> lib.oldestSupportedReleaseIsAtLeastRobert Hensing2024-10-081-2/+2
|/
* lib: add getStaticSomeone Serge2024-07-211-0/+29
* lib: reflect effective signatures of getOutput functionsSomeone Serge2024-07-211-16/+18
* lib: add getOutput', a nix-lang counterpart of _overrideFirstSomeone Serge2024-07-211-1/+72
* lib.intersectAttrs: Export from builtinsSilvan Mosberger2024-06-201-1/+1
* lib/attrsets: introduce mapCartesianProductGabriel Volpe2024-04-151-0/+34
* lib/attrsets: rename cartesianProductOfSets to cartesianProductGabriel Volpe2024-04-151-5/+9
* lib.hasAttrByPath: fix typo (#302042)Tharun Thennarasu2024-04-061-2/+2
* Apply suggestions from code reviewDaniel Sidhion2024-03-191-0/+56
* doc: manual fixup after migrationJohannes Kirschbauer2024-03-191-71/+12
* doc: migrate lib.attrsets to use doc-commentsJohannes Kirschbauer2024-03-151-447/+1242
* Merge pull request #292941 from adisbladis/lib-getattrfrompath-env•••lib.getAttrFromPath: Don't use errorMessage variableSilvan Mosberger2024-03-061-2/+1
|\
| * lib.getAttrFromPath: Don't use errorMessage variable•••We can just pass the error message on without creating an environment. adisbladis2024-03-031-2/+1
* | Merge pull request #292938 from adisbladis/mapattrsrecursivecond-env•••lib.mapAttrsRecursiveCond: Eliminate intermediate one intermediate variable environmentSilvan Mosberger2024-03-061-7/+6
|\ \
| * | lib.mapAttrsRecursiveCond: Eliminate intermediate one intermediate variable e...adisbladis2024-03-031-7/+6
| |/
* | Merge pull request #292937 from adisbladis/zipattrs-env•••lib.zipAttrs: Remove needless function wrappingSilvan Mosberger2024-03-061-4/+1
|\ \
| * | lib.zipAttrs: Remove needless function wrapping•••Returning the partially applied `zipAttrsWith fn` is the same as `sets: zipAttrsWith fn sets`. adisbladis2024-03-031-4/+1
| |/
* | Merge pull request #292934 from adisbladis/lib-choosedevoutput•••lib.chooseDevOutputs: Remove needless function wrappingSilvan Mosberger2024-03-061-4/+1
|\ \
| * | lib.chooseDevOutputs: Remove needless function wrapping•••Returning the partially applied `map getDev` is the same as `drvs: map getDev drvs`. adisbladis2024-03-031-4/+1
| |/
* / doc: add details on `mapAttrsRecursive[Cond]` (#293509)•••* 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>Valentin Gagarin2024-03-061-31/+46
|/
* lib.attrsets: Remove unneeded polyfills•••Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around. Silvan Mosberger2024-02-091-9/+6
* lib: make deprecation warnings consistent•••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. Alois Wohlschlager2024-02-031-4/+5
* lib/attrsets: Document and link Nix language operatorsRobert Hensing2023-12-131-0/+24
* lib.attrsets.hasAttrByPath: Document law and laziness, and test itRobert Hensing2023-12-081-0/+7
* lib.attrsets.longestValidPathPrefix: init•••Allows finding the most specific path that exists. This is useful for error messages relating to attribute paths. Robert Hensing2023-12-081-0/+65
* Merge pull request #269552 from adisbladis/lib-matchattrs-list-allocs•••lib.attrsets.matchAttrs: Avoid some list allocations when walking structureRobert Hensing2023-11-271-9/+20
|\
| * lib.attrsets.matchAttrs: Avoid some list allocations when walking structure•••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 } } ``` adisbladis2023-11-271-9/+20
* | lib.attrsets.attrByPath: Don't allocate one extra list per lookup recursion•••Using `tail` in a recursive loop like this needlessly allocates. This changes the loop to look up by list index instead. adisbladis2023-11-271-11/+21
* | lib.attrsets.hasAttrByPath: Don't allocate one extra list per lookup recursion•••Using `tail` in a recursive loop like this needlessly allocates. This changes the loop to look up by list index instead. adisbladis2023-11-271-6/+10
|/
* lib: Take advantage of section descriptions•••See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0 Silvan Mosberger2023-11-201-1/+1
* Merge pull request #254452 from flyingcircusio/lib-attrsToList•••lib.attrsets.attrsToList: add functionSilvan Mosberger2023-10-101-0/+30
|\
| * 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> Oliver Schmidt2023-10-101-0/+30
* | lib.attrsets.foldlAttrs: Make stricter•••See the parent commit for the same change to lib.lists.foldl' Silvan Mosberger2023-09-271-5/+5
* | lib.lists.foldl': Make strict in the initial accumulator•••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. Silvan Mosberger2023-09-271-1/+1
|/
* lib.attrsets.mergeAttrsList: init•••Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Silvan Mosberger2023-07-181-0/+36
* lib/attrsets: remove unused let bindingsfigsoda2023-06-231-1/+1
* lib.concatMapAttrs: Simplify stack traceRobert Hensing2023-05-311-1/+5
* lib: add missing removeAttrs builtin•••I'm expecting all the builtins.* functions to be available in lib.* zimbatm2023-04-191-1/+1
* init: lib.foldlAttrs•••- provide comprehensive example - add unit test hsjobeki2023-03-111-0/+60
* lib: standardise attrset type syntax•••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. Colin Arnott2023-01-301-5/+5
* Update lib/attrsets.nix•••Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>Adam Joseph2023-01-251-1/+4
* attrsets: clarify that mapAttrs maps over *leaf* attrsAdam Joseph2023-01-221-2/+4
* lib: Fix mismatched quotes in `lib.*` doc comments•••caused problems for automated rich text generation such as https://teu5us.github.io/nix-lib.html#customisation-functions YoshiRulz2023-01-021-10/+10
* attrsets: fix and add some doc typeshsjobeki2022-12-241-25/+36