Michael Daniels
eddcb5f228
lib/tests/release: stop testing nix_2_28
...
See 7d940ca082 and #538699 .
Not-cherry-picked-because: already done on master
2026-07-05 11:56:41 -04:00
zimbatm
8b870d7666
lib.sources.sourceByGlobs: address review comments
...
(cherry picked from commit 01bdc186ae )
2026-07-04 06:49:08 +00:00
adisbladis
96d5ebc8c2
lib.sources.sourceByGlobs: init function
...
Adds a source filtering function inspired by [doublestar](https://github.com/bmatcuk/doublestar ).
This has been in used in a few private repositories since the last ~6 months with success.
- Testing
This was originally tested with the nix-unit testsuite:
```
let
inherit (import ./internal.nix) mkSourceFilter mkMatcher;
in
{
mkMatcher = {
empty = {
testMatch = {
expr = mkMatcher "" "" "regular";
expected = true;
};
testNoMatch = {
expr = mkMatcher "" "foo" "regular";
expected = false;
};
};
simple = {
testMatch = {
expr = mkMatcher "foo" "foo" "regular";
expected = true;
};
testNoMatch = {
expr = mkMatcher "foo" "bar" "regular";
expected = false;
};
};
singleStar = {
testMatch = {
expr = mkMatcher "*.js" "foo.js" "regular";
expected = true;
};
testNoMatch = {
expr = mkMatcher "*.js" "foo.py" "regular";
expected = false;
};
};
doubleStar = {
testMatch = {
expr = mkMatcher "foo/**/bar" "foo/baz/bar" "regular";
expected = true;
};
testNoMatch = {
expr = mkMatcher "foo/**/bar" "foo/bar/baz" "regular";
expected = false;
};
testMultiMatch = {
expr = mkMatcher "foo/**/bar" "foo/baz/xyz/bar" "regular";
expected = true;
};
testMultiMatchDoubleGlob = {
expr = mkMatcher "foo/**/**/bar" "foo/baz/xyz/bar" "regular";
expected = true;
};
testInfixMatch = {
expr = mkMatcher "foo/**/qux/**/bar" "foo/baz/qux/baz/bar" "regular";
expected = true;
};
testInfixNoMatch = {
expr = mkMatcher "foo/**/xyz/**/bar" "foo/baz/qux/baz/bar" "regular";
expected = false;
};
# Technically a partial match
testInfixDirMatch = {
expr = mkMatcher "foo/**/xyz/**/bar" "foo/baz/qux/baz/bar" "directory";
expected = true;
};
};
};
mkSourceFilter = {
testSourceFilter = {
expr = mkSourceFilter ./fixtures [
"bar/*.js"
] "bar/bar.js" "regular";
expected = true;
};
};
}
```
but it was dropped in this nixpkgs contribution as the structure of nixpkgs lib testing is too primitive to incorp this without more extensive refactoring than I'd like at the momment.
- Performance
It's hard to benchmark this against anything else meaningful except [globsset](https://github.com/pdtpartners/globset ), which has a very similar API.
`sourceByGlobs` avoids performance pitfalls by:
- Using `builtins.filterSource`
This is more performant than the fileset API.
The downside compared to the fileset API is that any directory which matches the filter will be added to the build, even if it's empty.
- Match paths component by component
By splitting each pattern into a token per / separator.
This is much faster in Nix than the doublestar algorithm.
- Globset source
```json
{
"cpuTime": 0.8585879802703857,
"envs": {
"bytes": 148252864,
"elements": 11899843,
"number": 6631765
},
"gc": {
"heapSize": 402915328,
"totalBytes": 671288560
},
"list": {
"bytes": 3358664,
"concats": 28658,
"elements": 419833
},
"nrAvoided": 11562713,
"nrFunctionCalls": 4816963,
"nrLookups": 4316209,
"nrOpUpdateValuesCopied": 5686407,
"nrOpUpdates": 464060,
"nrPrimOpCalls": 2966970,
"nrThunks": 7796186 ,
"sets": {
"bytes": 196404672,
"elements": 10837802,
"number": 1437490
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 8,
"Value": 24
},
"symbols": {
"bytes": 340652,
"number": 32026
},
"values": {
"bytes": 207367440,
"number": 8640310
}
}
```
- Glob-filter source
```json
{
"cpuTime": 0.3904629945755005,
"envs": {
"bytes": 13263440,
"elements": 1005877,
"number": 652053
},
"gc": {
"heapSize": 402915328,
"totalBytes": 146914896
},
"list": {
"bytes": 3032168,
"concats": 5899,
"elements": 379021
},
"nrAvoided": 1666598,
"nrFunctionCalls": 484399,
"nrLookups": 112698,
"nrOpUpdateValuesCopied": 3432135,
"nrOpUpdates": 13426,
"nrPrimOpCalls": 1041954,
"nrThunks": 1205792,
"sets": {
"bytes": 64304800,
"elements": 3978167,
"number": 40883
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 8,
"Value": 24
},
"symbols": {
"bytes": 285306,
"number": 28864
},
"values": {
"bytes": 42963240,
"number": 1790135
}
}
```
(cherry picked from commit 59d55cbaa3 )
2026-07-04 06:49:08 +00:00
d18g
0362e1f2d1
lib.types: types.attrTag declaration info
...
Closes #303082
(cherry picked from commit 495906d50a )
2026-07-02 14:10:29 +01:00
Eman Resu
23b3177402
lib.attrsets.concatMapAttrs: add test for handling duplicates
...
(cherry picked from commit f3e6fa555f )
2026-06-23 15:27:13 +00:00
Eman Resu
aed9f7b95d
lib.attrsets.concatMapAttrs: rewrite for efficiency
...
(cherry picked from commit 1c53d25f58 )
2026-06-23 15:27:12 +00: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
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
bb71feaec1
lib.functionArgs: save a function call on every lookup
2026-05-14 19:29:25 -04:00
Eman Resu
77334757d7
lib.isFunction: save an attribute lookup
2026-05-14 19:28:43 -04:00
Johannes Kirschbauer
0bb05b5bd0
lib/modules: document limitations of 'mkRenamedOptionModule' ( #470160 )
2026-05-14 13:35:43 +00:00
toonn
1aa1947487
lib.types: Fix biggest/smallest supported int comment
2026-05-13 18:44:05 +02:00
Johannes Kirschbauer
e8f89b3417
lib.types: small performance improvements ( #517843 )
2026-05-13 14:21:26 +00:00
Emily
036199b38a
lib.systems.equals: only filter functions once ( #513844 )
2026-05-13 00:56:58 +00:00
Eman Resu
db9c713393
lib.types: move variable to its usage, don't check condition twice
...
The only place `merged` is used already checks if `coercedType.merge ?
v2`, so we don't need to check it again. We can also avoid creating the
variable if coercedTypes.merge doesn't have a v2 attribute.
2026-05-12 11:23:18 -04:00
Eman Resu
9b693534b4
lib.types: inline tail binding
2026-05-12 11:23:16 -04:00
Eman Resu
51a39dc768
lib.types: use head foo instead of elemAt foo 0
2026-05-12 11:23:14 -04:00
Eman Resu
89effed623
lib.types: reuse args in v2 merge functions
2026-05-12 11:23:05 -04:00
Eman Resu
1f94af932c
lib.types: add variables to global scope
2026-05-12 11:23:04 -04:00
Eman Resu
5616d07fe0
lib/types: filter for nulls instead of counting them
2026-05-12 11:22:36 -04:00
Eman Resu
ea872088f3
lib/types: only filter if we're actually getting an error
2026-05-12 11:22:33 -04:00
Eman Resu
cc86a8faa0
lib.types: inherit builtins into scope
2026-05-12 11:22:25 -04:00
Eman Resu
6c84f96a96
lib.types: inherit builtins to global scope
2026-05-12 11:22:24 -04:00