1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-10 08:53:55 +02:00

nix eval: Add option to write a directory

This is useful for generating the nix manpages, but it may have other
applications (like generating configuration files without a Nix store).
This commit is contained in:
Eelco Dolstra 2020-12-02 21:25:32 +01:00
parent 148608ba6d
commit df552a2645
2 changed files with 59 additions and 4 deletions

View file

@ -16,3 +16,11 @@ nix eval --expr 'assert 1 + 2 == 3; true'
[[ $(nix eval --impure --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; })).x") == 123 ]]
(! nix eval --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; })).x")
nix eval --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; sha256 = \"$(nix hash-file pure-eval.nix --type sha256)\"; })).x"
rm -rf $TEST_ROOT/eval-out
nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ x = "foo" + "bar"; y = { z = "bla"; }; }'
[[ $(cat $TEST_ROOT/eval-out/x) = foobar ]]
[[ $(cat $TEST_ROOT/eval-out/y/z) = bla ]]
rm -rf $TEST_ROOT/eval-out
(! nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ "." = "bla"; }')