From 99ef620c8c453949719c45229a8bd4f1cd5a66a8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 5 Oct 2006 20:41:57 +0000 Subject: [PATCH] * Documented nix-instantiate --xml, --strict. * Added an example to the nix-build section. --- doc/manual/nix-build.xml | 16 +++++ doc/manual/nix-instantiate.xml | 90 ++++++++++++++++++++++++-- doc/manual/opt-common.xml | 2 +- doc/manual/writing-nix-expressions.xml | 2 +- 4 files changed, 104 insertions(+), 6 deletions(-) diff --git a/doc/manual/nix-build.xml b/doc/manual/nix-build.xml index dc4a5ac874..bb64085f83 100644 --- a/doc/manual/nix-build.xml +++ b/doc/manual/nix-build.xml @@ -117,4 +117,20 @@ except for and / +Examples + + +$ nix-build pkgs/top-level/all-packages.nix -A firefox +store derivation is /nix/store/qybprl8sz2lc...-firefox-1.5.0.7.drv +/nix/store/d18hyl92g30l...-firefox-1.5.0.7 + +$ ls -l result +lrwxrwxrwx ... result -> /nix/store/d18hyl92g30l...-firefox-1.5.0.7 + +$ ls ./result/bin/ +firefox firefox-config + + + + diff --git a/doc/manual/nix-instantiate.xml b/doc/manual/nix-instantiate.xml index 5f38743081..71c8d3ec37 100644 --- a/doc/manual/nix-instantiate.xml +++ b/doc/manual/nix-instantiate.xml @@ -20,10 +20,16 @@ path - - - - + + + + + + + + + + files @@ -85,6 +91,31 @@ common options. + + + When used with and + , print the resulting expression as an + XML representation of the abstract syntax tree rather than as an + ATerm. The schema is the same as that used by the toXML + built-in. + + + + + + When used with , + recursively evaluate list elements and attributes. Normally, such + sub-expressions are left unevaluated (since the Nix expression + language is lazy). + + This option can cause non-termination, because lazy + data structures can be infinitely large. + + + + + @@ -92,6 +123,9 @@ common options. Examples +Instantiating store derivations from a Nix expression, and +building them using nix-store: + $ nix-instantiate test.nix (instantiate) /nix/store/cigxbmvy6dzix98dxxh9b6shg7ar5bvs-perl-BerkeleyDB-0.26.drv @@ -104,6 +138,54 @@ $ ls -l /nix/store/qhqk4n8ci095g3sdp93x7rgwyh9rdvgk-perl-BerkeleyDB-0.26 dr-xr-xr-x 2 eelco users 4096 1970-01-01 01:00 lib ... + + +Parsing and evaluating Nix expressions: + + +$ echo '"foo" + "bar"' | nix-instantiate --parse-only - +OpPlus(Str("foo"),Str("bar")) + +$ echo '"foo" + "bar"' | nix-instantiate --eval-only - +Str("foobar") + +$ echo '"foo" + "bar"' | nix-instantiate --eval-only --xml - + + + +]]> + + + +The difference between non-strict and strict evaluation: + + +$ echo 'rec { x = "foo"; y = x; }' | nix-instantiate --eval-only --xml - +... + + + + + ]]> +... + +Note that y is left unevaluated (the XML +representation doesn’t attempt to show non-normal forms). + + +$ echo 'rec { x = "foo"; y = x; }' | nix-instantiate --eval-only --xml --strict - +... + + + + + ]]> +... + + + diff --git a/doc/manual/opt-common.xml b/doc/manual/opt-common.xml index 95e8f78d99..1d09fef955 100644 --- a/doc/manual/opt-common.xml +++ b/doc/manual/opt-common.xml @@ -286,4 +286,4 @@ - \ No newline at end of file + diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index cf590190ca..e8d84164e3 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -1769,7 +1769,7 @@ in foo - builtins.toXML e + builtins.toXML e Return a string containing an XML representation of e. The main application for