The unpack-channel.nix core function is in flux for 20.09

Once hydra and nixpkgs are on the same nix this we can settle on
the newer builtin-based src/nix-channel/unpack-channel.nix.
This commit is contained in:
Tyson Whitehead
2021-02-02 00:19:49 -05:00
parent c44bd5abc3
commit c4382fa872
2 changed files with 46 additions and 1 deletions

View File

@@ -81,7 +81,7 @@ in let
# The nix provided nix/unpack-channel.nix function extracts the nixpkgs from the channel, # The nix provided nix/unpack-channel.nix function extracts the nixpkgs from the channel,
# #
nixpkgs = nixpkgs =
( import <nix/unpack-channel.nix> rec { ( pkgs.callPackage ./unpack-channel.nix { } rec {
name = "nixos"; name = "nixos";
channelName = "${name}-${version}"; channelName = "${name}-${version}";
src = channel + /tarballs + "/${name}-${version}${nixpkgsVersion.suffix}.tar.xz"; src = channel + /tarballs + "/${name}-${version}${nixpkgsVersion.suffix}.tar.xz";

45
unpack-channel.nix Normal file
View File

@@ -0,0 +1,45 @@
# 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;
}