Skip to content

Commit 258a5bc

Browse files
author
Test User
committed
refactor(nix): fetch dependencies from bun.lock
Use Bun's recorded source integrities instead of hashing its installed layout. Keep native Bun responsible for patches and peer contexts. Remove hash calibration and manual lock synchronization. Closes anomalyco#49063
1 parent 161d466 commit 258a5bc

16 files changed

Lines changed: 647 additions & 437 deletions

‎.github/workflows/bot-nix-hashes.yml‎

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

‎.github/workflows/check-nix.yml‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,29 @@ jobs:
1919
nix-eval:
2020
if: ${{ !github.event.pull_request.draft }}
2121
runs-on: blacksmith-4vcpu-ubuntu-2404
22-
timeout-minutes: 15
22+
timeout-minutes: 60
2323
steps:
2424
- name: Checkout repository
2525
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2626

27+
- name: Detect dependency input changes
28+
id: dependencies
29+
env:
30+
BASE_REV: ${{ github.event.pull_request.base.sha || github.event.before }}
31+
run: |
32+
set -euo pipefail
33+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
34+
echo "changed=true" >> "$GITHUB_OUTPUT"
35+
exit 0
36+
fi
37+
git fetch --no-tags --depth=1 origin "$BASE_REV"
38+
changed=$(git diff --name-only "$BASE_REV" HEAD -- \
39+
bun.lock package.json '**/package.json' flake.nix flake.lock \
40+
nix patches .github/workflows/check-nix.yml)
41+
if [[ -n "$changed" ]]; then
42+
echo "changed=true" >> "$GITHUB_OUTPUT"
43+
fi
44+
2745
- name: Setup Nix
2846
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
2947

@@ -41,8 +59,8 @@ jobs:
4159
4260
SYSTEMS="x86_64-linux aarch64-linux aarch64-darwin"
4361
PACKAGES="opencode"
44-
# TODO: move 'desktop' to PACKAGES when #11755 is fixed
45-
OPTIONAL_PACKAGES="desktop"
62+
# TODO: move 'opencode-desktop' to PACKAGES when #11755 is fixed
63+
OPTIONAL_PACKAGES="opencode-desktop"
4664
4765
echo ""
4866
echo "=== Evaluating packages for all systems ==="
@@ -95,3 +113,11 @@ jobs:
95113
96114
echo ""
97115
echo "=== All evaluations passed ==="
116+
117+
- name: Check Bun lock source import
118+
if: steps.dependencies.outputs.changed == 'true'
119+
run: nix develop --command bun nix/check-lock.ts
120+
121+
- name: Check CLI runtime and Desktop build
122+
if: steps.dependencies.outputs.changed == 'true'
123+
run: nix build .#checks.x86_64-linux.runtime .#opencode-desktop --max-jobs auto --no-link -L

‎CONTRIBUTING.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ Follow package-specific instructions in nearby `AGENTS.md` files. After changing
7373

7474
Follow the repository [style guide](./AGENTS.md).
7575

76+
### Nix packaging
77+
78+
Nix reads package URLs and integrity hashes directly from `bun.lock`, then uses bun2nix to prepare Bun's offline cache. Bun installs the original lockfile, links workspaces and peers, and applies patches. CLI and Desktop share these dependencies.
79+
80+
Changing `bun.lock` updates Nix dependencies automatically. There is no generated lockfile, aggregate `node_modules` hash, or hash-update workflow to maintain.
81+
82+
The cache filters incompatible `os`/`cpu` constraints using Bun's matching rules. It retains libc variants: Bun 1.4.2 ignores libc, while Bun 1.4.4 filters it per dependency.
83+
84+
GitHub archives use Bun's recorded archive integrity, not a separate Nix tree hash. [GitHub can change archive compression](https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives#stability-of-source-code-archives), invalidating that checksum even when Git contents are unchanged. The fetch fails rather than accepting different bytes.
85+
86+
Build the CLI and run the installed color and service-discovery checks:
87+
88+
```bash
89+
nix build .#opencode
90+
nix build ".#checks.$(nix eval --impure --raw --expr builtins.currentSystem).runtime"
91+
```
92+
93+
CI checks the lock reader, installed CLI runtime, and Desktop build before dependency input changes merge. Unrelated source-only PRs keep evaluation-only Nix checks. The reader supports lockfile v1 registry, GitHub, and HTTP sources with recorded integrity; unsupported formats fail explicitly.
94+
7695
## Pull Requests
7796

7897
### Link Issues When Required

‎flake.lock‎

Lines changed: 82 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)