Commit Graph

161 Commits

Author SHA1 Message Date
Johannes Kirschbauer
d4f9b38c18 lib.attrsets: performance improvements (#523872) 2026-08-08 15:40:37 +00:00
Eman Resu
9b7289dfc5 lib: improve implementation of foldAttrs (#547436) 2026-08-06 22:25:55 +00:00
h7x4
331c4cf699 lib: improve implementation of foldAttrs 2026-07-31 01:35:00 +09:00
h7x4
e74c1dad9d lib: improve implementation of overrideExisting 2026-07-30 23:55:19 +09:00
Ryan Mulligan
d875aae529 doc: fix mmdoc fenced div rendering 2026-07-14 14:02:36 -07:00
Eman Resu
442c1d9296 lib.attrsets.mapAttrsRecursive: beta reduce 2026-06-24 18:34:50 -04:00
Eman Resu
ebbae9566a lib.attrsets.getFirstOutput: avoid builtins lookup 2026-06-24 18:34:39 -04:00
Eman Resu
24b77159de lib.attrsets.getFirstOutput: use ? instead of hasAttr 2026-06-24 18:34:26 -04:00
Eman Resu
26ddb0d857 lib.attrsets.getFirstOutput: inline variable 2026-06-24 18:34:24 -04:00
Eman Resu
8760d9dbed lib.attrsets.collect: use recurse function to avoid passing pred 2026-06-21 19:41:21 -04:00
Eman Resu
27e8b1f69f lib.attrsets.dontRecurseIntoAttrs: only create attrset once 2026-06-21 19:41:21 -04:00
Eman Resu
75cf725444 lib.attrsets.recurseIntoAttrs: only create attrset once 2026-06-21 19:41:21 -04:00
Eman Resu
411e96cfa2 lib.attrsets.getAttrFromPath: beta reduce 2026-06-21 19:27:58 -04:00
Eman Resu
1c53d25f58 lib.attrsets.concatMapAttrs: rewrite for efficiency 2026-06-21 18:01:06 -04:00
Eman Resu
e7a80a0510 lib.attrsets.matchAttrs: check attrset equality before recursing 2026-06-20 16:53:33 -04:00
Eman Resu
bc4b353bff lib.attrsets.matchAttrs: only assert isAttrs once 2026-06-20 16:53:32 -04:00
Eman Resu
2d99119aa0 lib.attrsets.mergeAttrsList: check equality instead of comparing 2026-06-10 12:22:39 -04:00
Eman Resu
dd16d43a35 lib.attrsets.mergeAttrsList: use simpler midpoint function 2026-06-06 02:42:26 -04:00
Eman Resu
89a8033268 lib.attrsets.genAttrs: redefine genAttrs' logic inline 2026-05-25 00:01:17 -04:00
İlkecan Bozdoğan
6acae46c84 lib: don't inherit unused functions 2026-03-04 00:10:00 +03:00
İlkecan Bozdoğan
e394a579b0 lib: update type signatures
- concrete types start with uppercase: Int, String, Bool, Derivation,
  etc.
- type variables start with lowercase: a, b, etc.
- list:
  - use `[x]` for homogeneous lists instead of `List x` or `[ x ]`
  - use `List` for heterogeneous lists (not that common in `lib`)
- attr:
  - use `AttrSet` for a generic attribute set type
  - use `{ key1 :: Type1; key2 :: Type2; ... }` for adding signatures
    for known attribute names and types
  - use `{ key1 = value1; key2 = value2; ... }` for adding attributes
    with known literals
  - end with an ellipsis (`...`) if the set can contain unknown
    attributes
  - use `{ [String] :: x }` if all the attributes has the same type `x`
- prefer `Any` over `a` if the latter is not reused
2026-03-04 00:10:00 +03:00
İlkecan Bozdoğan
64a8ada54e lib: add type signature to some of the functions 2026-03-02 15:46:43 +00:00
Johannes Kirschbauer
eda04ce64e docs: improve docs for 'lib.attrsets.recursiveUpdateUntil' 2026-01-14 20:38:59 -05:00
Anton Mosich
0ba9a655f2 docs/lib: Fix smaller typos
The changes is lib/attrsets.nix make sure the names are consistent with
the names used in the respective description.
2025-11-29 22:04:24 +01:00
Anton Mosich
4fc8af31c0 docs/lib: use note/warning markup more consistently 2025-11-29 22:03:10 +01:00
Anton Mosich
367d102c09 docs/lib: use backticks for nix names 2025-11-29 21:46:54 +01:00
Philip Taron
3aefc14aca lib.attrsets: remove deprecated names
- `lib.attrsets.cartesianProductOfSets` was deprecated in 228621e42d
- `lib.attrsets.zip` was deprecated in fcbc4fe9ff (2013!)
- `lib.attrsets.zipWithNames` was deprecated in 00127bef3f (2009!)

The time has come.
2025-10-13 09:09:59 -07:00
Johannes Kirschbauer
bb9da33c62 lib/*: fix docs to use "returns" instead of "return" (#442388) 2025-10-06 08:09:54 +00:00
NAHO
6177c4ad72 lib: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd --type file . lib --exec-batch sed --in-place --regexp-extended "
      s/\<builtins\.($(
        printf '%s\n' "${builtins[@]}" |
          paste --delimiter '|' --serial -
      ))\>/\1/g
    "

    nix fmt
2025-09-30 09:02:59 +02:00
Felix Buehler
06ac3fbebd lib/*: fix docs to use "returns" instead of "return" 2025-09-12 16:16:41 +02:00
Wolfgang Walther
399136b3d7 lib/attrsets: add mapAttrsToListRecursive(Cond) function (#395160) 2025-09-08 19:12:59 +00:00
Wolfgang Walther
bf4b47abc7 lib.attrsets.unionOfDisjoint: simplify explanation
The whole business of `// z` is a confusing implementation detail for
the reader.
2025-09-01 16:52:54 +02:00
Plume
0477b30ab6 lib.attrsets.genAttrs': init (#436434)
* lib.attrsets.genAttrs': init

* lib.attrsets.genAttrs: rewrite with lib.attrsets.genAttrs'

* lib.attrsets.{genAttrs,genAttrs'}: add tests

* Update lib/attrsets.nix

Co-authored-by: Johannes Kirschbauer <hsjobeki+github@gmail.com>

* Update lib/attrsets.nix

Co-authored-by: Johannes Kirschbauer <hsjobeki+github@gmail.com>

* lib.attrsets.genAttrs': document and test attrName collision

---------

Co-authored-by: Johannes Kirschbauer <hsjobeki+github@gmail.com>
2025-09-01 11:58:28 +02:00
Mikael Voss
e5ac84e29c lib/attrsets: add mapAttrsToListRecursive(Cond) function 2025-08-31 12:11:43 +02:00
jefrwld
37c19df121 lib.attrsets: fix typo in attrVals documentation: 'attribitue' -> 'attribute' 2025-08-12 19:42:37 +02:00
Robert Hensing
77c2981a7d lib.attrsets.filterAttrs: Add tips to doc 2025-07-27 15:39:35 +02:00
Léana 江
a2f1023f57 doc: fix example consistency on mapAttrsRecursiveCond
The example should take a two argument function `f`.
2025-06-22 15:26:07 +02:00
Peder Bergebakken Sundt
c77ac9dfc3 treewide: fix typos 2025-06-02 16:07:07 +02:00
ccicnce113424
4551258940 lib: refactor lib.attrsets.{mapAttrs', mapAttrsToList} and mapAttrs'' in the strongswan-swanctl module
The new implementation of `mapAttrsToList` is simpler than the previous one, avoiding an extra string conversion. Benchmarking shows a slight performance improvement. See the discussion here: https://discourse.nixos.org/t/another-implementation-of-mapattrstolist

Additionally, I searched nixpkgs for expressions equivalent to the old `mapAttrsToList` and replaced them with direct calls to the new implementation.
2025-05-08 13:58:54 +08:00
Silvan Mosberger
3ca8b685c8 lib.getAttrFromPath: fix docs 2025-04-22 23:39:18 +02:00
Silvan Mosberger
374e6bcc40 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](8616af08d9/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.
2025-04-01 20:10:43 +02:00
Daniel Flanagan
208049c89c docs(lib): fix weird structures in attrsets docstrings 2025-02-14 23:04:58 -06:00
Silvan Mosberger
5690833b4f lib: improve filterAttrs (#345547) 2024-11-01 11:54:20 +01:00
Robert Hensing
1de8e07216 lib: refactor filterAttrs
`filter` is a primop which is designed for this task, and it saves
the allocation of some singleton lists here.
2024-10-31 16:30:07 +01:00
h7x4
c7c30eb452 lib: improve filterAttrs
Co-authored-by: Silvan Mosberger <contact@infinisil.com>
2024-10-25 15:07:12 +02:00
Robert Hensing
729225e355 treewide: lib.isInOldestRelease -> lib.oldestSupportedReleaseIsAtLeast 2024-10-08 11:14:24 +02:00
Someone Serge
98384afab5 lib: add getStatic 2024-07-21 11:38:04 +00:00
Someone Serge
76db6ba81a lib: reflect effective signatures of getOutput functions 2024-07-21 11:37:38 +00:00
Someone Serge
744305bce4 lib: add getOutput', a nix-lang counterpart of _overrideFirst 2024-07-21 11:29:23 +00:00
Silvan Mosberger
56535c832f lib.intersectAttrs: Export from builtins 2024-06-20 17:59:36 +02:00