diff --git a/doc/functions.xml b/doc/functions.xml index 73b178b061f..908e9571ed6 100644 --- a/doc/functions.xml +++ b/doc/functions.xml @@ -89,27 +89,27 @@ in ... <pkg>.overrideDerivation - Do not use this function in Nixpkgs. Because it breaks - package abstraction and doesn’t provide error checking for - function arguments, it is only intended for ad-hoc customisation - (such as in ~/.nixpkgs/config.nix). - - - - Additionally, overrideDerivation forces an evaluation - of the Derivation which can be quite a performance penalty if there are many - overrides used. + Do not use this function in Nixpkgs as it evaluates a Derivation + before modifying it, which breaks package abstraction and removes + error-checking of function arguments. In addition, this + evaluation-per-function application incurs a performance penalty, + which can become a problem if many overrides are used. + It is only intended for ad-hoc customisation, such as in + ~/.nixpkgs/config.nix. - The function overrideDerivation is usually available for all the - derivations in the nixpkgs expression (pkgs). + The function overrideDerivation creates a new derivation + based on an existing one by overriding the original's attributes with + the attribute set produced by the specified function. + This function is available on all + derivations defined using the makeOverridable function. + Most standard derivation-producing functions, such as + stdenv.mkDerivation, are defined using this + function, which means most packages in the nixpkgs expression, + pkgs, have this function. - - It is used to create a new derivation by overriding the attributes of - the original derivation according to the given function. - Example usage: @@ -125,9 +125,9 @@ in ... - In the above example, the name, src and patches of the derivation - will be overridden, while all other attributes will be retained from the - original derivation. + In the above example, the name, src, + and patches of the derivation will be overridden, while + all other attributes will be retained from the original derivation. @@ -135,6 +135,20 @@ in ... the original derivation. + + + A package's attributes are evaluated *before* being modified by + the overrideDerivation function. + For example, the name attribute reference + in url = "mirror://gnu/hello/${name}.tar.gz"; + is filled-in *before* the overrideDerivation function + modifies the attribute set. This means that overriding the + name attribute, in this example, *will not* change the + value of the url attribute. Instead, we need to override + both the name *and* url attributes. + + +