Skip to content

Commit bd4920f

Browse files
edenreichclaude
andauthored
ci(nix): Replace standalone package.nix with flake.nix (#508)
## Summary Adds Nix flake support for consuming `infer` from any flake-aware tool — most notably as a Flox manifest entry across other repos. Replaces the standalone `nix/package.nix` with a single `flake.nix` at the repo root, and syncs `version` + `vendorHash` as part of each release commit so tags are self-consistent. ### Pin from Flox ```toml [install] infer.flake = "github:inference-gateway/cli/v0.110.0" # recommended: pin to tag infer.flake = "github:inference-gateway/cli" # latest default branch ``` Tag pins are the reliable path — the release commit refreshes both `version =` and `vendorHash`, so every tagged version builds cleanly in a fresh checkout. ### Changes 1. **NEW `flake.nix`** — multi-platform (`aarch64`/`x86_64` × `linux`/`darwin`) `buildGoModule` derivation. `proxyVendor = true` (still required by `robotgo`'s CGO header layout) and `goSum = ./go.sum;` for reliability across nixpkgs upgrades. Exposes `packages.<system>.{default,infer}`, `apps.default`, and `devShells.default`. 2. **DELETED `nix/` folder** — `package.nix`, `default.nix`, `update-hashes.sh`, and the `nixpkgs-submission/` scaffolding. Single source of truth. 3. **MIGRATED `nix-build.yml`** — switched from `nix-build` to `nix build .#infer` + `nix flake check --all-systems`. Only triggers on `flake.nix`/`flake.lock` changes. 4. **UPDATED `release.yml` + `.releaserc.yaml`** — added Determinate Nix install + `@semantic-release/exec` with a `prepareCmd` that: - seds `version =` in `flake.nix` - runs `determinate-nixd fix hashes --auto-apply flake.nix` to refresh `vendorHash` - `flake.nix` is committed alongside `CHANGELOG.md` via `@semantic-release/git`'s `assets` 5. **DELETED `nix-version-sync.yml`** — its job is now done inside the release commit itself, not in a follow-up PR. ### Release pipeline impact ~30-60s for Determinate Nix install + a few seconds for `fix hashes` per release. Subsequent releases are mostly cached. ### Mid-cycle staleness (known trade-off) Between releases, `main` may have stale `vendorHash` if Dependabot bumped `go.mod`/`go.sum`. `nix build github:inference-gateway/cli` (default branch) may fail during these windows. Each release pipeline refreshes it. **Pin to tags for reliability** — this is the recommended consumption pattern for cross-repo Flox manifests anyway. ## Test plan - [x] `nix flake check --all-systems --no-build` evaluates cleanly on all 4 platforms - [x] `nix build .#infer` succeeds locally → `result/bin/infer version` reports `0.109.3` - [x] `nixfmt --check flake.nix` + `statix check flake.nix` pass - [x] **Flox integration A** (local `path:` ref): `flox activate -- infer version` works against working tree - [x] **Flox integration B** (remote `github:` ref): `flox activate -- infer version` works against this pushed branch - [ ] CI `Nix Build Verification` matrix passes on all 4 platforms - [ ] First release after merge: confirm release commit includes both `CHANGELOG.md` and `flake.nix` updates, and `nix build github:inference-gateway/cli/v<new>#infer` succeeds in a clean checkout 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aabde54 commit bd4920f

6 files changed

Lines changed: 245 additions & 160 deletions

File tree

.github/workflows/nix-build.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Nix Build Verification
23

34
concurrency:
@@ -9,13 +10,15 @@ on:
910
branches:
1011
- main
1112
paths:
12-
- 'nix/**'
13+
- 'flake.nix'
14+
- 'flake.lock'
1315
- '.github/workflows/nix-build.yml'
1416
push:
1517
branches:
1618
- main
1719
paths:
18-
- 'nix/**'
20+
- 'flake.nix'
21+
- 'flake.lock'
1922
- '.github/workflows/nix-build.yml'
2023
workflow_dispatch:
2124

@@ -53,7 +56,7 @@ jobs:
5356

5457
- name: Build with Nix
5558
run: |
56-
nix-build nix/default.nix --show-trace
59+
nix build .#infer --show-trace --print-build-logs
5760
5861
- name: Verify binary
5962
run: |
@@ -93,15 +96,15 @@ jobs:
9396

9497
- name: Check Nix formatting (nixfmt-rfc-style)
9598
run: |
96-
nix-shell -p nixfmt-rfc-style --run "nixfmt --check nix/package.nix nix/default.nix"
99+
nix-shell -p nixfmt-rfc-style --run "nixfmt --check flake.nix"
97100
98101
- name: Lint with statix
99102
run: |
100-
nix-shell -p statix --run "statix check nix/"
103+
nix-shell -p statix --run "statix check flake.nix"
101104
102-
- name: Evaluate Nix expression
105+
- name: Check flake evaluates on all systems
103106
run: |
104-
nix-instantiate --eval --strict nix/default.nix --show-trace
107+
nix flake check --all-systems --no-build --show-trace
105108
106109
summary:
107110
name: Build Summary
@@ -124,4 +127,4 @@ jobs:
124127
exit 1
125128
fi
126129
127-
echo "All Nix build checks passed!"
130+
echo "All Nix build checks passed!"

.github/workflows/nix-version-sync.yml

Lines changed: 0 additions & 152 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ jobs:
6565
@semantic-release/commit-analyzer@13.0.1 \
6666
@semantic-release/release-notes-generator@14.1.0 \
6767
@semantic-release/changelog@6.0.3 \
68+
@semantic-release/exec@7.1.0 \
6869
@semantic-release/git@10.0.1 \
6970
@semantic-release/github@1.0.0 \
7071
conventional-changelog-conventionalcommits@9.1.0 \
7172
conventional-changelog-cli@5.0.0
7273
74+
- name: Install Determinate Nix
75+
uses: DeterminateSystems/determinate-nix-action@v3
76+
7377
- name: Check for existing releases
7478
id: check_releases
7579
env:

.releaserc.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ plugins:
8787
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8888
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8989
90+
- - "@semantic-release/exec"
91+
- prepareCmd: |
92+
sed -i.bak 's|version = "[^"]*";|version = "${nextRelease.version}";|' flake.nix && rm flake.nix.bak
93+
determinate-nixd fix hashes --auto-apply flake.nix
94+
9095
- - "@semantic-release/git"
9196
- assets:
9297
- CHANGELOG.md
98+
- flake.nix
9399
message: |
94100
chore(release): ${nextRelease.version} [skip ci]
95101
@@ -124,6 +130,21 @@ plugins:
124130
curl -fsSL https://raw.githubusercontent.com/inference-gateway/cli/main/install.sh | bash -s -- --install-dir $HOME/.local/bin
125131
```
126132
133+
### Nix Flake
134+
135+
Run directly without installing:
136+
137+
```bash
138+
nix run github:inference-gateway/cli/<%= nextRelease.gitTag %>
139+
```
140+
141+
Or pin it in a [Flox](https://flox.dev) manifest (`.flox/env/manifest.toml`):
142+
143+
```toml
144+
[install]
145+
infer.flake = "github:inference-gateway/cli/<%= nextRelease.gitTag %>"
146+
```
147+
127148
### Binary Download
128149
129150
Download the appropriate binary for your platform from the assets below.

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)