about summary refs log tree commit diff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-12-11lib.isConvertibleToString: Statically compute types listadisbladis1-2/+4
2023-12-11lib.toHexString: Statically compute hexDigits attrsetadisbladis1-16/+14
2023-12-11lib.pipe: Avoid creating scopesadisbladis1-3/+1
2023-12-11lib.strings: Dont create scopes for getName/getVersionadisbladis1-12/+12
We can create the `parse` function in a scope one level up to avoid recomputing it every time.
2023-12-10Merge pull request #272709 from hercules-ci/module-system-test-pr-131205Maximilian Bosch4-0/+36
lib/modules: Test optionless module errors from #131205
2023-12-10flake/version overlay: review fixesMaximilian Bosch3-19/+22
* Improves the comments of `lib/flake-version-info.nix` and drops the `__`-prefix from the filename. * `lib'` -> `lib0` in `nixpkgs/lib`. * Drop the declaration of `trivial.version` in the overlay because this declaration already uses the final expressions of `versionSuffix` and `release` now. * No need to fall back to `self.lastModified` anymore, this was a workaround for pre2.4 Nix. Co-authored-by: Robert Hensing <robert@roberthensing.nl> Co-authored-by: Silvan Mosberger <contact@infinisil.com>
2023-12-10lib/trivial: drop `rec` in favor of `lib` fixpointMaximilian Bosch1-2/+14
That way each expression uses the final version of other lib.trivial declarations. For instance, when replacing `versionSuffix` with the string `"fnord"` in a lib overlay, `trivial.version` uses `"fnord"` as suffix now rather than `pre-git`.
2023-12-10Merge pull request #272183 from infinisil/nixpkgs-referenceRobert Hensing1-1/+1
doc: Rename to Nixpkgs reference manual and restate purpose
2023-12-10Merge pull request #272764 from tweag/anyBoolRobert Hensing3-0/+36
lib.types.anyBool: init
2023-12-09lib/modules: Clarify test assertionsRobert Hensing1-0/+3
2023-12-09lib/modules: Test optionless module errors from #131205Robert Hensing4-0/+33
2023-12-09flake: also provide proper version info for lib's flakeMaximilian Bosch2-1/+23
This effectively means that nixpkgs$ nix eval ./lib#lib.trivial.version "23.11.20231020.ee0d6b5" now gives meaningful results as well. See https://github.com/NixOS/nixpkgs/pull/257100#discussion_r1352075369 for the discussion around this.
2023-12-08lib.attrsets.hasAttrByPath: Document law and laziness, and test itRobert Hensing2-0/+12
2023-12-08lib.attrsets.longestValidPathPrefix: initRobert Hensing2-0/+105
Allows finding the most specific path that exists. This is useful for error messages relating to attribute paths.
2023-12-08lib.sort: Make doc consistent with sortOnRobert Hensing1-1/+4
2023-12-08lib.callPackageWith: Optimize levenshtein sortRobert Hensing1-2/+2
Probably not significant because of the limits already applied. This is mostly cleanup.
2023-12-08lib.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`.
2023-12-08lib.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>
2023-12-08doc: Rename to Nixpkgs reference manual and state purposeSilvan Mosberger1-1/+1
For the time being, we're moving towards https://nix.dev/ containing all tutorials and guides. The Nixpkgs manual is reinforced to be a _reference_ manual. While it's not just reference for now, that's what the docs team is working towards. This commits rewrites the Nixpkgs manual introduction to reflect that and point to some more useful links. The contribution docs are updated similarly so it's not missed. Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-12-05lib: Add contribution guidelinesSilvan Mosberger1-0/+63
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2023-12-03lib.systems.elaborate: add libDir attributeJeff Huffman1-0/+7
2023-12-03lib/customisation: fix eval error (attribute "levenshtein" missing)Someone Serge1-2/+2
2023-12-03lib.systems.elaborate: fix passing `rust` (more) (#271707)Alyssa Ross1-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
2023-12-03lib/customisation: fix callPackage error messagesK9001-2/+3
2023-12-02sudo: fix meta license information (#269788)Pierre Bourdon1-0/+6
2023-11-30lib.customisation.callPackageWith: use throw, not abortAdam Joseph1-1/+3
2023-11-27Merge pull request #270299 from adisbladis/lib-customisation-allocsSilvan Mosberger1-40/+51
lib.customisation: Refactor nested set access & avoid some allocations
2023-11-27Merge pull request #269552 from adisbladis/lib-matchattrs-list-allocsRobert Hensing2-9/+40
lib.attrsets.matchAttrs: Avoid some list allocations when walking structure
2023-11-27lib.customisation: Don't allocate intermediate list for missing argsadisbladis1-3/+3
2023-11-27lib.customisation: Inherit lib/builtins into scopeadisbladis1-39/+50
It makes the code more readable if we have less nested attrsets being accessed.
2023-11-27lib.attrsets.attrByPath: Don't allocate one extra list per lookup recursionadisbladis1-11/+21
Using `tail` in a recursive loop like this needlessly allocates. This changes the loop to look up by list index instead.
2023-11-27lib.attrsets.hasAttrByPath: Don't allocate one extra list per lookup recursionadisbladis1-6/+10
Using `tail` in a recursive loop like this needlessly allocates. This changes the loop to look up by list index instead.
2023-11-26Merge pull request #269637 from adisbladis/lib-meta-avoid-alloc-platformmatchSilvan Mosberger2-10/+42
lib.meta: Avoid attrset allocation in platformMatch
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 } } ```
2023-11-26acc: init at 1.60Emily Trau1-0/+7
2023-11-25lib.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 } } ```
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")
2023-11-24Merge pull request #266362 from tweag/fileset.fileFilter-extSilvan Mosberger3-3/+46
`lib.fileset.fileFilter`: Predicate attribute for file extension
2023-11-23lib.fileset.fileFilter: Predicate attribute for file extensionSilvan Mosberger3-3/+46
2023-11-22Merge pull request #265964 from tweag/fileset.optionalSilvan Mosberger4-6/+81
`lib.fileset.maybeMissing`: init
2023-11-22lib.fileset: Document decision for strict existence checksSilvan Mosberger1-0/+13
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-11-2124.05 is Uakari 24.05-prefigsoda1-1/+1
2023-11-20lib.fileset.maybeMissing: initSilvan Mosberger4-7/+69
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!