feat(nix): add package validation and pinned lock regeneration#284
feat(nix): add package validation and pinned lock regeneration#284
Conversation
Greptile SummaryThis PR moves Nix-specific CI validation into a dedicated
Confidence Score: 4/5Safe to merge; changes are additive and well-scoped to Nix packaging infrastructure with no impact on the core application. The core logic — moving lockfile verification into a dedicated workflow, exposing named flake outputs, and pinning
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
PR[Pull Request / Push to main]
PR --> NIX[nix.yml: Nix Workflow]
PR --> CI[ci.yml / pr-ci.yml: Bun CI]
NIX --> LOCK[Verify Nix lockfile\nnix run .#update-bun-lock\ngit diff nix/bun.lock.nix]
NIX --> CHECK[nix flake check\n--print-build-logs]
NIX --> BUILD[nix build .#default\n--print-build-logs]
NIX --> SMOKE[Smoke test\nhunk --version\nhunk skill path]
LOCK -->|drift detected| FAIL[Fail: regenerate lockfile]
LOCK -->|up to date| CHECK
CHECK --> BUILD
BUILD --> SMOKE
subgraph flake.nix outputs
PKG[packages.hunk\npackages.default]
APP_DEFAULT[apps.default\nnix run .]
APP_UPDATE[apps.update-bun-lock\nbun run nix:update-lock]
end
APP_UPDATE --> LOCK
BUILD --> PKG
APP_DEFAULT --> PKG
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
flake.nix:45-68
**Duplicate nixpkgs instantiation in `apps`**
The `apps` block instantiates `pkgs = import nixpkgs { inherit system; };` independently from the `packages` block, which does the same. Every call to `forAllSystems` in `apps` and `packages` produces a separate `nixpkgs` evaluation per system, doubling the import cost at evaluation time. Since `devShells` already follows this pattern, the same fix could apply to all three: share a single `pkgs` via a unified `forAllSystems` call or hoist `pkgs` into the outer `let` binding with `forAllSystems`.
### Issue 2 of 2
.github/workflows/nix.yml:46-47
**`nix flake check` only validates the current system's outputs**
Without `--all-systems`, `nix flake check` only evaluates and builds outputs for `x86_64-linux` (the runner's platform). The flake declares four supported systems (`x86_64-linux`, `aarch64-linux`, `x86_64-darwin`, `aarch64-darwin`), so Darwin and ARM builds are never CI-verified. Adding `--no-build` to a second `nix flake check --all-systems --no-build` step (consistent with the verification steps listed in the PR description) would at least catch evaluation errors across all systems without requiring cross-compilation builders.
Reviews (1): Last reviewed commit: "feat(nix): add package validation and pi..." | Re-trigger Greptile |
3230ac5 to
bcd9013
Compare
Note for maintainersCI now validates that To regenerate, you need Nix installed (one-time setup: bun install
bun run nix:update-lock
git add bun.lock nix/bun.lock.nix package.jsonIf a contributor doesn't have Nix, CI will catch the drift and a maintainer with Nix can push the regenerated lockfile as a follow-up commit. |
c5e5b1c to
0b054af
Compare
Summary
hunkpackage plusnix runapp outputs, including a pinnedupdate-bun-lockapp used bybun run nix:update-locknix run, named package builds, and pinned lock regeneration@types/bunto the locked version so bun2nix regeneration is reproducible and warning-freeVerification
bun run format:checkbun run nix:update-lock && git diff --exit-code nix/bun.lock.nixnix flake check --print-build-logsnix build .#default --print-build-logsnix run . -- --versionnix flake check --all-systems --no-build