bscpkgs/garlic/stages/control.nix

34 lines
545 B
Nix
Raw Normal View History

2020-08-11 18:05:43 +08:00
{
stdenv
2020-10-09 21:55:37 +08:00
, garlicTools
2020-08-11 18:05:43 +08:00
}:
2020-09-02 23:07:09 +08:00
{
2020-10-09 21:55:37 +08:00
nextStage
2020-09-03 22:18:50 +08:00
, loops ? 30
2020-09-02 23:07:09 +08:00
}:
2020-08-11 18:05:43 +08:00
2020-10-09 21:55:37 +08:00
with garlicTools;
2020-08-11 18:05:43 +08:00
stdenv.mkDerivation {
2020-09-02 23:07:09 +08:00
name = "control";
2020-08-11 18:05:43 +08:00
preferLocalBuild = true;
phases = [ "installPhase" ];
dontPatchShebangs = true;
installPhase = ''
2020-09-02 23:07:09 +08:00
cat > $out <<EOF
#!/bin/sh -e
2020-10-07 16:55:40 +08:00
for n in \$(seq 1 ${toString loops}); do
2020-11-20 22:32:41 +08:00
export GARLIC_RUN="\$n"
2020-10-26 16:24:18 +08:00
echo "running \$n of ${toString loops}" > status
mkdir "\$n"
cd "\$n"
2020-10-09 21:55:37 +08:00
${stageProgram nextStage}
cd ..
2020-08-11 18:05:43 +08:00
done
2020-10-26 16:24:18 +08:00
echo "completed" > status
2020-08-11 18:05:43 +08:00
EOF
2020-09-02 23:07:09 +08:00
chmod +x $out
2020-08-11 18:05:43 +08:00
'';
}