doc: describe pname
This was forgotten when RFC 0035 was implemented.
This commit is contained in:
parent
ad2a9cdd8f
commit
902952d3a3
@ -31,9 +31,28 @@ stdenv.mkDerivation {
|
|||||||
separate Nix expression from <filename>pkgs/all-packages.nix</filename>, you
|
separate Nix expression from <filename>pkgs/all-packages.nix</filename>, you
|
||||||
need to pass it as a function argument.) Specifying a
|
need to pass it as a function argument.) Specifying a
|
||||||
<varname>name</varname> and a <varname>src</varname> is the absolute minimum
|
<varname>name</varname> and a <varname>src</varname> is the absolute minimum
|
||||||
you need to do. Many packages have dependencies that are not provided in the
|
Nix requires. For convenience, you can also use <varname>pname</varname> and
|
||||||
standard environment. It’s usually sufficient to specify those
|
<varname>version</varname> attributes and <literal>mkDerivation</literal>
|
||||||
dependencies in the <varname>buildInputs</varname> attribute:
|
will automatically set <varname>name</varname> to
|
||||||
|
<literal>"${pname}-${version}"</literal> by default. Since
|
||||||
|
<link xlink:href="https://github.com/NixOS/rfcs/pull/35">RFC 0035</link>,
|
||||||
|
this is preferred for packages in Nixpkgs, as it allows us to reuse the
|
||||||
|
version easily:
|
||||||
|
<programlisting>
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
name = "libfoo";
|
||||||
|
version = "1.2.3";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "http://example.org/libfoo-source-${version}.tar.bz2";
|
||||||
|
sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
|
||||||
|
};
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Many packages have dependencies that are not provided in the standard
|
||||||
|
environment. It’s usually sufficient to specify those dependencies in the
|
||||||
|
<varname>buildInputs</varname> attribute:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "libfoo-1.2.3";
|
name = "libfoo-1.2.3";
|
||||||
|
Loading…
Reference in New Issue
Block a user