From 39b64b52ed349bb7b6f26f50013335d76d1605f6 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Fri, 19 Aug 2016 22:21:32 -0400 Subject: mkDerivation: add overrideAttrs function This is similar to `overrideDerivation`, but overrides the arguments to `mkDerivation` instead of the underlying `derivation` call. Also update `makeOverridable` so that uses of `overrideAttrs` can be followed by `override` and `overrideDerivation`, i.e. they can be mix-and-matched. --- doc/functions.xml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'doc') diff --git a/doc/functions.xml b/doc/functions.xml index 908e9571ed6..f5fb90921bf 100644 --- a/doc/functions.xml +++ b/doc/functions.xml @@ -85,9 +85,70 @@ in ... +
+ <pkg>.overrideAttrs + + + The function overrideAttrs allows overriding the + attribute set passed to a stdenv.mkDerivation call, + producing a new derivation based on the original one. + This function is available on all derivations produced by the + stdenv.mkDerivation function, which is most packages + in the nixpkgs expression pkgs. + + + + Example usage: + + helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec { + separateDebugInfo = true; +}); + + + + In the above example, the separateDebugInfo attribute is + overriden to be true, thus building debug info for + helloWithDebug, while all other attributes will be + retained from the original hello package. + + + + The argument oldAttrs is conventionally used to refer to + the attr set originally passed to stdenv.mkDerivation. + + + + + Note that separateDebugInfo is processed only by the + stdenv.mkDerivation function, not the generated, raw + Nix derivation. Thus, using overrideDerivation will + not work in this case, as it overrides only the attributes of the final + derivation. It is for this reason that overrideAttrs + should be preferred in (almost) all cases to + overrideDerivation, i.e. to allow using + sdenv.mkDerivation to process input arguments, as well + as the fact that it is easier to use (you can use the same attribute + names you see in your Nix code, instead of the ones generated (e.g. + buildInputs vs nativeBuildInputs, + and involves less typing. + + + +
+ +
<pkg>.overrideDerivation + + You should prefer overrideAttrs in almost all + cases, see its documentation for the reasons why. + overrideDerivation is not deprecated and will continue + to work, but is less nice to use and does not have as many abilities as + overrideAttrs. + + + Do not use this function in Nixpkgs as it evaluates a Derivation before modifying it, which breaks package abstraction and removes -- cgit 1.4.1