bscpkgs/garlic/stages/trebuchet.nix

41 lines
763 B
Nix
Raw Normal View History

2020-10-09 01:48:20 +08:00
{
stdenv
2020-10-09 22:13:16 +08:00
, garlicTools
2020-10-09 01:48:20 +08:00
}:
{
2020-10-09 22:13:16 +08:00
nextStage
2020-10-09 01:48:20 +08:00
, nixPrefix
, sshHost
2020-10-09 01:48:20 +08:00
}:
2020-10-10 02:28:00 +08:00
with garlicTools;
2020-10-09 22:13:16 +08:00
let
2020-10-10 02:28:00 +08:00
program = stageProgram nextStage;
2020-10-09 22:13:16 +08:00
in
2020-10-09 01:48:20 +08:00
stdenv.mkDerivation {
name = "trebuchet";
phases = [ "installPhase" ];
preferLocalBuild = true;
dontPatchShebangs = true;
2020-10-10 02:28:00 +08:00
inherit nextStage;
2020-10-09 01:48:20 +08:00
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.
2020-10-13 19:00:59 +08:00
# This trebuchet launches:
# ${nextStage}
2020-10-10 02:28:00 +08:00
# ${nextStage.nextStage}
2020-10-13 19:00:59 +08:00
# ${nextStage.nextStage.nextStage}
2020-10-09 01:48:20 +08:00
2020-10-13 19:00:59 +08:00
# Take a look at ${program}
# to see what is being executed.
ssh ${sshHost} ${nixPrefix}${program}
2020-10-09 01:48:20 +08:00
EOF
chmod +x $out
'';
}