git.iko.soy/typeable/nixpkgs
on master help sign in
Merge #20001: docs: use overrideAttrs instead of overrideDerivation
5d5efceVladimír Čunát
nixos/doc/manual/configuration/customizing-packages.xml+14−13
@@ -42,29 +42,30 @@ construction, so without them,
42elements.)</para>
42elements.)</para>
43
43
44<para>Even greater customisation is possible using the function
44<para>Even greater customisation is possible using the function
45−<varname>overrideDerivation</varname>. While the
45+<varname>overrideAttrs</varname>. While the
46<varname>override</varname> mechanism above overrides the arguments of
46<varname>override</varname> mechanism above overrides the arguments of
47−a package function, <varname>overrideDerivation</varname> allows
47+a package function, <varname>overrideAttrs</varname> allows
48−changing the <emphasis>result</emphasis> of the function. This
48+changing the <emphasis>attributes</emphasis> passed to <literal>mkDerivation</literal>.
49−permits changing any aspect of the package, such as the source code.
49+This permits changing any aspect of the package, such as the source code.
50For instance, if you want to override the source code of Emacs, you
50For instance, if you want to override the source code of Emacs, you
51can say:
51can say:
52
52
53<programlisting>
53<programlisting>
54−environment.systemPackages =
54+environment.systemPackages = [
55− [ (pkgs.lib.overrideDerivation pkgs.emacs (attrs: {
55+ (pkgs.emacs.overrideAttrs (oldAttrs: {
56− name = "emacs-25.0-pre";
56+ name = "emacs-25.0-pre";
57− src = /path/to/my/emacs/tree;
57+ src = /path/to/my/emacs/tree;
58− }))
58+ }))
59− ];
59+];
60</programlisting>
60</programlisting>
61
61
62−Here, <varname>overrideDerivation</varname> takes the Nix derivation
62+Here, <varname>overrideAttrs</varname> takes the Nix derivation
63specified by <varname>pkgs.emacs</varname> and produces a new
63specified by <varname>pkgs.emacs</varname> and produces a new
64derivation in which the original’s <literal>name</literal> and
64derivation in which the original’s <literal>name</literal> and
65<literal>src</literal> attribute have been replaced by the given
65<literal>src</literal> attribute have been replaced by the given
66+values by re-calling <literal>stdenv.mkDerivation</literal>.
66−values. The original attributes are accessible via
67+The original attributes are accessible via the function argument,
67−<varname>attrs</varname>.</para>
68+which is conventionally named <varname>oldAttrs</varname>.</para>
68
69
69<para>The overrides shown above are not global. They do not affect
70<para>The overrides shown above are not global. They do not affect
70the original package; other packages in Nixpkgs continue to depend on
71the original package; other packages in Nixpkgs continue to depend on
nixos/modules/config/debug-info.nix+2−4
@@ -17,12 +17,10 @@ with lib;
17 where tools such as <command>gdb</command> can find them.
17 where tools such as <command>gdb</command> can find them.
18 If you need debug symbols for a package that doesn't
18 If you need debug symbols for a package that doesn't
19 provide them by default, you can enable them as follows:
19 provide them by default, you can enable them as follows:
20− <!-- FIXME: ugly, see #10721 -->
21 <programlisting>
20 <programlisting>
22 nixpkgs.config.packageOverrides = pkgs: {
21 nixpkgs.config.packageOverrides = pkgs: {
23− hello = pkgs.lib.overrideDerivation pkgs.hello (attrs: {
22+ hello = pkgs.hello.overrideAttrs (oldAttrs: {
24− outputs = attrs.outputs or ["out"] ++ ["debug"];
23+ separateDebugInfo = true;
25− buildInputs = attrs.buildInputs ++ [&lt;nixpkgs/pkgs/build-support/setup-hooks/separate-debug-info.sh>];
26 });
24 });
27 };
25 };
28 </programlisting>
26 </programlisting>
nixos/modules/services/editors/emacs.xml+3−3
@@ -356,14 +356,14 @@ https://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides
356 <programlisting><![CDATA[
356 <programlisting><![CDATA[
357{ pkgs ? import <nixpkgs> {} }:
357{ pkgs ? import <nixpkgs> {} }:
358let
358let
359− myEmacs = pkgs.lib.overrideDerivation (pkgs.emacs.override {
359+ myEmacs = (pkgs.emacs.override {
360 # Use gtk3 instead of the default gtk2
360 # Use gtk3 instead of the default gtk2
361 withGTK3 = true;
361 withGTK3 = true;
362 withGTK2 = false;
362 withGTK2 = false;
363− }) (attrs: {
363+ }).overrideAttrs (attrs: {
364 # I don't want emacs.desktop file because I only use
364 # I don't want emacs.desktop file because I only use
365 # emacsclient.
365 # emacsclient.
366− postInstall = attrs.postInstall + ''
366+ postInstall = (attrs.postInstall or "") + ''
367 rm $out/share/applications/emacs.desktop
367 rm $out/share/applications/emacs.desktop
368 '';
368 '';
369 });
369 });