git.iko.soy/typeable/nixpkgs
on master help sign in
docs: use overrideAttrs instead of overrideDerivation
commit3d99eea85208d4f491e3a5c241b03d2c8d0c4125 authorAneesh Agrawal <aneeshusa@gmail.com> dateSun 30 Oct 2016, 12:35 (10 years ago) parent3cb116f
3 files changed+18−19
nixos/doc/manual/configuration/customizing-packages.xml+13−12 nixos/modules/config/debug-info.nix+2−4 nixos/modules/services/editors/emacs.xml+3−3
nixos/doc/manual/configuration/customizing-packages.xml+13−12
@@ -42,29 +42,30 @@ construction, so without them,
4242elements.)</para>
4343
4444<para>Even greater customisation is possible using the function
45−<varname>overrideDerivation</varname>. While the
45+<varname>overrideAttrs</varname>. While the
4646<varname>override</varname> mechanism above overrides the arguments of
47−a package function, <varname>overrideDerivation</varname> allows
48−changing the <emphasis>result</emphasis> of the function. This
47+a package function, <varname>overrideAttrs</varname> allows
48+changing the <emphasis>attributes</emphasis> of the function. This
4949permits changing any aspect of the package, such as the source code.
5050For instance, if you want to override the source code of Emacs, you
5151can say:
5252
5353<programlisting>
54−environment.systemPackages =
55− [ (pkgs.lib.overrideDerivation pkgs.emacs (attrs: {
56− name = "emacs-25.0-pre";
57− src = /path/to/my/emacs/tree;
58− }))
59− ];
54+environment.systemPackages = [
55+ (pkgs.emacs.overrideAttrs (oldAttrs: {
56+ name = "emacs-25.0-pre";
57+ src = /path/to/my/emacs/tree;
58+ }))
59+];
6060</programlisting>
6161
62−Here, <varname>overrideDerivation</varname> takes the Nix derivation
62+Here, <varname>overrideAttrs</varname> takes the Nix derivation
6363specified by <varname>pkgs.emacs</varname> and produces a new
6464derivation in which the original’s <literal>name</literal> and
6565<literal>src</literal> attribute have been replaced by the given
66−values. The original attributes are accessible via
67−<varname>attrs</varname>.</para>
66+values by re-calling <literal>stdenv.mkDerivation</literal>.
67+The original attributes are accessible via the function argument,
68+which is conventionally named <varname>oldAttrs</varname>.</para>
6869
6970<para>The overrides shown above are not global. They do not affect
7071the original package; other packages in Nixpkgs continue to depend on
nixos/modules/config/debug-info.nix+2−4
@@ -17,12 +17,10 @@ with lib;
1717 where tools such as <command>gdb</command> can find them.
1818 If you need debug symbols for a package that doesn't
1919 provide them by default, you can enable them as follows:
20− <!-- FIXME: ugly, see #10721 -->
2120 <programlisting>
2221 nixpkgs.config.packageOverrides = pkgs: {
23− hello = pkgs.lib.overrideDerivation pkgs.hello (attrs: {
24− outputs = attrs.outputs or ["out"] ++ ["debug"];
25− buildInputs = attrs.buildInputs ++ [&lt;nixpkgs/pkgs/build-support/setup-hooks/separate-debug-info.sh>];
22+ hello = pkgs.hello.overrideAttrs (oldAttrs: {
23+ separateDebugInfo = true;
2624 });
2725 };
2826 </programlisting>
nixos/modules/services/editors/emacs.xml+3−3
@@ -356,14 +356,14 @@ https://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides
356356 <programlisting><![CDATA[
357357{ pkgs ? import <nixpkgs> {} }:
358358let
359− myEmacs = pkgs.lib.overrideDerivation (pkgs.emacs.override {
359+ myEmacs = (pkgs.emacs.override {
360360 # Use gtk3 instead of the default gtk2
361361 withGTK3 = true;
362362 withGTK2 = false;
363− }) (attrs: {
363+ }).overrideAttrs (attrs: {
364364 # I don't want emacs.desktop file because I only use
365365 # emacsclient.
366− postInstall = attrs.postInstall + ''
366+ postInstall = (attrs.postInstall or "") + ''
367367 rm $out/share/applications/emacs.desktop
368368 '';
369369 });