bscpkgs/garlic/stages/control.nix
2021-02-08 14:14:08 +01:00

37 lines
644 B
Nix

{
stdenv
, garlicTools
}:
{
nextStage
, loops ? 30
}:
with garlicTools;
stdenv.mkDerivation {
name = "control";
preferLocalBuild = true;
phases = [ "installPhase" ];
dontPatchShebangs = true;
installPhase = ''
cat > $out <<"EOF"
#!/bin/sh -e
for n in $(seq 1 ${toString loops}); do
export GARLIC_RUN="$n"
echo "running $n of ${toString loops}" > status
mkdir "$n"
cd "$n"
mkdir .garlic
date +%s > .garlic/total_time_start
${stageProgram nextStage}
date +%s > .garlic/total_time_end
cd ..
done
echo "completed" > status
EOF
chmod +x $out
'';
}