agentleFS
pmarreckpmarreck/llm_skills/fix-zig-deps-hash/SKILL.md

fix-zig-deps-hash

Skill2 starsChanged 4 months agoMITView on GitHub

Use when nix build fails with zigDeps/zigDepsHash mismatch, build.zig.zon deps changed, or "hash mismatch"/"fixed-output derivation" errors appear.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When Zig dependencies change (new commit pinned in build.zig.zon), the zigDepsHash in flake.nix becomes stale and nix build fails with a …

    line 10
  2. Very specific:

    Update the specific dependency's hash field

    line 68

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Fix Zig Deps Hash

Overview

When Zig dependencies change (new commit pinned in build.zig.zon), the zigDepsHash in flake.nix becomes stale and nix build fails with a hash mismatch. This skill automates the detect-extract-update-retry cycle.

<when_to_use>

  • nix build fails with "hash mismatch" mentioning the zigDeps derivation
  • You just updated a dependency URL or hash in build.zig.zon
  • You bumped a dependency to a new commit/version
  • Error contains "fixed-output derivation" and "got: sha256-..." </when_to_use>

Workflow

Step 1: Set to fakeHash

Find the zigDepsHash line in flake.nix and set it to the Nix fake hash:

zigDepsHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";

Or use pkgs.lib.fakeHash if the flake uses that pattern:

zigDepsHash = pkgs.lib.fakeHash;

Step 2: Run nix build

nix build 2>&1

This will fail, but the error output contains the correct hash. Look for a line like:

  got:    sha256-xYzAbCdEfGhIjKlMnOpQrStUvWxYz1234567890AB=

Step 3: Extract and update

Copy the sha256-... hash from the error output and replace the zigDepsHash value in flake.nix:

zigDepsHash = "sha256-xYzAbCdEfGhIjKlMnOpQrStUvWxYz1234567890AB=";

Step 4: Verify

nix build

This should now succeed. If it fails again with a DIFFERENT hash mismatch (rare, can happen with transitive deps), repeat from Step 2.

For linkFarm Projects

Some projects (codescan, chatscan) use linkFarm + --system instead of zigDepsHash. For these:

  1. The dependency hash lives in individual pkgs.fetchgit/pkgs.fetchzip calls
  2. Update the specific dependency's hash field
  3. The cache key name (e.g., sqlite_vec-0.1.7-alpha.2-4Cdt0Ov...) may also change -- check build.zig.zon for the new URL/hash to derive it

The fakeHash trick works the same way for individual fetch calls.

Common Mistakes

<important> - **Forgetting to also update `checks` derivation** -- if the test derivation copies zigDeps separately, it uses the same hash. Both should reference the same `zigDeps` binding. - **Editing the wrong hash** -- projects may have multiple hashes (for different deps). Match the derivation name in the error to the right variable. - **Host cache hiding missing inputs** -- a clean Nix build must use its declared prefetched dependency tree, not `~/.cache/zig`. Compare source pins, staging, fetch/cache hashes and effective sandbox configuration; clearing the developer cache is not a portability repair. Follow `writing-nix/references/dependency-portability.md`. </important>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.