2006-08-21 16:05:11 +00:00
|
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook"
|
2014-08-27 16:41:09 +00:00
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
|
|
|
|
xml:id="sec-nix-build">
|
2007-09-19 14:01:41 +00:00
|
|
|
|
|
|
|
|
|
<refmeta>
|
|
|
|
|
<refentrytitle>nix-build</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum>
|
|
|
|
|
<refmiscinfo class="source">Nix</refmiscinfo>
|
2014-09-16 12:57:45 +00:00
|
|
|
|
<refmiscinfo class="version"><xi:include href="../version.txt" parse="text"/></refmiscinfo>
|
2007-09-19 14:01:41 +00:00
|
|
|
|
</refmeta>
|
2006-08-21 16:05:11 +00:00
|
|
|
|
|
2005-04-07 10:47:58 +00:00
|
|
|
|
<refnamediv>
|
|
|
|
|
<refname>nix-build</refname>
|
|
|
|
|
<refpurpose>build a Nix expression</refpurpose>
|
|
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
|
<cmdsynopsis>
|
|
|
|
|
<command>nix-build</command>
|
2007-02-05 12:10:10 +00:00
|
|
|
|
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="opt-common-syn.xml#xmlns(db=http://docbook.org/ns/docbook)xpointer(/db:nop/*)" />
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<arg><option>--arg</option> <emphasis>name</emphasis> <emphasis>value</emphasis></arg>
|
|
|
|
|
<arg><option>--argstr</option> <emphasis>name</emphasis> <emphasis>value</emphasis></arg>
|
2006-10-05 20:07:41 +00:00
|
|
|
|
<arg>
|
|
|
|
|
<group choice='req'>
|
|
|
|
|
<arg choice='plain'><option>--attr</option></arg>
|
|
|
|
|
<arg choice='plain'><option>-A</option></arg>
|
|
|
|
|
</group>
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<emphasis>attrPath</emphasis>
|
2006-10-05 20:07:41 +00:00
|
|
|
|
</arg>
|
2006-10-02 11:50:55 +00:00
|
|
|
|
<arg><option>--no-out-link</option></arg>
|
2019-11-06 23:11:57 +00:00
|
|
|
|
<arg><option>--dry-run</option></arg>
|
2006-10-02 11:50:55 +00:00
|
|
|
|
<arg>
|
|
|
|
|
<group choice='req'>
|
|
|
|
|
<arg choice='plain'><option>--out-link</option></arg>
|
|
|
|
|
<arg choice='plain'><option>-o</option></arg>
|
|
|
|
|
</group>
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<emphasis>outlink</emphasis>
|
2006-10-02 11:50:55 +00:00
|
|
|
|
</arg>
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<arg choice='plain' rep='repeat'><emphasis>paths</emphasis></arg>
|
2005-04-07 10:47:58 +00:00
|
|
|
|
</cmdsynopsis>
|
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
|
|
<refsection><title>Description</title>
|
|
|
|
|
|
|
|
|
|
<para>The <command>nix-build</command> command builds the derivations
|
2020-07-23 12:28:05 +00:00
|
|
|
|
described by the Nix expressions in <emphasis>paths</emphasis>.
|
2005-04-07 10:47:58 +00:00
|
|
|
|
If the build succeeds, it places a symlink to the result in the
|
|
|
|
|
current directory. The symlink is called <filename>result</filename>.
|
|
|
|
|
If there are multiple Nix expressions, or the Nix expressions evaluate
|
|
|
|
|
to multiple derivations, multiple sequentially numbered symlinks are
|
|
|
|
|
created (<filename>result</filename>, <filename>result-2</filename>,
|
|
|
|
|
and so on).</para>
|
|
|
|
|
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<para>If no <emphasis>paths</emphasis> are specified, then
|
2005-07-13 17:39:10 +00:00
|
|
|
|
<command>nix-build</command> will use <filename>default.nix</filename>
|
|
|
|
|
in the current directory, if it exists.</para>
|
|
|
|
|
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<para>If an element of <emphasis>paths</emphasis> starts with
|
2015-06-01 13:14:44 +00:00
|
|
|
|
<literal>http://</literal> or <literal>https://</literal>, it is
|
|
|
|
|
interpreted as the URL of a tarball that will be downloaded and
|
|
|
|
|
unpacked to a temporary location. The tarball must include a single
|
|
|
|
|
top-level directory containing at least a file named
|
|
|
|
|
<filename>default.nix</filename>.</para>
|
|
|
|
|
|
2006-10-02 11:50:55 +00:00
|
|
|
|
<para><command>nix-build</command> is essentially a wrapper around
|
|
|
|
|
<link
|
2005-04-07 10:47:58 +00:00
|
|
|
|
linkend="sec-nix-instantiate"><command>nix-instantiate</command></link>
|
|
|
|
|
(to translate a high-level Nix expression to a low-level store
|
|
|
|
|
derivation) and <link
|
|
|
|
|
linkend="rsec-nix-store-realise"><command>nix-store
|
2006-10-02 11:50:55 +00:00
|
|
|
|
--realise</command></link> (to build the store derivation).</para>
|
2005-04-07 10:47:58 +00:00
|
|
|
|
|
|
|
|
|
<warning><para>The result of the build is automatically registered as
|
|
|
|
|
a root of the Nix garbage collector. This root disappears
|
|
|
|
|
automatically when the <filename>result</filename> symlink is deleted
|
|
|
|
|
or renamed. So don’t rename the symlink.</para></warning>
|
|
|
|
|
|
|
|
|
|
</refsection>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<refsection><title>Options</title>
|
|
|
|
|
|
2012-04-06 19:45:00 +00:00
|
|
|
|
<para>All options not listed here are passed to <command>nix-store
|
|
|
|
|
--realise</command>, except for <option>--arg</option> and
|
|
|
|
|
<option>--attr</option> / <option>-A</option> which are passed to
|
|
|
|
|
<command>nix-instantiate</command>. <phrase condition="manual">See
|
|
|
|
|
also <xref linkend="sec-common-options" />.</phrase></para>
|
2006-10-05 09:08:52 +00:00
|
|
|
|
|
2005-04-07 10:47:58 +00:00
|
|
|
|
<variablelist>
|
|
|
|
|
|
2006-10-02 11:50:55 +00:00
|
|
|
|
<varlistentry><term><option>--no-out-link</option></term>
|
2012-12-04 15:03:56 +00:00
|
|
|
|
|
2005-04-07 10:47:58 +00:00
|
|
|
|
<listitem><para>Do not create a symlink to the output path. Note
|
|
|
|
|
that as a result the output does not become a root of the garbage
|
|
|
|
|
collector, and so might be deleted by <command>nix-store
|
|
|
|
|
--gc</command>.</para></listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2019-11-06 23:11:57 +00:00
|
|
|
|
<varlistentry><term><option>--dry-run</option></term>
|
2019-11-26 19:33:46 +00:00
|
|
|
|
<listitem><para>Show what store paths would be built or downloaded.</para></listitem>
|
2019-11-06 23:11:57 +00:00
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2006-10-02 11:50:55 +00:00
|
|
|
|
<varlistentry xml:id='opt-out-link'><term><option>--out-link</option> /
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<option>-o</option> <emphasis>outlink</emphasis></term>
|
2012-12-04 15:03:56 +00:00
|
|
|
|
|
2006-10-02 11:50:55 +00:00
|
|
|
|
<listitem><para>Change the name of the symlink to the output path
|
2012-01-13 23:35:07 +00:00
|
|
|
|
created from <filename>result</filename> to
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<emphasis>outlink</emphasis>.</para></listitem>
|
2006-10-02 11:50:55 +00:00
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2005-04-07 10:47:58 +00:00
|
|
|
|
</variablelist>
|
|
|
|
|
|
2013-07-19 10:02:44 +00:00
|
|
|
|
<para>The following common options are supported:</para>
|
|
|
|
|
|
2012-04-06 19:45:00 +00:00
|
|
|
|
<variablelist condition="manpage">
|
|
|
|
|
<xi:include href="opt-common.xml#xmlns(db=http://docbook.org/ns/docbook)xpointer(//db:variablelist[@xml:id='opt-common']/*)" />
|
|
|
|
|
</variablelist>
|
|
|
|
|
|
2005-04-07 10:47:58 +00:00
|
|
|
|
</refsection>
|
|
|
|
|
|
|
|
|
|
|
2006-10-05 20:41:57 +00:00
|
|
|
|
<refsection><title>Examples</title>
|
|
|
|
|
|
|
|
|
|
<screen>
|
2012-05-09 23:06:39 +00:00
|
|
|
|
$ nix-build '<nixpkgs>' -A firefox
|
2006-10-05 20:41:57 +00:00
|
|
|
|
store derivation is /nix/store/qybprl8sz2lc...-firefox-1.5.0.7.drv
|
|
|
|
|
/nix/store/d18hyl92g30l...-firefox-1.5.0.7
|
|
|
|
|
|
|
|
|
|
$ ls -l result
|
2020-07-23 12:28:05 +00:00
|
|
|
|
lrwxrwxrwx <emphasis>...</emphasis> result -> /nix/store/d18hyl92g30l...-firefox-1.5.0.7
|
2006-10-05 20:41:57 +00:00
|
|
|
|
|
|
|
|
|
$ ls ./result/bin/
|
|
|
|
|
firefox firefox-config</screen>
|
|
|
|
|
|
2012-12-04 15:03:56 +00:00
|
|
|
|
<para>If a derivation has multiple outputs,
|
|
|
|
|
<command>nix-build</command> will build the default (first) output.
|
|
|
|
|
You can also build all outputs:
|
|
|
|
|
<screen>
|
|
|
|
|
$ nix-build '<nixpkgs>' -A openssl.all
|
|
|
|
|
</screen>
|
|
|
|
|
This will create a symlink for each output named
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<filename>result-<emphasis>outputname</emphasis></filename>.
|
2012-12-04 15:03:56 +00:00
|
|
|
|
The suffix is omitted if the output name is <literal>out</literal>.
|
|
|
|
|
So if <literal>openssl</literal> has outputs <literal>out</literal>,
|
|
|
|
|
<literal>bin</literal> and <literal>man</literal>,
|
|
|
|
|
<command>nix-build</command> will create symlinks
|
|
|
|
|
<literal>result</literal>, <literal>result-bin</literal> and
|
|
|
|
|
<literal>result-man</literal>. It’s also possible to build a specific
|
|
|
|
|
output:
|
|
|
|
|
<screen>
|
|
|
|
|
$ nix-build '<nixpkgs>' -A openssl.man
|
|
|
|
|
</screen>
|
|
|
|
|
This will create a symlink <literal>result-man</literal>.</para>
|
2012-05-10 23:29:36 +00:00
|
|
|
|
|
2014-02-19 15:30:19 +00:00
|
|
|
|
<para>Build a Nix expression given on the command line:
|
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
$ nix-build -E 'with import <nixpkgs> { }; runCommand "foo" { } "echo bar > $out"'
|
|
|
|
|
$ cat ./result
|
|
|
|
|
bar
|
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
2015-06-01 13:14:44 +00:00
|
|
|
|
<para>Build the GNU Hello package from the latest revision of the
|
|
|
|
|
master branch of Nixpkgs:
|
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
$ nix-build https://github.com/NixOS/nixpkgs/archive/master.tar.gz -A hello
|
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
2006-10-05 20:41:57 +00:00
|
|
|
|
</refsection>
|
|
|
|
|
|
|
|
|
|
|
2012-04-06 19:56:20 +00:00
|
|
|
|
<refsection condition="manpage"><title>Environment variables</title>
|
|
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
|
<xi:include href="env-common.xml#xmlns(db=http://docbook.org/ns/docbook)xpointer(//db:variablelist[@xml:id='env-common']/*)" />
|
|
|
|
|
</variablelist>
|
|
|
|
|
|
|
|
|
|
</refsection>
|
2012-12-04 15:03:56 +00:00
|
|
|
|
|
2012-04-06 19:56:20 +00:00
|
|
|
|
|
2005-04-07 10:47:58 +00:00
|
|
|
|
</refentry>
|