Once hydra and nixpkgs are on the same nix this we can settle on the newer builtin-based src/nix-channel/unpack-channel.nix.
46 lines
1.1 KiB
Nix
46 lines
1.1 KiB
Nix
# Hydra runs the newer nix which doesn't have corepkgs/unpack-channel.nix. The nix-daemon runs the older nix which
|
|
# doesn't have builtins:unpack-channel. This means
|
|
#
|
|
# - for now we need to provide the older corepkgs/unpack-channel.nix
|
|
# - in the future we should switch to src/nix-channel/unpack-channel.nix
|
|
|
|
{ bash, coreutils, gnutar, xz, gzip, bzip2 }:
|
|
|
|
let
|
|
|
|
tarFlags = "--warning=no-timestamp";
|
|
|
|
builder = builtins.toFile "unpack-channel.sh"
|
|
''
|
|
mkdir $out
|
|
cd $out
|
|
xzpat="\.xz\$"
|
|
gzpat="\.gz\$"
|
|
if [[ "$src" =~ $xzpat ]]; then
|
|
xz -d < $src | tar xf - ${tarFlags}
|
|
elif [[ "$src" =~ $gzpat ]]; then
|
|
gzip -d < $src | tar xf - ${tarFlags}
|
|
else
|
|
bzip2 -d < $src | tar xf - ${tarFlags}
|
|
fi
|
|
if [ * != $channelName ]; then
|
|
mv * $out/$channelName
|
|
fi
|
|
'';
|
|
|
|
in
|
|
|
|
{ name, channelName, src }:
|
|
|
|
derivation {
|
|
system = builtins.currentSystem;
|
|
builder = "${bash}/bin/sh";
|
|
args = [ "-e" builder ];
|
|
inherit name channelName src;
|
|
|
|
PATH = "${coreutils}/bin:${gnutar}/bin:${xz}/bin:${gzip}/bin:${bzip2}/bin";
|
|
|
|
# No point in doing this remotely.
|
|
preferLocalBuild = true;
|
|
}
|