diff options
Diffstat (limited to 'corepkgs')
-rw-r--r-- | corepkgs/config.nix.in | 3 | ||||
-rw-r--r-- | corepkgs/nar.nix | 21 |
2 files changed, 17 insertions, 7 deletions
diff --git a/corepkgs/config.nix.in b/corepkgs/config.nix.in index 98924c4ef779..26e821d0e2d7 100644 --- a/corepkgs/config.nix.in +++ b/corepkgs/config.nix.in @@ -6,7 +6,8 @@ in { perl = "@perl@"; shell = "@shell@"; coreutils = "@coreutils@"; - bzip2 = fromEnv "NIX_BZIP2" "@bzip2@"; + bzip2 = "@bzip2@"; + xz = "@xz@"; tar = "@tar@"; tr = "@tr@"; curl = "@curl@"; 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; |