summaryrefslogtreecommitdiff
path: root/lib/customisation.nix (follow)
Commit message (Expand)AuthorAgeFilesLines
* lib.extendMkDerivation: init•••Add functions extendMkDerivation to lib.customisation. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Lin Jian <me@linj.tech> Co-authored-by: Philip Taron <philip.taron@gmail.com> Yueh-Shun Li2025-01-181-0/+124
* lib.customisation: remove dead code•••Remove unneeded function inheritance in the let-in block. Yueh-Shun Li2024-12-201-2/+0
* lib/customisation.nix: format with nixfmt-rfc-styleYueh-Shun Li2024-12-201-141/+216
* lib/customisation: remove overrideScope'•••Let's follow through on the comment. Wolfgang Walther2024-11-241-4/+0
* just fix markupKazuki Okamoto2024-08-171-1/+1
* doc: migrate lib.customisation to use doc-commentsJohannes Kirschbauer2024-03-221-80/+221
* doc: actually document `lib.customisation.makeScope` (#294194)•••* doc: actually document `lib.customisation.makeScope`Valentin Gagarin2024-03-091-11/+122
* lib/customization: propagate function arguments in callPackagesWith•••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; } Andrew Childs2024-02-281-1/+2
* lib.callPackageWith: Use abort, not throw•••This reverts f8ea911f7c4e44b167d4b1b51f6d00ebd93e1ed1, see also https://github.com/NixOS/nixpkgs/pull/271123#discussion_r1442134594 Silvan Mosberger2024-01-071-1/+5
* lib.callPackageWith: Optimize levenshtein sort•••Probably not significant because of the limits already applied. This is mostly cleanup. Robert Hensing2023-12-081-2/+2
* lib/customisation: fix eval error (attribute "levenshtein" missing)Someone Serge2023-12-031-2/+2
* lib/customisation: fix callPackage error messagesK9002023-12-031-2/+3
* lib.customisation.callPackageWith: use throw, not abortAdam Joseph2023-11-301-1/+3
* lib.customisation: Don't allocate intermediate list for missing argsadisbladis2023-11-271-3/+3
* lib.customisation: Inherit lib/builtins into scope•••It makes the code more readable if we have less nested attrsets being accessed. adisbladis2023-11-271-39/+50
* lib.makeOverridable: simplify function arguments preservation•••Rename temporary variable copyArgs -> mirrorArgs. Use lib.mirrorFunctionArgs to define `mirrorArgs`. Apply mirrorArgs also to the returned function. Yueh-Shun Li2023-11-071-8/+10
* lib.makeScopeWithSplicing': add comments•••I didn't add these arguments, so these comments are from my understading of the arguments. Artturin2023-11-021-0/+17
* lib.overrideDerivation: inter-link the documentation•••Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Yueh-Shun Li2023-10-211-2/+1
* doc: lib.customization: add Type and Example tags•••Add the "Type:" blocks. Move the examples below the descriptions whenever possibles Add "Example:" tags before the examples moved below the descriptions. Yueh-Shun Li2023-10-211-19/+70
* lib.makeOverridable: fix functionArgs on returned functionRobert Hensing2023-10-111-3/+4
* doc: Replace `sha256` with `hash` where appropriatenicoo2023-09-131-1/+1
* makeScopeWithSplicing: fix `makeScopeWithSplicing'` call•••makeScopeWithSplicing: fix comment Artturin2023-08-211-4/+4
* Merge pull request #245957 from amjoseph-nixpkgs/pr/lib/customization/makeSco...Artturi2023-08-201-8/+21
|\
| * lib.customisation: add uncurried form of makeScopeWithSplicing•••Deeply-curried functions are pretty error-prone in untyped languages like Nix. This is a particularly bad case because `top-level/splice.nix` *also* declares a makeScopeWithSplicing, but it takes *two fewer arguments*. Let's add a version that uses attrset-passing form, to provide some minimal level of sanity-checking. This also provides defaults for keep and extra (these are often unneeded by the user). Adam Joseph2023-08-141-8/+21
* | lib.customisation.makeScope: Make `overrideScope` consistent with `makeScopeW...•••Right now converting `makeScope` to `makeScopeWithSplicing` is not transparent to users and requires adding a warning for `overrideScope'` in the set itself. Warning and `overrideScope'` were added in 2018 b9dce11712d2bfc8cd367df5a7f737a5cec1e252 and there should be no users left after 5 years. Artturin2023-08-141-4/+5
|/
* Revert "lib.customisation: uncurry makeScopeWithSplicing"Silvan Mosberger2023-07-281-14/+8
* lib.makeScopeWithSplicing: provide default for keep,extra•••These are often unneeded by the user. Artturin2023-07-281-1/+9
* lib.customisation: uncurry makeScopeWithSplicing•••Deeply-curried functions are pretty error-prone in untyped languages like Nix. This is a particularly bad case because `top-level/splice.nix` *also* declares a makeScopeWithSplicing, but it takes *two fewer arguments*. Let's switch to attrset-passing form, to provide some minimal level of sanity-checking. Adam Joseph2023-07-271-8/+6
* splice.nix: finish nativeDrv,crossDrv removalArtturin2023-06-221-6/+0
* lib/customisation: callPackageWith should abort with errors•••ofborg relies on the behavior that existed prior to 1c00bf394867b07ed7a908408d8bc1d0afd9fa49, where evaluation would immediately abort due to a missing argument (whether it be an aliased package when `allowAliases = false;` or a typo'd or otherwise nonexistent package). If `callPackageWith` `throw`s instead of `abort`s, the following `nix-env` invocation does not fail fast but instead silently skips the attribute (assuming there is a package that has an aliased package in its `autoArgs`): $ nix-env -qa --json --file . --arg config '{ allowAliases = false; }' &>/dev/null $ echo $? 0 This does change the error output when there is a missing package (for any of the reasons mentioned above), though. Before this change, the errors looked like this: $ nix-build -A hello --arg config '{ allowAliases = false; }' error: … while calling the 'throw' builtin at /home/vin/workspace/vcs/nixpkgs/master/lib/customisation.nix:179:65: 178| 179| in if missingArgs == [] then makeOverridable f allArgs else throw error; | ^ 180| error: Function called without required argument "bash_5" at /home/vin/workspace/vcs/nixpkgs/master/pkgs/applications/misc/hello/default.nix:8, did you mean "bash" or "bashdb"? And the errors now look like this: $ nix-build -A hello --arg config '{ allowAliases = false; }' error: … while calling the 'abort' builtin at /home/vin/workspace/vcs/nixpkgs/master/lib/customisation.nix:179:65: 178| 179| in if missingArgs == [] then makeOverridable f allArgs else abort error; | ^ 180| error: evaluation aborted with the following error message: 'Function called without required argument "bash_5" at /home/vin/workspace/vcs/nixpkgs/master/pkgs/applications/misc/hello/default.nix:8, did you mean "bash" or "bashdb"?' Cole Helbling2023-03-241-1/+1
* Merge pull request #211685 from Artturin/splicingstuff1-splitArtturi2023-02-031-1/+8
|\
| * lib.extendDerivation: Fix interaction between output selection and overrideAttrsRobert Hensing2023-01-201-1/+8
* | lib.hydraJob: Tolerate null•••By allowing null, we allow code to avoid filterAttrs, improving laziness in real world use cases. Specifically, this strategy prevents infinite recursion errors, performance issues and possibly other errors that are unrelated to the user's code. Robert Hensing2023-01-301-1/+2
|/
* lib: Fix mismatched quotes in `lib.*` doc comments•••caused problems for automated rich text generation such as https://teu5us.github.io/nix-lib.html#customisation-functions YoshiRulz2023-01-021-11/+11
* lib/customisation.overrideDerivation: propagate evaluation condition•••The new derivation should evaluate only if the old derivation does. Sadly this means that the old derivation cannot depend on the new one any more, which was used by xorgserver on Darwin. But this is not a problem as `overrideAttrs` can (and should) usually be used instead. This change allowed catching an invalid `meta.platforms` in the linux_rpi kernels, which use `overrideDerivation`. Naïm Favier2023-01-011-1/+9
* splice.nix: start deprecating nativeDrv and crossDrvArtturin2022-11-191-0/+1
* lib.overrideDerivation: override attrs in __splicedArtturin2022-11-181-6/+8
* lib/customization: Improve callPackage error message for missing args•••This uses the levenshtein distance to look through all possible arguments to find ones that are close to what was requested: error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix called without required argument "fetchFromGithub", did you mean "fetchFromGitHub" or "fetchFromGitLab"? With https://github.com/NixOS/nix/pull/3468 (in current nixUnstable) the error message becomes even better, adding line location info Silvan Mosberger2022-04-011-2/+49
* lib: make extendDerivation lighter on eval•••the fix to extendDerivation in #140051 unwittingly worsened eval performance by quite a bit. set elements alone needed over 1GB extra after the change, which seems disproportionate to how small it was. if we flip the logic used to determine which outputs to install around and keep a "this one exactly" flag in the specific outputs instead of a "all of them" in the root we can avoid most of that cost. pennae2021-10-151-3/+2
* fix nested calls to extendDerivation•••if extendDerivation is called on something that already had extendDerivation called on it (eg a mkDerivation result) the second call will set outputUnspecified=true on every output by way of propagating attributes of the full derivation to the individual outputs. this in turn causes buildEnv--and thus nix-shell and environment.systemPackages--to install every output of such a derivation even when only a specific output was requested, which renders the point of multiple outputs moot. this happens in python modules (see #139756), though it seems that tcl and possibly others should also be affected. pennae2021-09-301-1/+2
* treewide: Do a number of no-op cleanups for cross and darwin•••I am taking the non-invasive parts of #110914 to hopefully help out with #111988. In particular: - Use `lib.makeScopeWithSplicing` to make the `darwin` package set have a proper `callPackage`. - Adjust Darwin `stdenv`'s overlays keeping things from the previous stage to not stick around too much. - Expose `binutilsNoLibc` / `darwin.binutilsNoLibc` to hopefully get us closer to a unified LLVM and GCC bootstrap. John Ericson2021-05-061-3/+5
* lib: Create `makeScopeWithSplicing`•••It's ugly as hell, but I suppose it is needed to codify how to make spliced package sets. John Ericson2020-11-191-0/+27
* lib.callPackages(With): guard against a repeated mistake•••For example see the parent commit. Vladimír Čunát2020-03-121-1/+6
* Merge pull request #67809 from Infinisil/propagate-override-args•••lib.makeOverridable: Propagate function argumentsSilvan Mosberger2019-10-221-14/+23
|\
| * lib/makeOverridable: Refactor•••- Rename ff to result because that's what it is - Better indentation - Less parens - Comment what overrideWith does Silvan Mosberger2019-09-051-11/+14
| * lib/makeOverridable: Remove unimplemented overrideDerivation for functions•••- Apparently nobody ever needed this - We already have enough ways to override things - Using overrideDerivation is discouraged Silvan Mosberger2019-09-051-1/+0
| * lib/makeOverridable: Propagate function args of the callPackage'd function•••This allows querying function arguments of things like fetchFromGitHub: nix-repl> lib.functionArgs pkgs.fetchFromGitHub { fetchSubmodules = true; githubBase = true; ... } Silvan Mosberger2019-09-051-5/+6
| * lib/makeOverridable: Propagate function arguments to override functions•••This allows querying the arguments you can .override: nix-repl> lib.functionArgs pkgs.hello.override { fetchurl = false; stdenv = false; } Silvan Mosberger2019-09-051-2/+4
| * lib/makeOverridable: Abstract result overridingSilvan Mosberger2019-09-051-3/+4
| * lib/makeOverridable: Deduplicate override definition•••And call it overrideArgs in the let binding because that's what it does Silvan Mosberger2019-09-051-2/+5