Working setup with a `post-build-hook` daemon?

Is there any open-source implementation of a functioning post-build hook daemon, as sketched in Setting up post-build hooks ā€” nix.dev documentation?

We use this in a Hydra cluster of ~10 machines:

nix.settings.post-build-hook = lib.getExe (pkgs.writeShellApplication {
  name = "upload";
  runtimeInputs = with pkgs; [ts nix findutils];
  text = ''
    set -uf

    export AWS_SHARED_CREDENTIALS_FILE=${lib.escapeShellArg config.age.secrets.r2.path}

    if [[ -n "''${OUT_PATHS:-}" ]]; then
      export TS_MAXFINISHED=1000
      export TS_SLOTS=10

      echo "upload $OUT_PATHS"
      printf "%s" "$OUT_PATHS" \
      | xargs ts nix copy --to 's3://FOO?secret-key=${config.age.secrets.nix.path}&endpoint=foo.r2.cloudflarestorage.com&region=auto&compression=zstd'
    fi
  '';
});
2 Likes

Are you looking for a post-build hook or a build hook? I was working on a build hook - which does the load balancing for remote builds.

Post-build hooks are often used to upload to an s3 bucket or similar.

Here Iā€™m asking for post-build-hook for uploading build results to a cache. But the general idea for build hooks is similar, and distributed builds are related to caching in the sense that you usually want both in some combination.