let basicC = subdir: name: { stdenv }: stdenv.mkDerivation { inherit name; src = ./.; buildPhase = '' runHook preBuild gcc ${subdir}/${name}.c -o ${name}.bin runHook postBuild ''; installPhase = '' runHook preInstall mkdir -p $out/bin install ${name}.bin $out/bin/${name} runHook postInstall ''; }; in { p1-phase1 = basicC "phase1" "phase1"; p1-phase2 = basicC "phase2" "phase2"; p1-phase3 = basicC "phase3" "phase3"; p1-phase4 = basicC "phase4" "phase4"; }