2012-01-03 02:16:29 +02:00
|
|
|
|
with import <nix/config.nix>;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
builder = builtins.toFile "nar.sh"
|
|
|
|
|
''
|
|
|
|
|
export PATH=${nixBinDir}:${coreutils}
|
|
|
|
|
|
|
|
|
|
echo "packing ‘$storePath’..."
|
|
|
|
|
mkdir $out
|
2012-06-29 21:26:31 +03:00
|
|
|
|
dst=$out/tmp.nar.xz
|
2012-01-03 02:16:29 +02:00
|
|
|
|
|
|
|
|
|
set -o pipefail
|
2012-06-29 21:26:31 +03:00
|
|
|
|
nix-store --dump "$storePath" | ${xz} -9 > $dst
|
2012-01-03 02:16:29 +02:00
|
|
|
|
|
2012-06-29 21:26:31 +03:00
|
|
|
|
hash=$(nix-hash --flat --type $hashAlgo --base32 $dst)
|
|
|
|
|
echo -n $hash > $out/nar-compressed-hash
|
2012-01-03 02:16:29 +02:00
|
|
|
|
|
2012-06-29 21:26:31 +03:00
|
|
|
|
mv $dst $out/$hash.nar.xz
|
2012-01-03 02:16:29 +02:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
2012-04-14 19:48:11 +03:00
|
|
|
|
{ storePath, hashAlgo }:
|
2012-01-03 02:16:29 +02:00
|
|
|
|
|
|
|
|
|
derivation {
|
|
|
|
|
name = "nar";
|
2012-04-14 19:48:11 +03:00
|
|
|
|
system = builtins.currentSystem;
|
2012-01-03 02:16:29 +02:00
|
|
|
|
builder = shell;
|
|
|
|
|
args = [ "-e" builder ];
|
2012-04-14 19:48:11 +03:00
|
|
|
|
inherit storePath hashAlgo;
|
2012-05-10 05:14:36 +03:00
|
|
|
|
|
|
|
|
|
# Don't build in a chroot because Nix's dependencies may not be there.
|
|
|
|
|
__noChroot = true;
|
2012-01-03 02:16:29 +02:00
|
|
|
|
}
|