about summary refs log tree commit diff
path: root/corepkgs/nar.nix
diff options
context:
space:
mode:
Diffstat (limited to 'corepkgs/nar.nix')
-rw-r--r--corepkgs/nar.nix18
1 files changed, 13 insertions, 5 deletions
diff --git a/corepkgs/nar.nix b/corepkgs/nar.nix
index c5155dcc917c..cf8851d50978 100644
--- a/corepkgs/nar.nix
+++ b/corepkgs/nar.nix
@@ -6,29 +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.xz
+      dst=$out/tmp.nar.$ext
 
       set -o pipefail
-      nix-store --dump "$storePath" | ${xz} -9 > $dst
+      nix-store --dump "$storePath" | $compressor -9 > $dst
 
       hash=$(nix-hash --flat --type $hashAlgo --base32 $dst)
       echo -n $hash > $out/nar-compressed-hash
 
-      mv $dst $out/$hash.nar.xz
+      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;