bscpkgs/garlic/stages/trebuchet.nix

44 lines
907 B
Nix
Raw Normal View History

2020-10-09 01:48:20 +08:00
{
stdenv
, nixtools
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
2020-10-09 22:13:16 +08:00
# FIXME: These two should be specified in the configuration of the machine
2020-10-09 01:48:20 +08:00
, sshHost ? "mn"
, targetCluster ? "mn4"
}:
2020-10-09 22:13:16 +08:00
let
program = garlicTools.stageProgram nextStage;
in
2020-10-09 01:48:20 +08:00
stdenv.mkDerivation {
name = "trebuchet";
phases = [ "installPhase" ];
preferLocalBuild = true;
dontPatchShebangs = true;
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.
# Take a look at ${program}
# to see what is being executed.
# $out
2020-10-09 22:13:16 +08:00
${nextStage.desc}
2020-10-09 01:48:20 +08:00
nixtools=${nixPrefix}${nixtools}/bin
runexp=\$nixtools/${targetCluster}/runexp
>&2 echo "Launching \"\$runexp ${program}\" in MN4"
ssh ${sshHost} \$runexp ${program}
EOF
chmod +x $out
'';
}