about summary refs log tree commit diff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2024-05-27licenses: Add NCBI-PDGavin John1-0/+11
(cherry picked from commit 361874c944599d40faf1e810a287b3c1d4d29610)
2024-05-18types.attrTag: Remove unnecessary definitions override Robert Hensing1-1/+0
Committing because tests pass. Co-authored-by: Silvan Mosberger <github@infinisil.com>
2024-05-18lib.types.attrTag: Fix declarationPositions after mergeRobert Hensing2-4/+18
2024-05-18lib/tests/modules/types-attrTag.nix: Test other option doc attrsRobert Hensing1-0/+9
2024-05-18lib/tests/modules/types-attrTag.nix: Clean up unneeded commentRobert Hensing1-1/+0
2024-05-18types.attrTag: Remove substSubmodulesRobert Hensing1-9/+0
I haven't managed to trigger the error, and it turns out that this method is optional. Specifically, getSubmodules is unimplemented (and unimplementable), the tests pass, and we seem to have good location info.
2024-05-18types.attrTagWith: removeRobert Hensing2-11/+19
Keep it simple for now.
2024-05-18lib.types.attrTag: Custom error when passing bare typeRobert Hensing3-1/+23
2024-05-18lib/tests/modules/types-attrTag: Test against unexpected attrsRobert Hensing1-6/+6
Thank you lheckemann for pointing this out!
2024-05-18lib.types.attrTag: Remove tags from descriptionRobert Hensing2-7/+8
You can find them in the sub-options now.
2024-05-18lib.modules.evalOptionValue: Undeprecate for lib.typesRobert Hensing2-2/+3
lib.types.attrTag needs it.
2024-05-18lib.types.attrTag: Provide declarations, definitionsRobert Hensing2-2/+20
2024-05-18lib/types.nix: Fix getSubOptions docRobert Hensing1-1/+1
This comment was added in 73f32d03758a5, when it was already supposed to be an attrset.
2024-05-18lib.types.attrTag: Support type mergingRobert Hensing2-1/+32
2024-05-18lib.types.attrTag: Take options instead of typesRobert Hensing2-21/+55
2024-05-18lib.types.attrTag: Support module docsRobert Hensing3-1/+65
2024-05-18lib.types.attrTag: initRobert Hensing3-0/+112
2024-02-28lib.fileset: Fix tests on Darwin, more POSIXSilvan Mosberger1-48/+52
This was found when trying to run the fileset tests on Darwin (https://github.com/NixOS/nix/pull/9546#issuecomment-1967409445), which mysteriously fail on Darwin: test case at lib/fileset/tests.sh:342 failed: toSource { root = "/nix/store/foobar"; fileset = ./.; } should have errored with this regex pattern: lib.fileset.toSource: `root` \(/nix/store/foobar\) is a string-like value, but it should be a path instead. \s*Paths in strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead. but this was the actual error: error: lib.fileset.toSource: `root` (/nix/store/foobar) is a string-like value, but it should be a path instead. Paths in strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead. After dissecting this, I find out that apparently \s works on Linux, but not on Darwin for some reason! From the bash source code, it looks like <regex.h> with `REG_EXTENDED` is used for all platforms the same, so there's nothing odd there. It's almost impossible to know where <regex.h> comes from, but it looks to be a POSIX thing. So after digging through the almost impossible to find POSIX specifications (https://pubs.opengroup.org/onlinepubs/007908799/xbd/re.html#tag_007_003_005), I can indeed confirm that there's no mention of \s or the like! _However_, there is a mention of `[[:blank:]]`, so we'll use that instead. (cherry picked from commit 34295941145b2df1b6c3a9b36c50ad2982227b2f)
2024-02-26lib.fileset.toList: initSilvan Mosberger3-2/+82
(cherry picked from commit e3a6e380337820d17c154c54eaf50ab95bba5c0d)
2024-02-05lib.modules.doRename: Add condition parameterRobert Hensing6-3/+77
This is to support single-to-multi service migrations, so that the `to` (e.g. `foos.""`) isn't defined unconditionally. See test cases. (cherry picked from commit 29c7665003cdcfe3319c969a9846f594dfeae550)
2024-02-02lib.fileset.gitTracked: Allow clones of shallow repositoriesibbem2-1/+31
The only reason shallow clones are not the default in `builtins.fetchGit` is that `revCount` can't be provided when cloning a shallow repository. However, `revCount` isn't used or exposed by `lib.fileset`. Hence, allowing cloning shallow repositories makes `gitTracked` more general without any drawbacks. Co-authored-by: Silvan Mosberger <github@infinisil.com> (cherry picked from commit 6558e891777932e8066080e89bdc773e6127e1e7)
2023-12-20Merge staging-next-23.11 into staging-23.11github-actions[bot]3-57/+125
2023-12-19Remove --simulate-pure-evalSilvan Mosberger1-36/+18
(cherry picked from commit 38cf6ff099856e19f83649fcdbc98b5bde58eaca)
2023-12-19lib.fileset.gitTracked: Support out-of-tree buildsSilvan Mosberger3-6/+86
(cherry picked from commit 4a70c1e4da8bd66fe27885d1fba54ffee775e3da)
2023-12-19lib.fileset.fetchGit: RefactoringSilvan Mosberger1-18/+24
(cherry picked from commit 74f2e495436983b9b3d8c9a94a638bb411cfb245)
2023-12-19lib: `modules.sh` should check JSON output for predictabilityRebecca Turner4-17/+24
Currently, the `lib/tests/modules.sh` test checks the output of `nix-instantiate --eval` without `--json`, which outputs an unspecified human-readable format. This patch modifies `modules.sh` to use the `--json` output instead, to be robust against future changes to `nix-instantiate` output.
2023-12-13lib.path.hasStorePathPrefix: initSilvan Mosberger2-1/+110
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> (cherry picked from commit d4b7b154072635827dcd473131273e1a8bc54097)
2023-12-13lib.fileset.gitTracked: Improve error when passing filesSilvan Mosberger2-0/+8
(cherry picked from commit 6e3be6ddb0c9789d8b891318c526a9401dab481e)
2023-12-13lib.fileset: Refactor gitTracked and gitTrackedWithSilvan Mosberger2-41/+48
Introduce an internal function for them to share more behavior. This makes future changes easier. (cherry picked from commit eec765f9e6a862c82990df8d3ceedf51f4600330)
2023-12-11lib.attrsets.hasAttrByPath: Document law and laziness, and test itRobert Hensing2-0/+12
(cherry picked from commit 7d993b9521aa8a229648a1c33e730df8b630670f)
2023-12-11lib.attrsets.longestValidPathPrefix: initRobert Hensing2-0/+105
Allows finding the most specific path that exists. This is useful for error messages relating to attribute paths. (cherry picked from commit 72bd4bbb58f6867a00af2a0ddaae2d601c1ee2c7)
2023-12-10lib.types.boolByOr: initSilvan Mosberger3-0/+36
This type is necessary to have correct merging behavior for `allowUnfreePredicate` and `allowInsecurePredicate` Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> (cherry picked from commit 8d3978c149352de6b7e8b72946b58a16427eda2c)
2023-12-09lib.sort: Make doc consistent with sortOnRobert Hensing1-1/+4
(cherry picked from commit 50793752a71b35bc0dab203db7d6ad18281e2e1e)
2023-12-09lib.callPackageWith: Optimize levenshtein sortRobert Hensing1-1/+1
Probably not significant because of the limits already applied. This is mostly cleanup. (cherry picked from commit 016993237f083abba26f436eb201ac35ecc3ebd3)
2023-12-09lib.sortOn: initRobert Hensing3-1/+63
A more efficient sort in some cases, and often convenient. This exposes `lib.lists.sortOn` immediately on `lib`, because it is a sibling of `sort`, which is already present there. Omitting it would lead to more confusion, and worse outcomes. There's no confusion about the types `sort` or `sortOn` operate on. Haskell agrees about the type for `sortOn`, and it is in its `base`. (cherry picked from commit 67cc78643d7307b7a4cd783e43c53346fdea18bf)
2023-12-03lib.systems.elaborate: fix passing `rust` (more) (#271790)github-actions[bot]1-1/+2
An important idea around the rust stuff in lib.systems is that it's elaborated — this means that it should idempotently add to the values passed in, if any. But we missed that the names used for the parameter and the elaborated value for "rustcTarget"/"config" didn't line up. The intention was to use "rustcTarget" everywhere in the new interface, as a more descriptive name than "config". This fixes setting the system in NixOS configuration, which results in an already elaborated system being elaborated again. Before, this wouldn't produce the correct result: % nix-instantiate --eval -A stdenv.hostPlatform.rust.rustcTarget --system armv7l-linux "armv7-unknown-linux-gnueabihf" % NIX_PATH= nix-instantiate --eval -E '(import nixos/lib/eval-config.nix { system = "armv7l-linux"; modules = []; }).pkgs.stdenv.hostPlatform.rust.rustcTarget' "arm-unknown-linux-gnueabihf" Fixes: e3e57b8f1885 ("lib.systems: elaborate Rust metadata") Fixes: https://github.com/NixOS/nixpkgs/issues/271000 (cherry picked from commit 4d23987f4af94610ab0b76adc9d982a038eb345c) Co-authored-by: Alyssa Ross <hi@alyssa.is>
2023-11-27lib.attrsets.matchAttrs: Avoid some list allocations when walking structureadisbladis2-9/+40
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 } } ``` (cherry picked from commit 013a0a1357c446d0a46b4bbd8f68512fd9223257)
2023-11-26lib.meta: Avoid attrset allocation in platformMatchadisbladis2-10/+42
Benchmarks (`nix-instantiate ./. -A python3`) - Before ``` json { "cpuTime": 0.30625399947166443, "envs": { "bytes": 4484216, "elements": 221443, "number": 169542 }, "gc": { "heapSize": 402915328, "totalBytes": 53091024 }, "list": { "bytes": 749424, "concats": 4242, "elements": 93678 }, "nrAvoided": 253991, "nrFunctionCalls": 149848, "nrLookups": 49614, "nrOpUpdateValuesCopied": 1588326, "nrOpUpdates": 10106, "nrPrimOpCalls": 130356, "nrThunks": 359013, "sets": { "bytes": 30432320, "elements": 1860540, "number": 41480 }, "sizes": { "Attr": 16, "Bindings": 16, "Env": 16, "Value": 24 }, "symbols": { "bytes": 236218, "number": 24459 }, "values": { "bytes": 10504632, "number": 437693 } } ``` - After ``` { "cpuTime": 0.29695799946784973, "envs": { "bytes": 3296712, "elements": 169055, "number": 121517 }, "gc": { "heapSize": 402915328, "totalBytes": 49044992 }, "list": { "bytes": 504928, "concats": 4242, "elements": 63116 }, "nrAvoided": 175403, "nrFunctionCalls": 110554, "nrLookups": 44907, "nrOpUpdateValuesCopied": 1588326, "nrOpUpdates": 10106, "nrPrimOpCalls": 82330, "nrThunks": 306625, "sets": { "bytes": 29943328, "elements": 1843076, "number": 28382 }, "sizes": { "Attr": 16, "Bindings": 16, "Env": 16, "Value": 24 }, "symbols": { "bytes": 236218, "number": 24459 }, "values": { "bytes": 9037752, "number": 376573 } } ``` (cherry picked from commit 4b4d4138177fd467cd8e726470824afac6ad3df5)
2023-11-24lib.systems.elaborate: fix passing `rust`Alyssa Ross1-92/+92
Usually, attributes passed explicitly to elaborate take precedence over the elaborated ones, but since we also elaborate the nested "rust" attrset, we need to push that one level down, so the rest of "rust" is still filled in if you just pass { rust = { config = ... } }. I've had to drop the assertion that checked that at most one of "rust" and "rustc" was part of the un-elaborated system, because doing this broke passing an elaborated system in, which should be idempotent. For the same reason, I've also had to make it possible for rust.rustcTargetSpec to be passed in. Otherwise, on the second call, since platform was filled in by the first, the custom target file would be constructed. The only other way to avoid this would be to compare the platform attrs to all built in Rust targets to check it wasn't one of those, and that isn't feasible. Fixes: e3e57b8f1885 ("lib.systems: elaborate Rust metadata") (cherry picked from commit 886c89287f6a35adb6eb9230a3a0cccf682d0f88)
2023-11-23lib.fileset.fileFilter: Predicate attribute for file extensionSilvan Mosberger3-3/+46
(cherry picked from commit 6816f28c960c523e6a30f2ad4a1cc812251f5ffb)
2023-11-22lib.fileset: Document decision for strict existence checksSilvan Mosberger1-0/+13
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> (cherry picked from commit 827232d6dd2b7787749afdfef614fbea8d88ebe9)
2023-11-22lib.fileset.maybeMissing: initSilvan Mosberger4-7/+69
(cherry picked from commit 1cc2c2f13d7a548759a55f710fd0222da14c5403)
2023-11-20Merge pull request #268619 from tweag/lib-descriptionsSilvan Mosberger7-17/+20
lib: Take advantage of section descriptions
2023-11-20lib: Take advantage of section descriptionsSilvan Mosberger7-17/+20
See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0
2023-11-19lib.fileset: Re-order to match reference overviewSilvan Mosberger1-200/+200
2023-11-19lib.fileset: Add overview section to reference docsSilvan Mosberger1-2/+44
2023-11-19Merge pull request #268520 from tweag/fileset-minor-changesSilvan Mosberger3-6/+11
`lib.fileset`: Minor changes
2023-11-19lib.fileset: Minor changesSilvan Mosberger3-6/+11
- Make fromSource's missing file error message more consistent with others, and add a test for it - Indent some function arguments - Fix an internal type
2023-11-19lib.fileset: Move introduction section above the functionsSilvan Mosberger1-0/+49
Previously the introductory section and the function listings were in different places. But now nixdoc supports having them together with https://github.com/nix-community/nixdoc/pull/70!
2023-11-19Merge pull request #266443 from amjoseph-nixpkgs/pr/lib-tests-no-aws-sdkSilvan Mosberger3-5/+26