1
0
Fork 0
forked from lix-project/lix
lix/corepkgs/unpack-channel.nix

43 lines
1,001 B
Nix
Raw Normal View History

with import <nix/config.nix>;
2012-08-01 20:34:17 +00:00
let
builder = builtins.toFile "unpack-channel.sh"
''
mkdir $out
cd $out
2013-05-14 13:10:14 +00:00
xzpat="\.xz\$"
gzpat="\.gz\$"
if [[ "$src" =~ $xzpat ]]; then
${xz} -d < $src | ${tar} xf - ${tarFlags}
2013-07-12 12:06:05 +00:00
elif [[ "$src" =~ $gzpat ]]; then
2013-05-14 13:10:14 +00:00
${gzip} -d < $src | ${tar} xf - ${tarFlags}
else
${bzip2} -d < $src | ${tar} xf - ${tarFlags}
fi
2012-08-01 20:34:17 +00:00
mv * $out/$channelName
if [ -n "$binaryCacheURL" ]; then
mkdir $out/binary-caches
echo -n "$binaryCacheURL" > $out/binary-caches/$channelName
fi
2012-08-01 20:34:17 +00:00
'';
in
{ name, channelName, src, binaryCacheURL ? "" }:
derivation {
system = builtins.currentSystem;
builder = shell;
2012-08-01 20:34:17 +00:00
args = [ "-e" builder ];
inherit name channelName src binaryCacheURL;
2012-08-01 20:34:17 +00:00
PATH = "${nixBinDir}:${coreutils}";
2012-08-01 20:34:17 +00:00
# No point in doing this remotely.
preferLocalBuild = true;
# Don't build in a chroot because Nix's dependencies may not be there.
__noChroot = true;
}