* Simplification.

This commit is contained in:
Eelco Dolstra 2006-03-01 12:51:18 +00:00
parent a4c63c6e8e
commit 84c4631221
21 changed files with 77 additions and 67 deletions

View file

@ -1,5 +1,7 @@
TESTS_ENVIRONMENT = $(SHELL) -e TESTS_ENVIRONMENT = $(SHELL) -e
extra1 = $(shell pwd)/test-tmp/shared
simple.sh: simple.nix simple.sh: simple.nix
dependencies.sh: dependencies.nix dependencies.sh: dependencies.nix
locking.sh: locking.nix locking.sh: locking.nix

View file

@ -2,11 +2,11 @@ source common.sh
export NIX_BUILD_HOOK="build-hook.hook.sh" export NIX_BUILD_HOOK="build-hook.hook.sh"
drvPath=$($TOP/src/nix-instantiate/nix-instantiate build-hook.nix) drvPath=$($nixinstantiate build-hook.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -quf "$drvPath") outPath=$($nixstore -quf "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"

View file

@ -24,3 +24,8 @@ export aterm_bin=@aterm_bin@
export dot=@dot@ export dot=@dot@
export version=@version@ export version=@version@
export nixinstantiate=$TOP/src/nix-instantiate/nix-instantiate
export nixstore=$TOP/src/nix-store/nix-store
export nixenv=$TOP/src/nix-env/nix-env
export nixhash=$TOP/src/nix-hash/nix-hash

View file

@ -1,35 +1,35 @@
source common.sh source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix) drvPath=$($nixinstantiate dependencies.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
$TOP/src/nix-store/nix-store -q --tree "$drvPath" | grep ' +---.*builder1.sh' $TOP/src/nix-store/nix-store -q --tree "$drvPath" | grep ' +---.*builder1.sh'
# Test Graphviz graph generation. # Test Graphviz graph generation.
$TOP/src/nix-store/nix-store -q --graph "$drvPath" > $TEST_ROOT/graph $nixstore -q --graph "$drvPath" > $TEST_ROOT/graph
if test -n "$dot"; then if test -n "$dot"; then
# Does it parse? # Does it parse?
$dot < $TEST_ROOT/graph $dot < $TEST_ROOT/graph
fi fi
outPath=$($TOP/src/nix-store/nix-store -rvv "$drvPath") outPath=$($nixstore -rvv "$drvPath")
# Test Graphviz graph generation. # Test Graphviz graph generation.
$TOP/src/nix-store/nix-store -q --graph "$outPath" > $TEST_ROOT/graph $nixstore -q --graph "$outPath" > $TEST_ROOT/graph
if test -n "$dot"; then if test -n "$dot"; then
# Does it parse? # Does it parse?
$dot < $TEST_ROOT/graph $dot < $TEST_ROOT/graph
fi fi
$TOP/src/nix-store/nix-store -q --tree "$outPath" | grep '+---.*dependencies-input-2' $nixstore -q --tree "$outPath" | grep '+---.*dependencies-input-2'
echo "output path is $outPath" echo "output path is $outPath"
text=$(cat "$outPath"/foobar) text=$(cat "$outPath"/foobar)
if test "$text" != "FOOBAR"; then exit 1; fi if test "$text" != "FOOBAR"; then exit 1; fi
deps=$($TOP/src/nix-store/nix-store -quR "$drvPath") deps=$($nixstore -quR "$drvPath")
echo "output closure contains $deps" echo "output closure contains $deps"
@ -43,8 +43,8 @@ if echo "$deps" | grep -q "dependencies-input-1"; then exit 1; fi
input2OutPath=$(echo "$deps" | grep "dependencies-input-2") input2OutPath=$(echo "$deps" | grep "dependencies-input-2")
# The referrers closure of input-2 should include outPath. # The referrers closure of input-2 should include outPath.
$TOP/src/nix-store/nix-store -q --referrers-closure "$input2OutPath" | grep "$outPath" $nixstore -q --referrers-closure "$input2OutPath" | grep "$outPath"
# Check that the derivers are set properly. # Check that the derivers are set properly.
test $($TOP/src/nix-store/nix-store -q --deriver "$outPath") = "$drvPath" test $($nixstore -q --deriver "$outPath") = "$drvPath"
$TOP/src/nix-store/nix-store -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv" $nixstore -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv"

View file

@ -1,16 +1,16 @@
source common.sh source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate fallback.nix) drvPath=$($nixinstantiate fallback.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -q --fallback "$drvPath") outPath=$($nixstore -q --fallback "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"
# Register a non-existant substitute # Register a non-existant substitute
(echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $TOP/src/nix-store/nix-store --register-substitutes (echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $nixstore --register-substitutes
# Build the derivation # Build the derivation
$TOP/src/nix-store/nix-store -r --fallback "$drvPath" $nixstore -r --fallback "$drvPath"
text=$(cat "$outPath"/hello) text=$(cat "$outPath"/hello)
if test "$text" != "Hello World!"; then exit 1; fi if test "$text" != "Hello World!"; then exit 1; fi

View file

@ -1,19 +1,19 @@
source common.sh source common.sh
drvPath1=$($TOP/src/nix-instantiate/nix-instantiate gc-concurrent.nix) drvPath1=$($nixinstantiate gc-concurrent.nix)
outPath1=$($TOP/src/nix-store/nix-store -q $drvPath1) outPath1=$($nixstore -q $drvPath1)
drvPath2=$($TOP/src/nix-instantiate/nix-instantiate gc-concurrent2.nix) drvPath2=$($nixinstantiate gc-concurrent2.nix)
outPath2=$($TOP/src/nix-store/nix-store -q $drvPath2) outPath2=$($nixstore -q $drvPath2)
ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo2 ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo2
# Start build #1 in the background. It starts immediately. # Start build #1 in the background. It starts immediately.
$TOP/src/nix-store/nix-store -rvv "$drvPath1" & $nixstore -rvv "$drvPath1" &
pid1=$! pid1=$!
# Start build #2 in the background after 3 seconds. # Start build #2 in the background after 3 seconds.
(sleep 3 && $TOP/src/nix-store/nix-store -rvv "$drvPath2") & (sleep 3 && $nixstore -rvv "$drvPath2") &
pid2=$! pid2=$!
# Run the garbage collector while the build is running. Note: the GC # Run the garbage collector while the build is running. Note: the GC

View file

@ -1,7 +1,7 @@
source common.sh source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix) drvPath=$($nixinstantiate dependencies.nix)
outPath=$($TOP/src/nix-store/nix-store -rvv "$drvPath") outPath=$($nixstore -rvv "$drvPath")
# Set a GC root. # Set a GC root.
ln -s $outPath "$NIX_STATE_DIR"/gcroots/foo ln -s $outPath "$NIX_STATE_DIR"/gcroots/foo

View file

@ -2,7 +2,7 @@ source common.sh
try () { try () {
echo -n "$2" > $TEST_ROOT/vector echo -n "$2" > $TEST_ROOT/vector
hash=$($TOP/src/nix-hash/nix-hash $EXTRA --flat --type "$1" $TEST_ROOT/vector) hash=$($nixhash $EXTRA --flat --type "$1" $TEST_ROOT/vector)
if test "$hash" != "$3"; then if test "$hash" != "$3"; then
echo "hash $1, expected $3, got $hash" echo "hash $1, expected $3, got $hash"
exit 1 exit 1
@ -28,7 +28,7 @@ try sha256 "abc" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s"
EXTRA= EXTRA=
try2 () { try2 () {
hash=$($TOP/src/nix-hash/nix-hash --type "$1" $TEST_ROOT/hash-path) hash=$($nixhash --type "$1" $TEST_ROOT/hash-path)
if test "$hash" != "$2"; then if test "$hash" != "$2"; then
echo "hash $1, expected $2, got $hash" echo "hash $1, expected $2, got $hash"
exit 1 exit 1

View file

@ -18,9 +18,9 @@ mkdir "$NIX_DB_DIR"
mkdir "$NIX_CONF_DIR" mkdir "$NIX_CONF_DIR"
mkdir $NIX_BIN_DIR mkdir $NIX_BIN_DIR
ln -s $TOP/src/nix-store/nix-store $NIX_BIN_DIR/ ln -s $nixstore $NIX_BIN_DIR/
ln -s $TOP/src/nix-instantiate/nix-instantiate $NIX_BIN_DIR/ ln -s $nixinstantiate $NIX_BIN_DIR/
ln -s $TOP/src/nix-hash/nix-hash $NIX_BIN_DIR/ ln -s $nixhash $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/
mkdir $NIX_BIN_DIR/nix mkdir $NIX_BIN_DIR/nix
@ -66,7 +66,7 @@ chmod +x tmp
mv tmp $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh mv tmp $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh
# Initialise the database. # Initialise the database.
$TOP/src/nix-store/nix-store --init $nixstore --init
# Did anything happen? # Did anything happen?
test -e "$NIX_DB_DIR"/validpaths test -e "$NIX_DB_DIR"/validpaths

View file

@ -5,7 +5,7 @@ fail=0
for i in lang/parse-fail-*.nix; do for i in lang/parse-fail-*.nix; do
echo "parsing $i (should fail)"; echo "parsing $i (should fail)";
i=$(basename $i .nix) i=$(basename $i .nix)
if $TOP/src/nix-instantiate/nix-instantiate --parse-only - < lang/$i.nix; then if $nixinstantiate --parse-only - < lang/$i.nix; then
echo "FAIL: $i shouldn't parse" echo "FAIL: $i shouldn't parse"
fail=1 fail=1
fi fi
@ -14,7 +14,7 @@ done
for i in lang/parse-okay-*.nix; do for i in lang/parse-okay-*.nix; do
echo "parsing $i (should succeed)"; echo "parsing $i (should succeed)";
i=$(basename $i .nix) i=$(basename $i .nix)
if ! $TOP/src/nix-instantiate/nix-instantiate --parse-only - < lang/$i.nix > lang/$i.ast; then if ! $nixinstantiate --parse-only - < lang/$i.nix > lang/$i.ast; then
echo "FAIL: $i should parse" echo "FAIL: $i should parse"
fail=1 fail=1
fi fi
@ -27,7 +27,7 @@ done
for i in lang/eval-fail-*.nix; do for i in lang/eval-fail-*.nix; do
echo "evaluating $i (should fail)"; echo "evaluating $i (should fail)";
i=$(basename $i .nix) i=$(basename $i .nix)
if $TOP/src/nix-instantiate/nix-instantiate --eval-only - < lang/$i.nix; then if $nixinstantiate --eval-only - < lang/$i.nix; then
echo "FAIL: $i shouldn't evaluate" echo "FAIL: $i shouldn't evaluate"
fail=1 fail=1
fi fi
@ -36,7 +36,7 @@ done
for i in lang/eval-okay-*.nix; do for i in lang/eval-okay-*.nix; do
echo "evaluating $i (should succeed)"; echo "evaluating $i (should succeed)";
i=$(basename $i .nix) i=$(basename $i .nix)
if ! $TOP/src/nix-instantiate/nix-instantiate --eval-only - < lang/$i.nix > lang/$i.out; then if ! $nixinstantiate --eval-only - < lang/$i.nix > lang/$i.out; then
echo "FAIL: $i should evaluate" echo "FAIL: $i should evaluate"
fail=1 fail=1
fi fi

View file

@ -1,17 +1,17 @@
source common.sh source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate locking.nix) drvPath=$($nixinstantiate locking.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
for i in 1 2 3 4 5; do for i in 1 2 3 4 5; do
echo "WORKER $i" echo "WORKER $i"
$TOP/src/nix-store/nix-store -rvv "$drvPath" & $nixstore -rvv "$drvPath" &
done done
sleep 5 sleep 5
outPath=$($TOP/src/nix-store/nix-store -qvvf "$drvPath") outPath=$($nixstore -qvvf "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"

View file

@ -3,10 +3,14 @@ source common.sh
# Tests miscellaneous commands. # Tests miscellaneous commands.
# Do all commands have help? # Do all commands have help?
$TOP/src/nix-env/nix-env --help | grep -q install $nixenv --help | grep -q install
$TOP/src/nix-store/nix-store --help | grep -q realise $nixstore --help | grep -q realise
$TOP/src/nix-instantiate/nix-instantiate --help | grep -q eval-only $nixinstantiate --help | grep -q eval-only
$TOP/src/nix-hash/nix-hash --help | grep -q base32 $nixhash --help | grep -q base32
# Can we ask for the version number? # Can we ask for the version number?
$TOP/src/nix-env/nix-env --version | grep "$version" $nixenv --version | grep "$version"
# Usage errors.
$nixenv --foo 2>&1 | grep "no operation"
$nixenv -q --foo 2>&1 | grep "unknown flag"

View file

@ -7,7 +7,7 @@ clearStore () {
mkdir "$NIX_STORE_DIR" mkdir "$NIX_STORE_DIR"
rm -rf "$NIX_DB_DIR" rm -rf "$NIX_DB_DIR"
mkdir "$NIX_DB_DIR" mkdir "$NIX_DB_DIR"
$TOP/src/nix-store/nix-store --init $nixstore --init
} }
pullCache () { pullCache () {
@ -18,11 +18,11 @@ pullCache () {
clearStore clearStore
pullCache pullCache
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix) drvPath=$($nixinstantiate dependencies.nix)
outPath=$($TOP/src/nix-store/nix-store -q $drvPath) outPath=$($nixstore -q $drvPath)
echo "building $outPath using substitutes..." echo "building $outPath using substitutes..."
$TOP/src/nix-store/nix-store -r $outPath $nixstore -r $outPath
cat $outPath/input-2/bar cat $outPath/input-2/bar
@ -30,10 +30,10 @@ clearStore
pullCache pullCache
echo "building $drvPath using substitutes..." echo "building $drvPath using substitutes..."
$TOP/src/nix-store/nix-store -r $drvPath $nixstore -r $drvPath
cat $outPath/input-2/bar cat $outPath/input-2/bar
# Check that the derivers are set properly. # Check that the derivers are set properly.
test $($TOP/src/nix-store/nix-store -q --deriver "$outPath") = "$drvPath" test $($nixstore -q --deriver "$outPath") = "$drvPath"
$TOP/src/nix-store/nix-store -q --deriver $(/bin/ls -l $outPath/input-2 | sed 's/.*->\ //') | grep -q -- "-input-2.drv" $nixstore -q --deriver $(/bin/ls -l $outPath/input-2 | sed 's/.*->\ //') | grep -q -- "-input-2.drv"

View file

@ -1,7 +1,7 @@
source common.sh source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix) drvPath=$($nixinstantiate dependencies.nix)
outPath=$($TOP/src/nix-store/nix-store -r $drvPath) outPath=$($nixstore -r $drvPath)
echo "pushing $drvPath" echo "pushing $drvPath"

View file

@ -1,10 +1,10 @@
source common.sh source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate parallel.nix) drvPath=$($nixinstantiate parallel.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -qfvv -j10000 "$drvPath") outPath=$($nixstore -qfvv -j10000 "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"

View file

@ -4,14 +4,14 @@ max=5000
reference=$NIX_STORE_DIR/abcdef reference=$NIX_STORE_DIR/abcdef
touch $reference touch $reference
(echo $reference && echo && echo 0) | $TOP/src/nix-store/nix-store --register-validity (echo $reference && echo && echo 0) | $nixstore --register-validity
echo "registering..." echo "registering..."
time for ((n = 0; n < $max; n++)); do time for ((n = 0; n < $max; n++)); do
storePath=$NIX_STORE_DIR/$n storePath=$NIX_STORE_DIR/$n
touch $storePath touch $storePath
(echo $storePath && echo && echo 1 && echo $reference) (echo $storePath && echo && echo 1 && echo $reference)
done | $TOP/src/nix-store/nix-store --register-validity done | $nixstore --register-validity
echo "collecting garbage..." echo "collecting garbage..."
time $TOP/src/nix-store/nix-store --gc 2> /dev/null time $nixstore --gc 2> /dev/null

View file

@ -1,10 +1,10 @@
source common.sh source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate simple.nix) drvPath=$($nixinstantiate simple.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -rvv "$drvPath") outPath=$($nixstore -rvv "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"

View file

@ -1,22 +1,22 @@
source common.sh source common.sh
# Instantiate. # Instantiate.
drvPath=$($TOP/src/nix-instantiate/nix-instantiate substitutes.nix) drvPath=$($nixinstantiate substitutes.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
# Find the output path. # Find the output path.
outPath=$($TOP/src/nix-store/nix-store -qvv "$drvPath") outPath=$($nixstore -qvv "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"
regSub() { regSub() {
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $TOP/src/nix-store/nix-store --register-substitutes (echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
} }
# Register a substitute for the output path. # Register a substitute for the output path.
regSub $outPath $(pwd)/substituter.sh regSub $outPath $(pwd)/substituter.sh
$TOP/src/nix-store/nix-store -rvv "$drvPath" $nixstore -rvv "$drvPath"
text=$(cat "$outPath"/hello) text=$(cat "$outPath"/hello)
if test "$text" != "Hallo Wereld"; then exit 1; fi if test "$text" != "Hallo Wereld"; then exit 1; fi

View file

@ -1,15 +1,15 @@
source common.sh source common.sh
# Instantiate. # Instantiate.
drvPath=$($TOP/src/nix-instantiate/nix-instantiate substitutes2.nix) drvPath=$($nixinstantiate substitutes2.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
# Find the output path. # Find the output path.
outPath=$($TOP/src/nix-store/nix-store -qvvvvv "$drvPath") outPath=$($nixstore -qvvvvv "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"
regSub() { regSub() {
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $TOP/src/nix-store/nix-store --register-substitutes (echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
} }
# Register a substitute for the output path. # Register a substitute for the output path.
@ -19,7 +19,7 @@ regSub $outPath $(pwd)/substituter.sh
# precedence over the previous one. It will fail. # precedence over the previous one. It will fail.
regSub $outPath $(pwd)/substituter2.sh regSub $outPath $(pwd)/substituter2.sh
$TOP/src/nix-store/nix-store -rvv "$drvPath" $nixstore -rvv "$drvPath"
text=$(cat "$outPath"/hello) text=$(cat "$outPath"/hello)
if test "$text" != "Hallo Wereld"; then exit 1; fi if test "$text" != "Hallo Wereld"; then exit 1; fi

View file

@ -1,6 +1,5 @@
source common.sh source common.sh
nixenv=$TOP/src/nix-env/nix-env
profiles="$NIX_STATE_DIR"/profiles profiles="$NIX_STATE_DIR"/profiles
# Query installed: should be empty. # Query installed: should be empty.

View file

@ -1,3 +1,3 @@
source common.sh source common.sh
$TOP/src/nix-store/nix-store --verify $nixstore --verify