docs: use overrideAttrs instead of overrideDerivation
This commit is contained in:
parent
3cb116f708
commit
3d99eea852
@ -42,29 +42,30 @@ construction, so without them,
|
|||||||
elements.)</para>
|
elements.)</para>
|
||||||
|
|
||||||
<para>Even greater customisation is possible using the function
|
<para>Even greater customisation is possible using the function
|
||||||
<varname>overrideDerivation</varname>. While the
|
<varname>overrideAttrs</varname>. While the
|
||||||
<varname>override</varname> mechanism above overrides the arguments of
|
<varname>override</varname> mechanism above overrides the arguments of
|
||||||
a package function, <varname>overrideDerivation</varname> allows
|
a package function, <varname>overrideAttrs</varname> allows
|
||||||
changing the <emphasis>result</emphasis> of the function. This
|
changing the <emphasis>attributes</emphasis> of the function. This
|
||||||
permits changing any aspect of the package, such as the source code.
|
permits changing any aspect of the package, such as the source code.
|
||||||
For instance, if you want to override the source code of Emacs, you
|
For instance, if you want to override the source code of Emacs, you
|
||||||
can say:
|
can say:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
environment.systemPackages =
|
environment.systemPackages = [
|
||||||
[ (pkgs.lib.overrideDerivation pkgs.emacs (attrs: {
|
(pkgs.emacs.overrideAttrs (oldAttrs: {
|
||||||
name = "emacs-25.0-pre";
|
name = "emacs-25.0-pre";
|
||||||
src = /path/to/my/emacs/tree;
|
src = /path/to/my/emacs/tree;
|
||||||
}))
|
}))
|
||||||
];
|
];
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
Here, <varname>overrideDerivation</varname> takes the Nix derivation
|
Here, <varname>overrideAttrs</varname> takes the Nix derivation
|
||||||
specified by <varname>pkgs.emacs</varname> and produces a new
|
specified by <varname>pkgs.emacs</varname> and produces a new
|
||||||
derivation in which the original’s <literal>name</literal> and
|
derivation in which the original’s <literal>name</literal> and
|
||||||
<literal>src</literal> attribute have been replaced by the given
|
<literal>src</literal> attribute have been replaced by the given
|
||||||
values. The original attributes are accessible via
|
values by re-calling <literal>stdenv.mkDerivation</literal>.
|
||||||
<varname>attrs</varname>.</para>
|
The original attributes are accessible via the function argument,
|
||||||
|
which is conventionally named <varname>oldAttrs</varname>.</para>
|
||||||
|
|
||||||
<para>The overrides shown above are not global. They do not affect
|
<para>The overrides shown above are not global. They do not affect
|
||||||
the original package; other packages in Nixpkgs continue to depend on
|
the original package; other packages in Nixpkgs continue to depend on
|
||||||
|
@ -17,12 +17,10 @@ with lib;
|
|||||||
where tools such as <command>gdb</command> can find them.
|
where tools such as <command>gdb</command> can find them.
|
||||||
If you need debug symbols for a package that doesn't
|
If you need debug symbols for a package that doesn't
|
||||||
provide them by default, you can enable them as follows:
|
provide them by default, you can enable them as follows:
|
||||||
<!-- FIXME: ugly, see #10721 -->
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
nixpkgs.config.packageOverrides = pkgs: {
|
nixpkgs.config.packageOverrides = pkgs: {
|
||||||
hello = pkgs.lib.overrideDerivation pkgs.hello (attrs: {
|
hello = pkgs.hello.overrideAttrs (oldAttrs: {
|
||||||
outputs = attrs.outputs or ["out"] ++ ["debug"];
|
separateDebugInfo = true;
|
||||||
buildInputs = attrs.buildInputs ++ [<nixpkgs/pkgs/build-support/setup-hooks/separate-debug-info.sh>];
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@ -356,14 +356,14 @@ https://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides
|
|||||||
<programlisting><![CDATA[
|
<programlisting><![CDATA[
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
let
|
let
|
||||||
myEmacs = pkgs.lib.overrideDerivation (pkgs.emacs.override {
|
myEmacs = (pkgs.emacs.override {
|
||||||
# Use gtk3 instead of the default gtk2
|
# Use gtk3 instead of the default gtk2
|
||||||
withGTK3 = true;
|
withGTK3 = true;
|
||||||
withGTK2 = false;
|
withGTK2 = false;
|
||||||
}) (attrs: {
|
}).overrideAttrs (attrs: {
|
||||||
# I don't want emacs.desktop file because I only use
|
# I don't want emacs.desktop file because I only use
|
||||||
# emacsclient.
|
# emacsclient.
|
||||||
postInstall = attrs.postInstall + ''
|
postInstall = (attrs.postInstall or "") + ''
|
||||||
rm $out/share/applications/emacs.desktop
|
rm $out/share/applications/emacs.desktop
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user