about summary refs log tree commit diff
path: root/corepkgs
diff options
context:
space:
mode:
Diffstat (limited to 'corepkgs')
-rw-r--r--corepkgs/Makefile.am2
-rw-r--r--corepkgs/config.nix.in4
-rw-r--r--corepkgs/nar.nix21
-rw-r--r--corepkgs/unpack-channel.nix25
-rw-r--r--corepkgs/unpack-channel.sh4
5 files changed, 40 insertions, 16 deletions
diff --git a/corepkgs/Makefile.am b/corepkgs/Makefile.am
index 4b0b8860be68..111b667d0b58 100644
--- a/corepkgs/Makefile.am
+++ b/corepkgs/Makefile.am
@@ -1,6 +1,6 @@
 all-local: config.nix
 
-files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh derivation.nix fetchurl.nix \
+files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix derivation.nix fetchurl.nix \
 	imported-drv-to-derivation.nix
 
 install-exec-local:
diff --git a/corepkgs/config.nix.in b/corepkgs/config.nix.in
index 98924c4ef779..6f6ec6de1a30 100644
--- a/corepkgs/config.nix.in
+++ b/corepkgs/config.nix.in
@@ -6,8 +6,10 @@ in {
   perl = "@perl@";
   shell = "@shell@";
   coreutils = "@coreutils@";
-  bzip2 = fromEnv "NIX_BZIP2" "@bzip2@";
+  bzip2 = "@bzip2@";
+  xz = "@xz@";
   tar = "@tar@";
+  tarFlags = "@tarFlags@";
   tr = "@tr@";
   curl = "@curl@";
   nixBinDir = fromEnv "NIX_BIN_DIR" "@bindir@";
diff --git a/corepkgs/nar.nix b/corepkgs/nar.nix
index 4747dc31def2..fc9687af776c 100644
--- a/corepkgs/nar.nix
+++ b/corepkgs/nar.nix
@@ -6,28 +6,37 @@ let
     ''
       export PATH=${nixBinDir}:${coreutils}
 
+      if [ $compressionType = "xz" ]; then
+        ext=xz
+        compressor="${xz} -9"
+      else
+        ext=bz2
+        compressor="${bzip2}"
+      fi
+
       echo "packing ‘$storePath’..."
       mkdir $out
-      dst=$out/tmp.nar.bz2
+      dst=$out/tmp.nar.$ext
 
       set -o pipefail
-      nix-store --dump "$storePath" | ${bzip2} > $dst
+      nix-store --dump "$storePath" | $compressor > $dst
 
-      nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash
+      hash=$(nix-hash --flat --type $hashAlgo --base32 $dst)
+      echo -n $hash > $out/nar-compressed-hash
 
-      mv $out/tmp.nar.bz2 $out/$(cat $out/narbz2-hash).nar.bz2
+      mv $dst $out/$hash.nar.$ext
     '';
 
 in
 
-{ storePath, hashAlgo }:
+{ storePath, hashAlgo, compressionType }:
 
 derivation {
   name = "nar";
   system = builtins.currentSystem;
   builder = shell;
   args = [ "-e" builder ];
-  inherit storePath hashAlgo;
+  inherit storePath hashAlgo compressionType;
 
   # Don't build in a chroot because Nix's dependencies may not be there.
   __noChroot = true;
diff --git a/corepkgs/unpack-channel.nix b/corepkgs/unpack-channel.nix
index 245430ab0feb..57d5a09a076a 100644
--- a/corepkgs/unpack-channel.nix
+++ b/corepkgs/unpack-channel.nix
@@ -1,14 +1,31 @@
 with import <nix/config.nix>;
 
-{ name, channelName, src }:
+let
+
+  builder = builtins.toFile "unpack-channel.sh"
+    ''
+      mkdir $out
+      cd $out
+      ${bzip2} -d < $src | ${tar} xf - --warning=no-timestamp
+      mv * $out/$channelName
+      if [ -n "$binaryCacheURL" ]; then
+        mkdir $out/binary-caches
+        echo -n "$binaryCacheURL" > $out/binary-caches/$channelName
+      fi
+    '';
+
+in
+
+{ name, channelName, src, binaryCacheURL ? "" }:
 
 derivation {
   system = builtins.currentSystem;
   builder = shell;
-  args = [ "-e" ./unpack-channel.sh ];
-  inherit name channelName src bzip2 tar tr;
+  args = [ "-e" builder ];
+  inherit name channelName src binaryCacheURL;
+
   PATH = "${nixBinDir}:${coreutils}";
-  
+
   # No point in doing this remotely.
   preferLocalBuild = true;
 
diff --git a/corepkgs/unpack-channel.sh b/corepkgs/unpack-channel.sh
deleted file mode 100644
index f42b0870ae18..000000000000
--- a/corepkgs/unpack-channel.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-mkdir $out
-cd $out
-$bzip2 -d < $src | $tar xf -
-mv * $out/$channelName