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 {
  a2-p1-producer = basicC "part1" "producer";
  a2-p1-consumer = basicC "part1" "consumer";

  a2-p2-bidirectional = basicC "part2" "bidirectional";

  a2-p3-producer = basicC "part3" "producer";
  a2-p3-consumer = basicC "part3" "consumer";
}
