about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-30T10·27+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-30T10·27+0100
commitdae5dc7ade60aa6a9a05e41133da7faebe6bdc1b (patch)
tree73dd25edb51c70422e4cb58df6ec885d6c461557 /tests
parent5c28943e8fd19d7eb55865d45d6dc61336aa04e9 (diff)
<nix/fetchurl.nix>: Support downloading and unpacking NARs
This removes the need to have multiple downloads in the stdenv
bootstrap process (like a separate busybox binary for Linux, or
curl/mkdir/sh/bzip2 for Darwin). Now all those files can be combined
into a single NAR.
Diffstat (limited to 'tests')
-rw-r--r--tests/fetchurl.nix6
-rw-r--r--tests/fetchurl.sh24
2 files changed, 21 insertions, 9 deletions
diff --git a/tests/fetchurl.nix b/tests/fetchurl.nix
deleted file mode 100644
index 2abcc039a832..000000000000
--- a/tests/fetchurl.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ filename, sha256 }:
-
-import <nix/fetchurl.nix> {
-  url = "file://${filename}";
-  inherit sha256;
-}
diff --git a/tests/fetchurl.sh b/tests/fetchurl.sh
index 6acc87eafca8..495d42a2568a 100644
--- a/tests/fetchurl.sh
+++ b/tests/fetchurl.sh
@@ -2,8 +2,26 @@ source common.sh
 
 clearStore
 
-hash=$(nix-hash --flat --type sha256 ./fetchurl.nix)
+hash=$(nix-hash --flat --type sha256 ./fetchurl.sh)
 
-outPath=$(nix-build ./fetchurl.nix --argstr filename $(pwd)/fetchurl.nix --argstr sha256 $hash --no-out-link)
+outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh --argstr sha256 $hash --no-out-link)
 
-cmp $outPath fetchurl.nix
+cmp $outPath fetchurl.sh
+
+rm -rf $TEST_ROOT/archive
+mkdir -p $TEST_ROOT/archive
+cp ./fetchurl.sh $TEST_ROOT/archive
+chmod +x $TEST_ROOT/archive/fetchurl.sh
+ln -s foo $TEST_ROOT/archive/symlink
+nar=$TEST_ROOT/archive.nar
+nix-store --dump $TEST_ROOT/archive > $nar
+
+hash=$(nix-hash --flat --type sha256 $nar)
+
+outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$nar --argstr sha256 $hash \
+          --arg unpack true --argstr name xyzzy --no-out-link)
+
+echo $outPath | grep -q 'xyzzy'
+
+test -x $outPath/fetchurl.sh
+test -L $outPath/symlink