2006-08-21 19:05:11 +03:00
|
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook"
|
2014-08-27 19:41:09 +03:00
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
|
|
|
|
xml:id="sec-nix-instantiate">
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2007-09-19 17:01:41 +03:00
|
|
|
|
<refmeta>
|
|
|
|
|
<refentrytitle>nix-instantiate</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum>
|
|
|
|
|
<refmiscinfo class="source">Nix</refmiscinfo>
|
2014-09-16 15:57:45 +03:00
|
|
|
|
<refmiscinfo class="version"><xi:include href="../version.txt" parse="text"/></refmiscinfo>
|
2007-09-19 17:01:41 +03:00
|
|
|
|
</refmeta>
|
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
<refnamediv>
|
|
|
|
|
<refname>nix-instantiate</refname>
|
|
|
|
|
<refpurpose>instantiate store derivations from Nix expressions</refpurpose>
|
|
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
|
<cmdsynopsis>
|
|
|
|
|
<command>nix-instantiate</command>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<group>
|
2014-02-19 17:34:24 +02:00
|
|
|
|
<arg choice='plain'><option>--parse</option></arg>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<arg choice='plain'>
|
2014-02-19 17:34:24 +02:00
|
|
|
|
<option>--eval</option>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<arg><option>--strict</option></arg>
|
2017-07-07 22:51:22 +03:00
|
|
|
|
<arg><option>--json</option></arg>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<arg><option>--xml</option></arg>
|
|
|
|
|
</arg>
|
|
|
|
|
</group>
|
|
|
|
|
<arg><option>--read-write-mode</option></arg>
|
2006-10-05 12:08:52 +03:00
|
|
|
|
<arg><option>--arg</option> <replaceable>name</replaceable> <replaceable>value</replaceable></arg>
|
2006-10-05 23:07:41 +03:00
|
|
|
|
<arg>
|
|
|
|
|
<group choice='req'>
|
|
|
|
|
<arg choice='plain'><option>--attr</option></arg>
|
|
|
|
|
<arg choice='plain'><option>-A</option></arg>
|
|
|
|
|
</group>
|
|
|
|
|
<replaceable>attrPath</replaceable>
|
|
|
|
|
</arg>
|
2005-04-05 18:28:30 +03:00
|
|
|
|
<arg><option>--add-root</option> <replaceable>path</replaceable></arg>
|
|
|
|
|
<arg><option>--indirect</option></arg>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<group choice='req'>
|
|
|
|
|
<arg choice='plain'><option>--expr</option></arg>
|
|
|
|
|
<arg choice='plain'><option>-E</option></arg>
|
|
|
|
|
</group>
|
|
|
|
|
<arg choice='plain' rep='repeat'><replaceable>files</replaceable></arg>
|
2017-07-06 17:37:19 +03:00
|
|
|
|
</cmdsynopsis>
|
|
|
|
|
<cmdsynopsis>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<command>nix-instantiate</command>
|
2014-10-27 00:06:13 +02:00
|
|
|
|
<arg choice='plain'><option>--find-file</option></arg>
|
2005-04-05 18:28:30 +03:00
|
|
|
|
<arg choice='plain' rep='repeat'><replaceable>files</replaceable></arg>
|
|
|
|
|
</cmdsynopsis>
|
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<refsection><title>Description</title>
|
|
|
|
|
|
|
|
|
|
<para>The command <command>nix-instantiate</command> generates <link
|
|
|
|
|
linkend="gloss-derivation">store derivations</link> from (high-level)
|
2014-02-19 17:30:19 +02:00
|
|
|
|
Nix expressions. It evaluates the Nix expressions in each of
|
|
|
|
|
<replaceable>files</replaceable> (which defaults to
|
2012-04-17 18:19:43 +03:00
|
|
|
|
<replaceable>./default.nix</replaceable>). Each top-level expression
|
|
|
|
|
should evaluate to a derivation, a list of derivations, or a set of
|
2005-04-05 18:28:30 +03:00
|
|
|
|
derivations. The paths of the resulting store derivations are printed
|
|
|
|
|
on standard output.</para>
|
|
|
|
|
|
2006-02-10 17:29:17 +02:00
|
|
|
|
<para>If <replaceable>files</replaceable> is the character
|
|
|
|
|
<literal>-</literal>, then a Nix expression will be read from standard
|
|
|
|
|
input.</para>
|
|
|
|
|
|
2012-04-06 22:45:00 +03:00
|
|
|
|
<para condition="manual">See also <xref linkend="sec-common-options"
|
|
|
|
|
/> for a list of common options.</para>
|
2005-04-05 18:28:30 +03:00
|
|
|
|
|
|
|
|
|
</refsection>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<refsection><title>Options</title>
|
|
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><option>--add-root</option> <replaceable>path</replaceable></term>
|
|
|
|
|
<term><option>--indirect</option></term>
|
|
|
|
|
|
|
|
|
|
<listitem><para>See the <link linkend="opt-add-root">corresponding
|
|
|
|
|
options</link> in <command>nix-store</command>.</para></listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2014-02-19 17:34:24 +02:00
|
|
|
|
<varlistentry><term><option>--parse</option></term>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
<listitem><para>Just parse the input files, and print their
|
|
|
|
|
abstract syntax trees on standard output in ATerm
|
|
|
|
|
format.</para></listitem>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
</varlistentry>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2014-02-19 17:34:24 +02:00
|
|
|
|
<varlistentry><term><option>--eval</option></term>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
<listitem><para>Just parse and evaluate the input files, and print
|
|
|
|
|
the resulting values on standard output. No instantiation of
|
|
|
|
|
store derivations takes place.</para></listitem>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
</varlistentry>
|
2004-11-13 01:22:08 +02:00
|
|
|
|
|
2012-04-17 18:14:14 +03:00
|
|
|
|
<varlistentry><term><option>--find-file</option></term>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2012-04-17 18:14:14 +03:00
|
|
|
|
<listitem><para>Look up the given files in Nix’s search path (as
|
2014-09-16 12:20:09 +03:00
|
|
|
|
specified by the <envar linkend="env-NIX_PATH">NIX_PATH</envar>
|
|
|
|
|
environment variable). If found, print the corresponding absolute
|
|
|
|
|
paths on standard output. For instance, if
|
|
|
|
|
<envar>NIX_PATH</envar> is
|
2012-04-17 18:14:14 +03:00
|
|
|
|
<literal>nixpkgs=/home/alice/nixpkgs</literal>, then
|
|
|
|
|
<literal>nix-instantiate --find-file nixpkgs/default.nix</literal>
|
|
|
|
|
will print
|
|
|
|
|
<literal>/home/alice/nixpkgs/default.nix</literal>.</para></listitem>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2012-04-17 18:14:14 +03:00
|
|
|
|
</varlistentry>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2017-07-07 22:51:22 +03:00
|
|
|
|
<varlistentry><term><option>--strict</option></term>
|
2006-10-05 23:41:57 +03:00
|
|
|
|
|
2017-07-07 22:51:22 +03:00
|
|
|
|
<listitem><para>When used with <option>--eval</option>,
|
|
|
|
|
recursively evaluate list elements and attributes. Normally, such
|
|
|
|
|
sub-expressions are left unevaluated (since the Nix expression
|
|
|
|
|
language is lazy).</para>
|
|
|
|
|
|
|
|
|
|
<warning><para>This option can cause non-termination, because lazy
|
|
|
|
|
data structures can be infinitely large.</para></warning>
|
|
|
|
|
|
|
|
|
|
</listitem>
|
2006-10-05 23:41:57 +03:00
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2014-06-24 00:30:22 +03:00
|
|
|
|
<varlistentry><term><option>--json</option></term>
|
|
|
|
|
|
2017-05-03 11:49:34 +03:00
|
|
|
|
<listitem><para>When used with <option>--eval</option>, print the resulting
|
|
|
|
|
value as an JSON representation of the abstract syntax tree rather
|
|
|
|
|
than as an ATerm.</para></listitem>
|
2014-06-24 00:30:22 +03:00
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2017-07-07 22:51:22 +03:00
|
|
|
|
<varlistentry><term><option>--xml</option></term>
|
2006-10-05 23:41:57 +03:00
|
|
|
|
|
2017-07-07 22:51:22 +03:00
|
|
|
|
<listitem><para>When used with <option>--eval</option>, print the resulting
|
|
|
|
|
value as an XML representation of the abstract syntax tree rather than as
|
|
|
|
|
an ATerm. The schema is the same as that used by the <link
|
|
|
|
|
linkend="builtin-toXML"><function>toXML</function> built-in</link>.
|
|
|
|
|
</para></listitem>
|
2006-10-05 23:41:57 +03:00
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2014-02-04 17:35:30 +02:00
|
|
|
|
<varlistentry><term><option>--read-write-mode</option></term>
|
2014-02-04 16:17:59 +02:00
|
|
|
|
|
2014-02-19 17:34:24 +02:00
|
|
|
|
<listitem><para>When used with <option>--eval</option>, perform
|
|
|
|
|
evaluation in read/write mode so nix language features that
|
|
|
|
|
require it will still work (at the cost of needing to do
|
2014-02-04 16:17:59 +02:00
|
|
|
|
instantiation of every evaluated derivation).</para>
|
|
|
|
|
|
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
</variablelist>
|
2004-02-10 18:14:47 +02:00
|
|
|
|
|
2012-04-06 22:45:00 +03: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-05 18:28:30 +03:00
|
|
|
|
</refsection>
|
2004-02-10 18:14:47 +02:00
|
|
|
|
|
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
<refsection><title>Examples</title>
|
2004-02-10 18:14:47 +02:00
|
|
|
|
|
2006-10-05 23:41:57 +03:00
|
|
|
|
<para>Instantiating store derivations from a Nix expression, and
|
|
|
|
|
building them using <command>nix-store</command>:
|
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
<screen>
|
|
|
|
|
$ nix-instantiate test.nix <lineannotation>(instantiate)</lineannotation>
|
|
|
|
|
/nix/store/cigxbmvy6dzix98dxxh9b6shg7ar5bvs-perl-BerkeleyDB-0.26.drv
|
2004-02-10 18:14:47 +02:00
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
$ nix-store -r $(nix-instantiate test.nix) <lineannotation>(build)</lineannotation>
|
|
|
|
|
<replaceable>...</replaceable>
|
|
|
|
|
/nix/store/qhqk4n8ci095g3sdp93x7rgwyh9rdvgk-perl-BerkeleyDB-0.26 <lineannotation>(output path)</lineannotation>
|
2004-02-10 18:14:47 +02:00
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
$ ls -l /nix/store/qhqk4n8ci095g3sdp93x7rgwyh9rdvgk-perl-BerkeleyDB-0.26
|
|
|
|
|
dr-xr-xr-x 2 eelco users 4096 1970-01-01 01:00 lib
|
2004-02-10 18:14:47 +02:00
|
|
|
|
...</screen>
|
2003-08-14 14:27:02 +03:00
|
|
|
|
|
2006-10-05 23:41:57 +03:00
|
|
|
|
</para>
|
|
|
|
|
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<para>You can also give a Nix expression on the command line:
|
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
$ nix-instantiate -E 'with import <nixpkgs> { }; hello'
|
|
|
|
|
/nix/store/j8s4zyv75a724q38cb0r87rlczaiag4y-hello-2.8.drv
|
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
|
|
This is equivalent to:
|
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
$ nix-instantiate '<nixpkgs>' -A hello
|
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
2006-10-05 23:41:57 +03:00
|
|
|
|
<para>Parsing and evaluating Nix expressions:
|
|
|
|
|
|
|
|
|
|
<screen>
|
2014-02-19 17:34:24 +02:00
|
|
|
|
$ nix-instantiate --parse -E '1 + 2'
|
2014-02-19 17:30:19 +02:00
|
|
|
|
1 + 2
|
2006-10-05 23:41:57 +03:00
|
|
|
|
|
2014-02-19 17:34:24 +02:00
|
|
|
|
$ nix-instantiate --eval -E '1 + 2'
|
2014-02-19 17:30:19 +02:00
|
|
|
|
3
|
2006-10-05 23:41:57 +03:00
|
|
|
|
|
2014-02-19 17:34:24 +02:00
|
|
|
|
$ nix-instantiate --eval --xml -E '1 + 2'
|
2006-10-05 23:41:57 +03:00
|
|
|
|
<![CDATA[<?xml version='1.0' encoding='utf-8'?>
|
|
|
|
|
<expr>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<int value="3" />
|
2006-10-05 23:41:57 +03:00
|
|
|
|
</expr>]]></screen>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
<para>The difference between non-strict and strict evaluation:
|
|
|
|
|
|
|
|
|
|
<screen>
|
2014-02-19 17:34:24 +02:00
|
|
|
|
$ nix-instantiate --eval --xml -E 'rec { x = "foo"; y = x; }'
|
2006-10-05 23:41:57 +03:00
|
|
|
|
<replaceable>...</replaceable><![CDATA[
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<attr name="x">
|
|
|
|
|
<string value="foo" />
|
|
|
|
|
</attr>
|
|
|
|
|
<attr name="y">
|
|
|
|
|
<unevaluated />
|
|
|
|
|
</attr>]]>
|
2006-10-05 23:41:57 +03:00
|
|
|
|
<replaceable>...</replaceable></screen>
|
|
|
|
|
|
|
|
|
|
Note that <varname>y</varname> is left unevaluated (the XML
|
|
|
|
|
representation doesn’t attempt to show non-normal forms).
|
|
|
|
|
|
|
|
|
|
<screen>
|
2014-02-19 17:34:24 +02:00
|
|
|
|
$ nix-instantiate --eval --xml --strict -E 'rec { x = "foo"; y = x; }'
|
2006-10-05 23:41:57 +03:00
|
|
|
|
<replaceable>...</replaceable><![CDATA[
|
2014-02-19 17:30:19 +02:00
|
|
|
|
<attr name="x">
|
|
|
|
|
<string value="foo" />
|
|
|
|
|
</attr>
|
|
|
|
|
<attr name="y">
|
|
|
|
|
<string value="foo" />
|
|
|
|
|
</attr>]]>
|
2006-10-05 23:41:57 +03:00
|
|
|
|
<replaceable>...</replaceable></screen>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
2005-04-05 18:28:30 +03:00
|
|
|
|
</refsection>
|
|
|
|
|
|
|
|
|
|
|
2012-04-06 22:56:20 +03: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>
|
2014-02-19 17:30:19 +02:00
|
|
|
|
|
2012-04-06 22:56:20 +03:00
|
|
|
|
|
2003-08-14 14:27:02 +03:00
|
|
|
|
</refentry>
|