Commit Graph

5275 Commits

Author SHA1 Message Date
Robert Hensing
8aa6e3dbb9 types.attrListWith: add valueMeta.definitions 2026-05-24 15:32:04 +02:00
Robert Hensing
e29bf2412b lib.modules.mapDefinitionValue: init 2026-05-24 15:32:04 +02:00
yaya
a2e55e31d6 26.11 is Zokor 2026-05-24 15:07:40 +02:00
Robert Hensing
f1b62fdc4e types.attrListWith: add asAttrs
This allows the type's return value to be accessed more easily.

Motivating use case:
- Built-in module provides CLI functionality by declaring
  an `attrListWith { asAttrs = true; }`, extracting the ordered list
  from `valueMeta` for the purpose of creating the `argv`.
- User modules can read the command line's flags directly without
  having to parse the list of attrs.
2026-05-24 15:07:05 +02:00
Robert Hensing
17fdb6f68a types.attrListWith: init
Trivial extraction from attrListOf.
2026-05-24 15:07:05 +02:00
Robert Hensing
43d998e6c0 types.attrListOf: init
This adds a type for name-value mappings that preserve ordering.

Motivating use case: command line flags for package modules /
wrappers / modular services.
The option value can be transformed into a command line in the
correct order.
Additionally, a convenience readOnly option could be provided
to give easy introspection access to the values in an ad hoc
manner.
2026-05-24 15:07:02 +02:00
Eman Resu
e9c2828c5a lib.generators.toGitINI: only recurse into necessary attributes 2026-05-21 18:16:47 -04:00
Eman Resu
ad02f2310f lib.generators.toGitINI: use concatMap to avoid a flatten at the end 2026-05-21 16:17:59 -04:00
Eman Resu
69bb729396 lib.generators.toGitINI: avoid concatenating and mapping on non-lists 2026-05-21 16:15:45 -04:00
Eman Resu
9b4dde7eba lib.generators.toGitINI: move escape logic outside of hot loop 2026-05-21 16:15:45 -04:00
Eman Resu
af62ce4887 lib.generators.toGitINI: avoid creating several variables on every call 2026-05-21 16:15:45 -04:00
Eman Resu
48a99a99fc lib.generators.toGitINI: only define helper variables once 2026-05-21 16:15:24 -04:00
Eman Resu
f23b117e50 lib.showWarnings: inherit lib functions, beta reduce for free 2026-05-21 14:50:51 -04:00
Eman Resu
7f6eb89aeb lib.{importJSON,importTOML}: inherit builtins to global scope 2026-05-21 14:47:07 -04:00
Eman Resu
1f83c2cc22 lib.toBaseDigits: avoid reversing list 2026-05-21 14:41:38 -04:00
Eman Resu
19fcf5006a lib.mirrorFunctionArgs: inline call to setFunctionArgs 2026-05-21 14:41:38 -04:00
adisbladis
8abecec2ab lib.extendMkDerivation: performance cleanups (#522123) 2026-05-21 02:48:31 +00:00
adisbladis
8efcb39ab2 lib.fetchers: minor performance improvements (#522121) 2026-05-21 02:46:56 +00:00
Eman Resu
32a1903229 lib.licenses: inherit lib functions into global scope 2026-05-20 00:32:15 -04:00
Eman Resu
1883329515 lib.licenses: use && for exception licenses
Seems preferable to iterating over a two-element list.
licenseType.exception is only used by lib.licenses.WITH, which I don't
see any usage of in tree - but thought I might as well.
2026-05-20 00:32:15 -04:00
Eman Resu
64e42fb8b1 lib.licenses: add evaluateNamedProperty for quickly checking subattributes 2026-05-20 00:32:14 -04:00
Eman Resu
9e48db8d39 lib.licenses: prevent subcalls for non-simple licenses 2026-05-19 23:02:22 -04:00
Eman Resu
22fcb80812 lib.licenses: only define OR and AND once 2026-05-19 23:02:21 -04:00
Eman Resu
fb84fe6d6f lib.fetchers.withNormalizedHash: share removed attributes for every call 2026-05-19 22:07:17 -04:00
Eman Resu
25118b87ed lib.fetchers.withNormalizedHash: define hashSet before taking fetcher 2026-05-19 22:07:17 -04:00
Eman Resu
35d9631df3 lib.fetchers: share default hash types between functions 2026-05-19 22:07:17 -04:00
Eman Resu
cb3f3435bb lib.fetchers: reuse default hash names between calls 2026-05-19 22:07:17 -04:00
Eman Resu
a64ab557a0 lib.fetchers.normalizeHash: avoid expensive builtins.tail call 2026-05-19 22:07:16 -04:00
Eman Resu
0466dc5b70 lib.fetchers.normalizeHash: remove unnecessary quotes 2026-05-19 22:07:16 -04:00
Eman Resu
e4d668e964 lib.fetchers: inherit commonH lib functions into global scope 2026-05-19 22:07:15 -04:00
Eman Resu
a6ff6c6bac lib.fetchers.withNormalizedHash: move lib inherits to toplevel 2026-05-19 22:07:15 -04:00
Eman Resu
1095dc1dd2 lib.fetchers.normalizeHash: move lib inherits to toplevel 2026-05-19 22:07:15 -04:00
Eman Resu
01272740d8 lib.extendMkDerivation: save several function calls 2026-05-19 20:59:24 -04:00
Eman Resu
a50c77cc33 lib.extendMkDerivation: use a single attrset instead of merging 2026-05-19 20:45:42 -04:00
Alyssa Ross
3570433a71 lib.licenses: add new spdxIds (#519321) 2026-05-18 12:56:15 +00:00
Alyssa Ross
5b6295c126 lib.license: add CFITSIO license, cfitsio: change license and homepage (#521119) 2026-05-18 06:01:05 +00:00
adisbladis
bd43f11bc5 lib.trivial: save attrset lookups in highly used functions (#520296) 2026-05-18 02:34:47 +00:00
Aliaksandr
20b7f2410b lib/customisation: reduce // merges in extendDerivation
Fold the 'all' attribute into the listToAttrs call alongside the outputs, so commonAttrs builds from drv // listToAttrs(...) // passthru // { drvPath; outPath; } instead of four separate merges with a standalone 'all' attrset.

Also convert remaining optionalAttrs to nullable attr names in extendDerivation, overrideDerivation, and makeOverridable.

Per-derivation // merges drop from 4 to 3.
2026-05-18 03:54:26 +03:00
Nicolas Benes
ab376383ec lib.license: add CFITSIO license 2026-05-17 01:14:09 +02:00
Emily
ba777b3b20 lib.systems.equals: fix euqality on re-elaborated platform (#521043) 2026-05-16 18:39:00 +00:00
Mix
cadca751c4 lib.systems.equals: fix euqality on re-elaborated platform 2026-05-17 02:14:48 +08:00
adisbladis
5a4597cc83 lib.systems: foldl -> foldl' 2026-05-16 15:51:29 +12:00
Eman Resu
4a438d1a8a lib.strings.toSentenceCase: use -1 trick instead of computing stringLength 2026-05-15 23:45:25 -04:00
Eman Resu
f908b7a78c lib.strings.versionAtLeast: avoid an extra function call 2026-05-15 23:45:24 -04:00
Eman Resu
9ff4fe0e93 lib.strings.splitString: use builtins from global scope
These are all already inherited.
2026-05-15 23:45:15 -04:00
Eman Resu
7a0811c24b lib.strings.hasInfix: compute escaped infix early 2026-05-15 23:44:49 -04:00
Eman Resu
28a5dc3806 lib.strings.normalizePath: use our hasSuffix optimization 2026-05-15 23:44:48 -04:00
Eman Resu
35ba022673 lib.strings: compute prefix and suffix lengths early
Meaningful if these functions are partially applied. Saves 16% primops,
12% thunks, and 6% memory bytes when recursively importing all the nix
files in nixpkgs. Slightly increases memory usage when partial function
application isn't done, but I think the benefits outweigh the losses
here.
2026-05-15 23:17:03 -04:00
Eman Resu
94148625b0 lib.strings: check if throw is necessary before taking str
If these functions are called with partial function application (like
`lib.hasPrefix ".nix"`), then we can avoid performing the isPath check
multiple times, and only confirm it once. This gives 12% less primops
when recursively importing all nix files in nixpkgs.
2026-05-15 23:12:54 -04:00
Eman Resu
9f5c9ea4a8 lib.strings: throw instead of warning when passed a path
We've had this warning for years at this point. Doing this will also
give us a free performance win in the next commits.
2026-05-15 23:12:50 -04:00