{ stdenv , garlicTools }: { nextStage , loops ? 30 }: with garlicTools; stdenv.mkDerivation { name = "control"; preferLocalBuild = true; phases = [ "installPhase" ]; dontPatchShebangs = true; installPhase = '' cat > $out < status mkdir "\$n" cd "\$n" ${stageProgram nextStage} cd .. done echo "completed" > status EOF chmod +x $out ''; }