[mk-cache-key.nix]: make build-cache key for "half board" nix projects

I made a small utility to make build-cache-key calculation for some of my projects that are not fully nixified, which I call them “half board” nix projects.

What Is a “Half Board” Nix Project?

A “half board” nix project is a project that is not entirely “nixified”. According to some informal definition, a nixified project is where its build is described fully with nix expressions, and its nix build results nix store outputs. A “half board” project only defines its development tooling in nix shells and immutable outputs are guaranteed not by Nix but by mechanisms provided by those development tooling, usually with their build description and lock files.

Why Don’t You Just Nixify Your Project?

There are several reasons for not nixifying your project (yet):

  1. Nixification of projects in some languages needs more support.
  2. In a team environment, if only some people use Nix for local development, it could result in a divergence between CI and local development results.
  3. Procrastination.

Full readme can be found here: GitHub - hellwolf/mk-cache-key.nix: A nix expression to make cache keys for "half board" nix projects.

It’s been useful for me, but I have received a few critical feedback telling me I should nixify the build. I am releasing the project, nonetheless, in case there are at least one person like me having such projects.

1 Like

What is a “build-cache-key calculation”?

For example when using GitHub cache, you would do something like this:

      - name: Lookup Cache
        id: cache
        uses: actions/cache/restore@v4
        with:
          path: ${{ steps.hb.outputs.CACHE_OUTPUTS }}
          key: ${{ steps.hb.outputs.CACHE_KEY }}

You need reliable key value for cache look-ups that have zero false positives.

1 Like