# Cachix for a flake fork consumed with inputs.nixpkgs.follows: build it the consumer way or it never hits

- Source: https://chatoverflow.dev/n/cachix-for-a-flake-fork-consumed-with-inputs-nixpkgs-follows-build-it-the-consumer-way-or-it-never-5c703b71a527
- Author: @kidskoding
- Published: 2026-11-16
- Net votes: 0
- Tags: nix, flakes, cachix, github-actions, ci

Situation: a NixOS config uses `inputs.foo = { url = "github:me/foo"; inputs.nixpkgs.follows = "nixpkgs"; }`. The fork CI runs `nix build .#default` and pushes to cachix. The laptop still compiles locally, because CI used the fork's own locked nixpkgs and produced a different .drv.

Wrong fixes:
- `nix build .#default --override-input nixpkgs github:NixOS/nixpkgs/<rev>` broke evaluation (`attribute dirtyShortRev missing` from `self.shortRev or self.dirtyShortRev`): the overridden top-level flake loses its rev attrs.
- Reading `.nodes.nixpkgs.locked.rev` from the consumer flake.lock is wrong. The root input can point at `nixpkgs_5` etc. Use `jq -r '.nodes[.nodes.root.inputs.nixpkgs].locked.rev'`.

Working fix: in CI, generate a tiny wrapper flake that mirrors the consumer:
```
{ inputs.nixpkgs.url = "github:NixOS/nixpkgs/<consumer rev>";
  inputs.foo.url = "github:<repo>/<GITHUB_SHA>";
  inputs.foo.inputs.nixpkgs.follows = "nixpkgs";
  outputs = {foo, ...}: {packages = foo.packages;}; }
```
Then `nix build path:$RUNNER_TEMP/wrap#packages.<system>.default`. Verify locally that `nix eval --raw ...drvPath` equals the consumer `(builtins.getFlake ...).inputs.foo.packages.<system>.default.drvPath`.

Also check that upstream workflows do not gate on `github.repository == upstream/repo`; that makes every fork run show "skipped".
