Add substituter install test

This commit is contained in:
Artemis Tosini 2024-07-17 06:22:57 +00:00
parent 78af1e1d88
commit cd42c70501
Signed by: artemist
GPG key ID: EE5227935FE3FF18

View file

@ -132,6 +132,33 @@ let
fi
'';
};
install-substituter = pkgs: let
rootPaths = binaryTarball.${pkgs.system}.passthru.rootPaths;
binaryCache = pkgs.mkBinaryCache { inherit rootPaths; };
targetArg = pkg: "--substitution-targets ${pkg.outPath}";
targetArgs = lib.concatMapStringsSep " " targetArg rootPaths;
in {
copyTarball = ''
scp -P 20022 $ssh_opts -r ${binaryCache} vagrant@localhost:binaryCache
'';
install = ''
python3 -m http.server -d binaryCache 8000 &
server_pid=$!
trap "kill $server_pid" EXIT
sleep 1
RUST_BACKTRACE="full" ./nix-installer install \
--use-substituters \
--substituters http://127.0.0.1:8000 \
--no-require-sigs \
${targetArgs} \
--no-confirm \
--logger pretty \
--log-directive lix_installer=info
'';
check = installCases.install-default.check;
uninstall = installCases.install-default.uninstall;
uninstallCheck = installCases.install-default.uninstallCheck;
};
install-no-start-daemon = {
install = ''
NIX_PATH=$(readlink -f nix.tar.xz)
@ -500,9 +527,13 @@ let
};
makeTest = imageName: testName: test:
let image = images.${imageName}; in
with (forSystem image.system ({ system, pkgs, ... }: pkgs));
makeTest = imageName: testName: testFunc:
let
image = images.${imageName};
pkgs = (forSystem image.system ({ system, pkgs, ... }: pkgs));
test = if builtins.isFunction testFunc then (testFunc pkgs) else testFunc;
in
with pkgs;
runCommand
"installer-test-${imageName}-${testName}"
{
@ -517,6 +548,8 @@ let
uninstallCheckScript = test.uninstallCheck;
installer = lix-installer-static;
binaryTarball = binaryTarball.${system};
copyTarball = test.copyTarball
or "scp -P 20022 $ssh_opts $binaryTarball/lix-*.tar.xz vagrant@localhost:nix.tar.xz";
}
''
shopt -s nullglob
@ -575,8 +608,9 @@ let
echo "Copying installer..."
scp -P 20022 $ssh_opts $installer/bin/lix-installer vagrant@localhost:nix-installer
ls $binaryTarball
echo "Copying nix tarball..."
scp -P 20022 $ssh_opts $binaryTarball/lix-*.tar.xz vagrant@localhost:nix.tar.xz
eval "$copyTarball"
echo "Running preinstall..."
$ssh "set -eux; $preinstallScript"