2023-12-03 23:29:15 +00:00
|
|
|
{ lib
|
|
|
|
, runCommand
|
|
|
|
, nix
|
2023-12-11 20:26:12 +00:00
|
|
|
, tarballs
|
2023-12-03 23:29:15 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
runCommand "installer-script" {
|
|
|
|
buildInputs = [ nix ];
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
|
|
|
|
# Converts /nix/store/50p3qk8k...-nix-2.4pre20201102_550e11f/bin/nix to 50p3qk8k.../bin/nix.
|
|
|
|
tarballPath() {
|
|
|
|
# Remove the store prefix
|
|
|
|
local path=''${1#${builtins.storeDir}/}
|
|
|
|
# Get the path relative to the derivation root
|
|
|
|
local rest=''${path#*/}
|
|
|
|
# Get the derivation hash
|
|
|
|
local drvHash=''${path%%-*}
|
|
|
|
echo "$drvHash/$rest"
|
|
|
|
}
|
|
|
|
|
|
|
|
substitute ${./install.in} $out/install \
|
|
|
|
${lib.concatMapStrings
|
2023-12-11 20:26:12 +00:00
|
|
|
(tarball: let
|
|
|
|
inherit (tarball.stdenv.hostPlatform) system;
|
|
|
|
in '' \
|
2023-12-03 23:29:15 +00:00
|
|
|
--replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${tarball}/*.tar.xz) \
|
|
|
|
--replace '@tarballPath_${system}@' $(tarballPath ${tarball}/*.tar.xz) \
|
|
|
|
''
|
|
|
|
)
|
2023-12-11 20:26:12 +00:00
|
|
|
tarballs
|
2023-12-03 23:29:15 +00:00
|
|
|
} --replace '@nixVersion@' ${nix.version}
|
|
|
|
|
|
|
|
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
|
|
|
|
''
|