bscpkgs/garlic/stages/trebuchet.nix
2020-11-20 15:35:36 +01:00

44 lines
810 B
Nix

{
stdenv
, garlicTools
}:
{
nextStage
, nixPrefix
, sshHost
}:
with garlicTools;
let
program = stageProgram nextStage;
in
stdenv.mkDerivation {
name = "trebuchet";
phases = [ "installPhase" ];
preferLocalBuild = true;
dontPatchShebangs = true;
inherit nextStage;
experiment = getExperimentStage nextStage;
installPhase = ''
cat > $out <<EOF
#!/bin/sh -e
# Using the token @upload-to-mn@ we instruct the post-build hook to upload
# this script and it's closure to the MN4 cluster, so it can run there.
# This trebuchet launches:
# ${nextStage}
# ${nextStage.nextStage}
# ${nextStage.nextStage.nextStage}
# Take a look at ${program}
# to see what is being executed.
ssh ${sshHost} ${nixPrefix}${program}
EOF
chmod +x $out
'';
}