about summary refs log tree commit diff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2024-02-28lib/customization: propagate function arguments in callPackagesWithAndrew Childs2-1/+20
makeOverridable is very careful to ensure the arguments to the overridden function are the same as the input function. As a result, the arguments of hello.override are exactly the same as the original arguments of the hello function that produced the derivation. However, callPackagesWith calls makeOverridable with a lambda that does not propagate the arguments. The override function for a package instantiated with callPackagesWith will not have the original arguments. For example: nix-repl> lib.functionArgs hello.override { callPackage = false; fetchurl = false; hello = false; lib = false; nixos = false; stdenv = false; testers = false; } nix-repl> lib.functionArgs openssl.override { } By copying the arguments onto the inner lambda before passing it to makeOverridable, we can make callPackage and callPackages behave the same. nix-repl> lib.functionArgs openssl.override { buildPackages = false; coreutils = false; cryptodev = false; enableSSL2 = true; enableSSL3 = true; fetchurl = false; lib = false; perl = false; removeReferencesTo = false; static = true; stdenv = false; withCryptodev = true; withPerl = true; }
2024-02-28Merge pull request #291933 from tweag/fileset-tests-posixRobert Hensing1-48/+52
lib.fileset: Fix tests on Darwin, more POSIX
2024-02-27lib.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.
2024-02-27Merge pull request #291909 from cdmistman/lib-meta-available-on-doc-exampleRyan Mulligan1-0/+4
lib.meta.availableOn: add example in documentation
2024-02-27lib.meta.platformMatch: expand documentationColton Donnelly1-0/+4
2024-02-27lib.meta.availableOn: add example in documentationColton Donnelly1-0/+4
2024-02-26lib/tests/release: Test lib.version in isolationRobert Hensing1-0/+6
2024-02-26.version: Make lib/.version source of truthRobert Hensing1-9/+0
This way we don't have to make sure they're in sync, and we remove a small step from the release process.
2024-02-26lib flake: Fix versionRobert Hensing3-1/+11
Manually tested with nix-repl> :lf path:lib nix-repl> lib.version
2024-02-26Merge pull request #288677 from tweag/fileset.toListSilvan Mosberger3-2/+82
lib.fileset.toList: init
2024-02-26Merge pull request #291583 from SuperSandro2000/mergeAttrsListSilvan Mosberger1-2/+2
lib: export attrsets.mergeAttrsList
2024-02-26lib.fileset.toList: initSilvan Mosberger3-2/+82
2024-02-26lib: export attrsets.mergeAttrsListSandro1-2/+2
2024-02-23lib/tests/test-with-nix.nix: initRobert Hensing2-54/+71
See https://github.com/NixOS/nix/pull/9900
2024-02-22Merge pull request #286544 from hercules-ci/doRename-docValentin Gagarin1-1/+72
lib.modules.doRename: Add doc comments
2024-02-18lib.evalModules: Fix deprecation doc for args parameterBenoit de Chezelles1-2/+2
2024-02-14lib.modules.doRename: Add doc commentsRobert Hensing1-1/+72
I don't think these are rendered yet, but this at least provides the content. Follow-up to https://github.com/NixOS/nixpkgs/pull/285612
2024-02-10licenses: add mplush7x41-0/+5
2024-02-10Merge pull request #284512 from hercules-ci/lib-types-unique-mergeSilvan Mosberger4-18/+62
lib.types.unique: Check inner type deeply
2024-02-09Merge pull request #287124 from RaitoBezarius/is-sparc-64Ryan Lahfa1-0/+1
lib/systems/inspect: add `isSparc64`
2024-02-09lib.versions: Remove unneeded polyfillSilvan Mosberger1-1/+1
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
2024-02-09lib.strings: Remove unneeded polyfillSilvan Mosberger1-2/+1
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
2024-02-09lib.lists: Remove unneeded polyfillsSilvan Mosberger1-26/+5
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
2024-02-09lib.attrsets: Remove unneeded polyfillsSilvan Mosberger1-9/+6
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
2024-02-09lib.trivial: Remove unneeded polyfillsSilvan Mosberger2-56/+2
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
2024-02-09Merge pull request #286117 from alois31/lib-deprecationsSilvan Mosberger5-11/+12
lib: make deprecation warnings consistent
2024-02-08lib/systems/inspect: add `isSparc64`Raito Bezarius1-0/+1
This is useful to distinguish between SPARC64 and SPARC whatever, because SPARC64 do support compressed kernels.
2024-02-05Merge pull request #285612 from hercules-ci/doRename-conditionRobert Hensing6-3/+77
lib.modules.doRename: Add condition parameter
2024-02-05Merge pull request #285353 from sternenseemann/nix-2.3-syntaxSilvan Mosberger2-0/+2
treewide: fix parse errors with Nix 2.3 and related problems
2024-02-04lib.option.mergeUniqueOption: Simplify and add warning about merge functionRobert Hensing1-16/+11
The previous code was optimized for the old uniq behavior, which did not call merge. That's changed, so the legacy path is not a hot path anymore, and is not worth any tech debt.
2024-02-04lib.types.uniq: Check inner typeRobert Hensing1-12/+1
We now reuse the `unique` type, which implements this. Keeping the duplication around would be bad at this point.
2024-02-03lib: make deprecation warnings consistentAlois Wohlschlager5-11/+12
The deprecation warnings in lib were wildly inconsistent. Different formulations were used in different places for the same meaning. Some warnings used builtins.trace instead of lib.warn, which prevents silencing; one even only had a comment instead. Make everything more uniform.
2024-02-02Merge branch 'optionalDrvAttr'Shea Levy3-2/+46
2024-02-02lib: Add optionalDrvAttr to conditionally set drv attributes.Shea Levy3-2/+46
This allows for adding new, conditionally set, derivation attributes to an existing derivation without changing any output paths in the case where the condition is not met.
2024-02-02lib.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.
2024-02-02Merge pull request #285301 from ibbem/gitTracked-shallowSilvan Mosberger2-1/+31
lib.fileset.gitTracked: Allow clones of shallow repositories
2024-02-01lib.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>
2024-01-31lib/tests/packages-from-directory: make sure all .nix files parsesternenseemann2-0/+2
It is useful that all (or almost all) .nix files in nixpkgs at least parse since it allows for checking syntax in the repository programmatically without evaluating anything.
2024-01-30Merge pull request #284829 from deemp/masterRobert Hensing3-0/+9
types.nix: fix nonEmptyListOf
2024-01-30feat: add test for nonEmptyListOf submoduleDanila Danko2-0/+8
2024-01-29types.nix: fix nonEmptyListOfDanila Danko1-0/+1
2024-01-29lib/trivial: bump oldestSupportedRelease to 23.11figsoda1-1/+1
2024-01-28lib.types.unique: Check inner type deeplyRobert Hensing4-6/+66
This doesn't change uniq. Why not? - In NixOS it seems that uniq is only used with simple types that are fully checked by t.check. - It exists for much longer and is used more widely. - I believe we should deprecate it, because unique was already better. - unique can be a proving ground.
2024-01-27licenses: add Creative Commons Attribution 2.0Vincenzo Mantova1-0/+5
2024-01-18lib.system.inspect: add wasm32 to isILP32Adam Joseph1-1/+2
According to the WebAssembly design doc, wasm32 is an ILP32 ABI like x32, mips64n32, and aarch64_ilp32 (Apple Watch). This commits adds it to the predicate. https://github.com/WebAssembly/design/blob/1319968ca53fb5c7e7ea6cc210c7b0ed46566a45/CAndC%2B%2B.md?plain=1#L16
2024-01-12Merge pull request #248220 from infinisil/document-extendsSilvan Mosberger1-23/+136
Improve the documentation of `lib.extends` and how it relates to overlays
2024-01-08Merge pull request #278777 from tweag/fix-evalsSilvan Mosberger1-1/+5
`lib.callPackageWith`: Use abort again instead of throw and fix evaluation errors caused by it
2024-01-07lib.callPackageWith: Use abort, not throwSilvan Mosberger1-1/+5
This reverts f8ea911f7c4e44b167d4b1b51f6d00ebd93e1ed1, see also https://github.com/NixOS/nixpkgs/pull/271123#discussion_r1442134594
2024-01-02lib/systems: add exec format inspection attrsRyan Burns1-0/+3
Most of the time when we do a patchelf conditional on hostPlatform.isLinux, what we really mean is hostPlatform.isElf. Now that we are starting to support BSDs, this is becoming more important.
2023-12-30Merge pull request #276271 from ↵Robert Hensing2-3/+31
hercules-ci/modules-types-description-nonRestrictiveClause lib.types: Improve descriptions of composed types that have commas