mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
nix-instantiate: Add a flag --expr / -E to read expressions from the command line
This is basically a shortcut for ‘echo 'expr...' | nix-instantiate -’. Also supported by nix-build and nix-shell.
This commit is contained in:
parent
e707a8a526
commit
c31836008e
6 changed files with 148 additions and 95 deletions
|
@ -164,6 +164,16 @@ $ nix-build '<nixpkgs>' -A openssl.man
|
||||||
</screen>
|
</screen>
|
||||||
This will create a symlink <literal>result-man</literal>.</para>
|
This will create a symlink <literal>result-man</literal>.</para>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
xml:id="sec-nix-instantiate">
|
xml:id="sec-nix-instantiate">
|
||||||
|
|
||||||
<refmeta>
|
<refmeta>
|
||||||
<refentrytitle>nix-instantiate</refentrytitle>
|
<refentrytitle>nix-instantiate</refentrytitle>
|
||||||
<manvolnum>1</manvolnum>
|
<manvolnum>1</manvolnum>
|
||||||
|
@ -18,7 +18,15 @@
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>nix-instantiate</command>
|
<command>nix-instantiate</command>
|
||||||
<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/*)" />
|
<group>
|
||||||
|
<arg choice='plain'><option>--parse-only</option></arg>
|
||||||
|
<arg choice='plain'>
|
||||||
|
<option>--eval-only</option>
|
||||||
|
<arg><option>--strict</option></arg>
|
||||||
|
<arg><option>--xml</option></arg>
|
||||||
|
</arg>
|
||||||
|
</group>
|
||||||
|
<arg><option>--read-write-mode</option></arg>
|
||||||
<arg><option>--arg</option> <replaceable>name</replaceable> <replaceable>value</replaceable></arg>
|
<arg><option>--arg</option> <replaceable>name</replaceable> <replaceable>value</replaceable></arg>
|
||||||
<arg>
|
<arg>
|
||||||
<group choice='req'>
|
<group choice='req'>
|
||||||
|
@ -29,18 +37,14 @@
|
||||||
</arg>
|
</arg>
|
||||||
<arg><option>--add-root</option> <replaceable>path</replaceable></arg>
|
<arg><option>--add-root</option> <replaceable>path</replaceable></arg>
|
||||||
<arg><option>--indirect</option></arg>
|
<arg><option>--indirect</option></arg>
|
||||||
<arg>
|
<group choice='req'>
|
||||||
<group choice='req'>
|
<arg choice='plain'><option>--expr</option></arg>
|
||||||
<arg choice='plain'><option>--parse-only</option></arg>
|
<arg choice='plain'><option>-E</option></arg>
|
||||||
<arg choice='plain'>
|
</group>
|
||||||
<option>--eval-only</option>
|
<arg choice='plain' rep='repeat'><replaceable>files</replaceable></arg>
|
||||||
<arg><option>--strict</option></arg>
|
<sbr/>
|
||||||
<arg><option>--read-write-mode</option></arg>
|
<command>nix-instantiate</command>
|
||||||
</arg>
|
<arg choice='plain'><option>--file-file</option></arg>
|
||||||
<arg choice='plain'><option>--find-file</option></arg>
|
|
||||||
</group>
|
|
||||||
<arg><option>--xml</option></arg>
|
|
||||||
</arg>
|
|
||||||
<arg choice='plain' rep='repeat'><replaceable>files</replaceable></arg>
|
<arg choice='plain' rep='repeat'><replaceable>files</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
@ -50,8 +54,8 @@
|
||||||
|
|
||||||
<para>The command <command>nix-instantiate</command> generates <link
|
<para>The command <command>nix-instantiate</command> generates <link
|
||||||
linkend="gloss-derivation">store derivations</link> from (high-level)
|
linkend="gloss-derivation">store derivations</link> from (high-level)
|
||||||
Nix expressions. It loads and evaluates the Nix expressions in each
|
Nix expressions. It evaluates the Nix expressions in each of
|
||||||
of <replaceable>files</replaceable> (which defaults to
|
<replaceable>files</replaceable> (which defaults to
|
||||||
<replaceable>./default.nix</replaceable>). Each top-level expression
|
<replaceable>./default.nix</replaceable>). Each top-level expression
|
||||||
should evaluate to a derivation, a list of derivations, or a set of
|
should evaluate to a derivation, a list of derivations, or a set of
|
||||||
derivations. The paths of the resulting store derivations are printed
|
derivations. The paths of the resulting store derivations are printed
|
||||||
|
@ -61,12 +65,6 @@ on standard output.</para>
|
||||||
<literal>-</literal>, then a Nix expression will be read from standard
|
<literal>-</literal>, then a Nix expression will be read from standard
|
||||||
input.</para>
|
input.</para>
|
||||||
|
|
||||||
<para>Most users and developers don’t need to use this command
|
|
||||||
(<command>nix-env</command> and <command>nix-build</command> perform
|
|
||||||
store derivation instantiation from Nix expressions automatically).
|
|
||||||
It is most commonly used for implementing new deployment
|
|
||||||
policies.</para>
|
|
||||||
|
|
||||||
<para condition="manual">See also <xref linkend="sec-common-options"
|
<para condition="manual">See also <xref linkend="sec-common-options"
|
||||||
/> for a list of common options.</para>
|
/> for a list of common options.</para>
|
||||||
|
|
||||||
|
@ -86,25 +84,24 @@ policies.</para>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry><term><option>--parse-only</option></term>
|
<varlistentry><term><option>--parse-only</option></term>
|
||||||
|
|
||||||
<listitem><para>Just parse the input files, and print their
|
<listitem><para>Just parse the input files, and print their
|
||||||
abstract syntax trees on standard output in ATerm
|
abstract syntax trees on standard output in ATerm
|
||||||
format.</para></listitem>
|
format.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry><term><option>--eval-only</option></term>
|
<varlistentry><term><option>--eval-only</option></term>
|
||||||
|
|
||||||
<listitem><para>Just parse and evaluate the input files, and print
|
<listitem><para>Just parse and evaluate the input files, and print
|
||||||
the resulting values on standard output. No instantiation of
|
the resulting values on standard output. No instantiation of
|
||||||
store derivations takes place.</para></listitem>
|
store derivations takes place.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry><term><option>--find-file</option></term>
|
<varlistentry><term><option>--find-file</option></term>
|
||||||
|
|
||||||
<listitem><para>Look up the given files in Nix’s search path (as
|
<listitem><para>Look up the given files in Nix’s search path (as
|
||||||
specified by the <envar>NIX_PATH</envar> environment variable).
|
specified by the <envar>NIX_PATH</envar> environment variable).
|
||||||
If found, print the corresponding absolute paths on standard
|
If found, print the corresponding absolute paths on standard
|
||||||
|
@ -113,9 +110,9 @@ policies.</para>
|
||||||
<literal>nix-instantiate --find-file nixpkgs/default.nix</literal>
|
<literal>nix-instantiate --find-file nixpkgs/default.nix</literal>
|
||||||
will print
|
will print
|
||||||
<literal>/home/alice/nixpkgs/default.nix</literal>.</para></listitem>
|
<literal>/home/alice/nixpkgs/default.nix</literal>.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry><term><option>--xml</option></term>
|
<varlistentry><term><option>--xml</option></term>
|
||||||
|
|
||||||
<listitem><para>When used with <option>--parse-only</option> and
|
<listitem><para>When used with <option>--parse-only</option> and
|
||||||
|
@ -180,19 +177,34 @@ dr-xr-xr-x 2 eelco users 4096 1970-01-01 01:00 lib
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
<para>Parsing and evaluating Nix expressions:
|
<para>Parsing and evaluating Nix expressions:
|
||||||
|
|
||||||
<screen>
|
<screen>
|
||||||
$ echo '"foo" + "bar"' | nix-instantiate --parse-only -
|
$ nix-instantiate --parse-only -E '1 + 2'
|
||||||
OpPlus(Str("foo"),Str("bar"))
|
1 + 2
|
||||||
|
|
||||||
$ echo '"foo" + "bar"' | nix-instantiate --eval-only -
|
$ nix-instantiate --eval-only -E '1 + 2'
|
||||||
Str("foobar")
|
3
|
||||||
|
|
||||||
$ echo '"foo" + "bar"' | nix-instantiate --eval-only --xml -
|
$ nix-instantiate --eval-only --xml -E '1 + 2'
|
||||||
<![CDATA[<?xml version='1.0' encoding='utf-8'?>
|
<![CDATA[<?xml version='1.0' encoding='utf-8'?>
|
||||||
<expr>
|
<expr>
|
||||||
<string value="foobar" />
|
<int value="3" />
|
||||||
</expr>]]></screen>
|
</expr>]]></screen>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
@ -200,28 +212,28 @@ $ echo '"foo" + "bar"' | nix-instantiate --eval-only --xml -
|
||||||
<para>The difference between non-strict and strict evaluation:
|
<para>The difference between non-strict and strict evaluation:
|
||||||
|
|
||||||
<screen>
|
<screen>
|
||||||
$ echo 'rec { x = "foo"; y = x; }' | nix-instantiate --eval-only --xml -
|
$ nix-instantiate --eval-only --xml -E 'rec { x = "foo"; y = x; }'
|
||||||
<replaceable>...</replaceable><![CDATA[
|
<replaceable>...</replaceable><![CDATA[
|
||||||
<attr name="x">
|
<attr name="x">
|
||||||
<string value="foo" />
|
<string value="foo" />
|
||||||
</attr>
|
</attr>
|
||||||
<attr name="y">
|
<attr name="y">
|
||||||
<unevaluated />
|
<unevaluated />
|
||||||
</attr>]]>
|
</attr>]]>
|
||||||
<replaceable>...</replaceable></screen>
|
<replaceable>...</replaceable></screen>
|
||||||
|
|
||||||
Note that <varname>y</varname> is left unevaluated (the XML
|
Note that <varname>y</varname> is left unevaluated (the XML
|
||||||
representation doesn’t attempt to show non-normal forms).
|
representation doesn’t attempt to show non-normal forms).
|
||||||
|
|
||||||
<screen>
|
<screen>
|
||||||
$ echo 'rec { x = "foo"; y = x; }' | nix-instantiate --eval-only --xml --strict -
|
$ nix-instantiate --eval-only --xml --strict -E 'rec { x = "foo"; y = x; }'
|
||||||
<replaceable>...</replaceable><![CDATA[
|
<replaceable>...</replaceable><![CDATA[
|
||||||
<attr name="x">
|
<attr name="x">
|
||||||
<string value="foo" />
|
<string value="foo" />
|
||||||
</attr>
|
</attr>
|
||||||
<attr name="y">
|
<attr name="y">
|
||||||
<string value="foo" />
|
<string value="foo" />
|
||||||
</attr>]]>
|
</attr>]]>
|
||||||
<replaceable>...</replaceable></screen>
|
<replaceable>...</replaceable></screen>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
@ -236,6 +248,6 @@ $ echo 'rec { x = "foo"; y = x; }' | nix-instantiate --eval-only --xml --strict
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
||||||
|
|
||||||
</refentry>
|
</refentry>
|
||||||
|
|
|
@ -61,11 +61,11 @@ the derivation attribute
|
||||||
<programlisting>
|
<programlisting>
|
||||||
shellHook =
|
shellHook =
|
||||||
''
|
''
|
||||||
echo "Hello shell!"
|
echo "Hello shell"
|
||||||
'';
|
'';
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
will cause <command>nix-shell</command> to print <literal>Hello shell!</literal>.</para>
|
will cause <command>nix-shell</command> to print <literal>Hello shell</literal>.</para>
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
||||||
|
@ -132,11 +132,11 @@ interactive shell in which to build it:
|
||||||
|
|
||||||
<screen>
|
<screen>
|
||||||
$ nix-shell '<nixpkgs>' -A pan
|
$ nix-shell '<nixpkgs>' -A pan
|
||||||
$ unpackPhase
|
[nix-shell]$ unpackPhase
|
||||||
$ cd pan-*
|
[nix-shell]$ cd pan-*
|
||||||
$ configurePhase
|
[nix-shell]$ configurePhase
|
||||||
$ buildPhase
|
[nix-shell]$ buildPhase
|
||||||
$ ./pan/gui/pan
|
[nix-shell]$ ./pan/gui/pan
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
To clear the environment first, and do some additional automatic
|
To clear the environment first, and do some additional automatic
|
||||||
|
@ -147,6 +147,14 @@ $ nix-shell '<nixpkgs>' -A pan --pure \
|
||||||
--command 'export NIX_DEBUG=1; export NIX_CORES=8; return'
|
--command 'export NIX_DEBUG=1; export NIX_CORES=8; return'
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
|
Nix expressions can also be given on the command line. For instance,
|
||||||
|
the following starts a shell containing the packages
|
||||||
|
<literal>sqlite</literal> and <literal>libX11</literal>:
|
||||||
|
|
||||||
|
<screen>
|
||||||
|
$ nix-shell -E 'with import <nixpkgs> { }; runCommand "dummy" { buildInputs = [ sqlite xorg.libX11 ]; } ""'
|
||||||
|
</screen>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
|
@ -8,15 +8,15 @@
|
||||||
<variablelist xml:id="opt-common">
|
<variablelist xml:id="opt-common">
|
||||||
|
|
||||||
<varlistentry><term><option>--help</option></term>
|
<varlistentry><term><option>--help</option></term>
|
||||||
|
|
||||||
<listitem><para>Prints out a summary of the command syntax and
|
<listitem><para>Prints out a summary of the command syntax and
|
||||||
exits.</para></listitem>
|
exits.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry><term><option>--version</option></term>
|
<varlistentry><term><option>--version</option></term>
|
||||||
|
|
||||||
<listitem><para>Prints out the Nix version number on standard output
|
<listitem><para>Prints out the Nix version number on standard output
|
||||||
and exits.</para></listitem>
|
and exits.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<term><option>-v</option></term>
|
<term><option>-v</option></term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
||||||
<para>Increases the level of verbosity of diagnostic messages
|
<para>Increases the level of verbosity of diagnostic messages
|
||||||
printed on standard error. For each Nix operation, the information
|
printed on standard error. For each Nix operation, the information
|
||||||
printed on standard output is well-defined; any diagnostic
|
printed on standard output is well-defined; any diagnostic
|
||||||
|
@ -37,18 +37,18 @@
|
||||||
following verbosity levels exist:</para>
|
following verbosity levels exist:</para>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
|
||||||
<varlistentry><term>0</term>
|
<varlistentry><term>0</term>
|
||||||
<listitem><para>“Errors only”: only print messages
|
<listitem><para>“Errors only”: only print messages
|
||||||
explaining why the Nix invocation failed.</para></listitem>
|
explaining why the Nix invocation failed.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry><term>1</term>
|
<varlistentry><term>1</term>
|
||||||
<listitem><para>“Informational”: print
|
<listitem><para>“Informational”: print
|
||||||
<emphasis>useful</emphasis> messages about what Nix is doing.
|
<emphasis>useful</emphasis> messages about what Nix is doing.
|
||||||
This is the default.</para></listitem>
|
This is the default.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry><term>2</term>
|
<varlistentry><term>2</term>
|
||||||
<listitem><para>“Talkative”: print more informational
|
<listitem><para>“Talkative”: print more informational
|
||||||
messages.</para></listitem>
|
messages.</para></listitem>
|
||||||
|
@ -68,11 +68,11 @@
|
||||||
<listitem><para>“Vomit”: print vast amounts of debug
|
<listitem><para>“Vomit”: print vast amounts of debug
|
||||||
information.</para></listitem>
|
information.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
builder's standard output and error are always written to a log file
|
builder's standard output and error are always written to a log file
|
||||||
in
|
in
|
||||||
<filename><replaceable>prefix</replaceable>/nix/var/log/nix</filename>.</para></listitem>
|
<filename><replaceable>prefix</replaceable>/nix/var/log/nix</filename>.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
configuration setting, which itself defaults to
|
configuration setting, which itself defaults to
|
||||||
<literal>1</literal>. A higher value is useful on SMP systems or to
|
<literal>1</literal>. A higher value is useful on SMP systems or to
|
||||||
exploit I/O latency.</para></listitem>
|
exploit I/O latency.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
configuration setting, if set, or <literal>1</literal> otherwise.
|
configuration setting, if set, or <literal>1</literal> otherwise.
|
||||||
The value <literal>0</literal> means that the builder should use all
|
The value <literal>0</literal> means that the builder should use all
|
||||||
available CPU cores in the system.</para></listitem>
|
available CPU cores in the system.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
derivation itself. Without this option, Nix stops if any build
|
derivation itself. Without this option, Nix stops if any build
|
||||||
fails (except for builds of substitutes), possibly killing builds in
|
fails (except for builds of substitutes), possibly killing builds in
|
||||||
progress (in case of parallel or distributed builds).</para></listitem>
|
progress (in case of parallel or distributed builds).</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@
|
||||||
resources).</para>
|
resources).</para>
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
<listitem><para>When this option is used, no attempt is made to open
|
<listitem><para>When this option is used, no attempt is made to open
|
||||||
the Nix database. Most Nix operations do need database access, so
|
the Nix database. Most Nix operations do need database access, so
|
||||||
those operations will fail.</para></listitem>
|
those operations will fail.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,12 +247,12 @@
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,10 +310,10 @@
|
||||||
<varlistentry xml:id="opt-attr"><term><option>--attr</option> / <option>-A</option>
|
<varlistentry xml:id="opt-attr"><term><option>--attr</option> / <option>-A</option>
|
||||||
<replaceable>attrPath</replaceable></term>
|
<replaceable>attrPath</replaceable></term>
|
||||||
|
|
||||||
<listitem><para>In <command>nix-env</command>,
|
<listitem><para>Select an attribute from the top-level Nix
|
||||||
<command>nix-instantiate</command> and <command>nix-build</command>,
|
expression being evaluated. (<command>nix-env</command>,
|
||||||
<option>--attr</option> allows you to select an attribute from the
|
<command>nix-instantiate</command>, <command>nix-build</command> and
|
||||||
top-level Nix expression being evaluated. The <emphasis>attribute
|
<command>nix-shell</command> only.) The <emphasis>attribute
|
||||||
path</emphasis> <replaceable>attrPath</replaceable> is a sequence of
|
path</emphasis> <replaceable>attrPath</replaceable> is a sequence of
|
||||||
attribute names separated by dots. For instance, given a top-level
|
attribute names separated by dots. For instance, given a top-level
|
||||||
Nix expression <replaceable>e</replaceable>, the attribute path
|
Nix expression <replaceable>e</replaceable>, the attribute path
|
||||||
|
@ -333,8 +333,18 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
<varlistentry><term><option>--expr</option> / <option>-E</option></term>
|
||||||
|
|
||||||
|
<listitem><para>Interpret the command line arguments as a list of
|
||||||
|
Nix expressions to be parsed and evaluated, rather than as a list
|
||||||
|
of file names of Nix expressions.
|
||||||
|
(<command>nix-instantiate</command>, <command>nix-build</command>
|
||||||
|
and <command>nix-shell</command> only.)</para></listitem>
|
||||||
|
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry><term><option>--show-trace</option></term>
|
<varlistentry><term><option>--show-trace</option></term>
|
||||||
|
|
||||||
<listitem><para>Causes Nix to print out a stack trace in case of Nix
|
<listitem><para>Causes Nix to print out a stack trace in case of Nix
|
||||||
expression evaluation errors.</para></listitem>
|
expression evaluation errors.</para></listitem>
|
||||||
|
|
||||||
|
@ -342,23 +352,23 @@
|
||||||
|
|
||||||
|
|
||||||
<varlistentry><term><option>-I</option> <replaceable>path</replaceable></term>
|
<varlistentry><term><option>-I</option> <replaceable>path</replaceable></term>
|
||||||
|
|
||||||
<listitem><para>Add a path to the Nix expression search path. This
|
<listitem><para>Add a path to the Nix expression search path. This
|
||||||
option may be given multiple times. See the <envar>NIX_PATH</envar>
|
option may be given multiple times. See the <envar>NIX_PATH</envar>
|
||||||
environment variable for information on the semantics of the Nix
|
environment variable for information on the semantics of the Nix
|
||||||
search path. Paths added through <option>-I</option> take
|
search path. Paths added through <option>-I</option> take
|
||||||
precedence over <envar>NIX_PATH</envar>.</para></listitem>
|
precedence over <envar>NIX_PATH</envar>.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry><term><option>--option</option> <replaceable>name</replaceable> <replaceable>value</replaceable></term>
|
<varlistentry><term><option>--option</option> <replaceable>name</replaceable> <replaceable>value</replaceable></term>
|
||||||
|
|
||||||
<listitem><para>Set the Nix configuration option
|
<listitem><para>Set the Nix configuration option
|
||||||
<replaceable>name</replaceable> to <replaceable>value</replaceable>.
|
<replaceable>name</replaceable> to <replaceable>value</replaceable>.
|
||||||
This overrides settings in the Nix configuration file (see
|
This overrides settings in the Nix configuration file (see
|
||||||
<citerefentry><refentrytitle>nix.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>).</para></listitem>
|
<citerefentry><refentrytitle>nix.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>).</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ my $dryRun = 0;
|
||||||
my $verbose = 0;
|
my $verbose = 0;
|
||||||
my $runEnv = $0 =~ /nix-shell$/;
|
my $runEnv = $0 =~ /nix-shell$/;
|
||||||
my $pure = 0;
|
my $pure = 0;
|
||||||
|
my $fromArgs = 0;
|
||||||
|
|
||||||
my @instArgs = ();
|
my @instArgs = ();
|
||||||
my @buildArgs = ();
|
my @buildArgs = ();
|
||||||
|
@ -49,7 +50,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
$drvLink = "./derivation";
|
$drvLink = "./derivation";
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--no-out-link" or $arg eq "--no-link") {
|
elsif ($arg eq "--no-out-link" || $arg eq "--no-link") {
|
||||||
$outLink = "$tmpDir/result";
|
$outLink = "$tmpDir/result";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,13 +60,13 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
$drvLink = $ARGV[$n];
|
$drvLink = $ARGV[$n];
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--out-link" or $arg eq "-o") {
|
elsif ($arg eq "--out-link" || $arg eq "-o") {
|
||||||
$n++;
|
$n++;
|
||||||
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
||||||
$outLink = $ARGV[$n];
|
$outLink = $ARGV[$n];
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--attr" or $arg eq "-A" or $arg eq "-I") {
|
elsif ($arg eq "--attr" || $arg eq "-A" || $arg eq "-I") {
|
||||||
$n++;
|
$n++;
|
||||||
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
||||||
push @instArgs, ($arg, $ARGV[$n]);
|
push @instArgs, ($arg, $ARGV[$n]);
|
||||||
|
@ -91,7 +92,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
$n += 2;
|
$n += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--max-jobs" or $arg eq "-j" or $arg eq "--max-silent-time" or $arg eq "--log-type" or $arg eq "--cores" or $arg eq "--timeout") {
|
elsif ($arg eq "--max-jobs" || $arg eq "-j" || $arg eq "--max-silent-time" || $arg eq "--log-type" || $arg eq "--c||es" || $arg eq "--timeout") {
|
||||||
$n++;
|
$n++;
|
||||||
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
||||||
push @buildArgs, ($arg, $ARGV[$n]);
|
push @buildArgs, ($arg, $ARGV[$n]);
|
||||||
|
@ -110,7 +111,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
@exprs = ("-");
|
@exprs = ("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--verbose" or substr($arg, 0, 2) eq "-v") {
|
elsif ($arg eq "--verbose" || substr($arg, 0, 2) eq "-v") {
|
||||||
push @buildArgs, $arg;
|
push @buildArgs, $arg;
|
||||||
push @instArgs, $arg;
|
push @instArgs, $arg;
|
||||||
$verbose = 1;
|
$verbose = 1;
|
||||||
|
@ -144,6 +145,11 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
elsif ($arg eq "--pure") { $pure = 1; }
|
elsif ($arg eq "--pure") { $pure = 1; }
|
||||||
elsif ($arg eq "--impure") { $pure = 0; }
|
elsif ($arg eq "--impure") { $pure = 0; }
|
||||||
|
|
||||||
|
elsif ($arg eq "--expr" || $arg eq "-E") {
|
||||||
|
$fromArgs = 1;
|
||||||
|
push @instArgs, "--expr";
|
||||||
|
}
|
||||||
|
|
||||||
elsif (substr($arg, 0, 1) eq "-") {
|
elsif (substr($arg, 0, 1) eq "-") {
|
||||||
push @buildArgs, $arg;
|
push @buildArgs, $arg;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +159,10 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@exprs = ("shell.nix") if scalar @exprs == 0 && $runEnv && -e "shell.nix";
|
if (!$fromArgs) {
|
||||||
@exprs = ("default.nix") if scalar @exprs == 0;
|
@exprs = ("shell.nix") if scalar @exprs == 0 && $runEnv && -e "shell.nix";
|
||||||
|
@exprs = ("default.nix") if scalar @exprs == 0;
|
||||||
|
}
|
||||||
|
|
||||||
$ENV{'IN_NIX_SHELL'} = 1 if $runEnv;
|
$ENV{'IN_NIX_SHELL'} = 1 if $runEnv;
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ void run(Strings args)
|
||||||
EvalState state;
|
EvalState state;
|
||||||
Strings files;
|
Strings files;
|
||||||
bool readStdin = false;
|
bool readStdin = false;
|
||||||
|
bool fromArgs = false;
|
||||||
bool findFile = false;
|
bool findFile = false;
|
||||||
bool evalOnly = false;
|
bool evalOnly = false;
|
||||||
bool parseOnly = false;
|
bool parseOnly = false;
|
||||||
|
@ -104,6 +105,8 @@ void run(Strings args)
|
||||||
|
|
||||||
if (arg == "-")
|
if (arg == "-")
|
||||||
readStdin = true;
|
readStdin = true;
|
||||||
|
else if (arg == "--expr" || arg == "-E")
|
||||||
|
fromArgs = true;
|
||||||
else if (arg == "--eval-only")
|
else if (arg == "--eval-only")
|
||||||
evalOnly = true;
|
evalOnly = true;
|
||||||
else if (arg == "--read-write-mode")
|
else if (arg == "--read-write-mode")
|
||||||
|
@ -162,11 +165,13 @@ void run(Strings args)
|
||||||
Expr * e = parseStdin(state);
|
Expr * e = parseStdin(state);
|
||||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||||
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
||||||
} else if (files.empty())
|
} else if (files.empty() && !fromArgs)
|
||||||
files.push_back("./default.nix");
|
files.push_back("./default.nix");
|
||||||
|
|
||||||
foreach (Strings::iterator, i, files) {
|
foreach (Strings::iterator, i, files) {
|
||||||
Expr * e = state.parseExprFromFile(resolveExprPath(lookupFileArg(state, *i)));
|
Expr * e = fromArgs
|
||||||
|
? state.parseExprFromString(*i, absPath("."))
|
||||||
|
: state.parseExprFromFile(resolveExprPath(lookupFileArg(state, *i)));
|
||||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||||
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue