-
Notifications
You must be signed in to change notification settings - Fork 16.1k
feat: nix support for the nix folks #3924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
b2ee706
nix flake: initial flake and patches for ts
Alb-O 1b698ae
nix flake: bundle TUI worker for nix builds
Alb-O c47e8bf
nix flake: get the version from package.json instead of hardcoded
Alb-O aeacf23
nix flake: add github workflow for automatically updating hashes
Alb-O bd8a5bd
nix flake: support arm64 builds
Alb-O ddac67f
nix flake: workflow cleanup and tweaks
Alb-O 9304005
nix flake: canonicalize node modules for reproducibility
Alb-O 7e64c36
nix flake: refactor/split bun-build script into script/nix dir
Alb-O 0a57a27
nix flake: refactor/split bun-build script into script/nix dir
Alb-O ad6ff43
nix flake: completed modularization refactor
Alb-O e7d5485
nix flake: fix/support aarch64
Alb-O ca804a1
nix flake: refactor hash collection to unified json file
Alb-O ae21ae3
nix flake: ensure optional packages list is up-to-date
Alb-O 1bc9ef9
nix flake: rewrite of workflow to hopefully be more robust
Alb-O 04cb545
nix flake: handle version changes of package deps
Alb-O 5fe4051
nix flake: extra fallback to allow script to get actual hash using `n…
Alb-O 431873c
nix flake: trigger workflow on package/bun.lock changes
Alb-O 3c04fe6
nix flake: initial darwin build support
Alb-O 48a3c31
nix flake: workflow: use 4 native system runners
Alb-O fc367c4
nix flake: pin node_modules metadata so derivation no longer drifts b…
Alb-O 2a68819
nix flake: pin platform specific optional packages
Alb-O 902bc08
nix flake: only npm pack when target bundle is absent
Alb-O a038fc7
nix flake: add hash guard workflow and add better metadata to auto c…
Alb-O a1ba48b
nix flake: expanded triggers for the workflow, use hash metadata with…
Alb-O 9b0411b
nix flake: remove direct models.dev json fetching, replace with equiv…
Alb-O 0fb86b4
nix flake: properly cancel previous workflow
Alb-O f154c25
nix flake: test with missing hashes.json
Alb-O 9d1cba2
nix flake: verify npm packages sri
Alb-O 99d0b45
nix flake: remove infinite loop check block (unnecessary)
Alb-O d5e802f
nix flake: minor cleanup
Alb-O 08c03d9
nix flake: track every asset Bun emits during compile, install them d…
Alb-O e80beb0
nix flake: resolve wasm assets to absolute filepaths
Alb-O 77ca898
nix flake: remove (1) of the unneeded scripts
Alb-O 6305089
nix flake: add `[skip ci]` to auto commit message
Alb-O 0dfeaf2
Merge branch 'dev' into nix-support
Alb-O 7cc268f
nix flake: fix commit metadata
Alb-O 94adfae
Merge branch 'dev' into nix-support
Alb-O eb91395
nix: update hashes (branch:nix-support)
c3b53cf
nix flake: add more explicit sorting
Alb-O 3071a03
nix: update hashes (branch:nix-support-dev)
0f79a47
nix flake: add more explicit sorting
Alb-O 0c4ef6c
nix: update hashes (branch:nix-support-dev)
af12e0d
Merge branch 'dev' into nix-support
Alb-O bf0093d
Merge branch 'nix-support' into nix-support-dev
Alb-O 45972b5
nix flake: remove a redundant builds from workflow
Alb-O a7c5b77
Merge branch 'dev' into nix-support-dev
Alb-O 3c160aa
nix flake: remove commit metadata info
Alb-O 22b928f
Update Nix hashes
bbfa63d
Update Nix hashes
3851f01
nix flake: use '--linker=isolated' in bun install
Alb-O 1e13436
nix flake: revert bundle-utils
Alb-O ffff63f
nix flake: revert verify sha script
Alb-O 9d142e2
nix flake: revert excessive optional metadata verification
Alb-O bef9709
nix flake: attempt full regen of hash file
Alb-O 170d1f7
nix flake: remove all optional metadata/packages handling
Alb-O 9224f35
Update Nix hashes
e2cd079
Merge branch 'dev' into nix-support-dev
Alb-O 4d613a3
Update Nix hashes
80685fb
nix flake: test without isolation flags on opentui/watcher
Alb-O 9465c27
Update Nix hashes
158a46f
Merge branch 'nix-support-dev' into nix-support
Alb-O 668ded5
Update Nix hashes
83c4e0e
Add workflow to snapshot node modules
Alb-O 459135e
Trigger snapshot workflow on debug branches
Alb-O cd7f3fa
Fix artifact glob for snapshot workflow
Alb-O 500f49c
Trigger snapshot run #2
Alb-O b65ee85
Normalize bun .bin directories for determinism
Alb-O e876e6f
Trigger snapshot run #3
Alb-O be0b300
Publish hash metadata separately
Alb-O 3aec0ab
Update Nix node_modules hashes
Alb-O f6addda
Merge branch 'dev' into nix-support-dev
Alb-O 45ce1a3
Merge branch 'debug/node-modules-hash' into nix-support-dev
Alb-O 1222dd5
Update Nix hashes
679b675
Merge branch 'dev' into nix-support-dev
Alb-O f08e58e
nix flake: remove debug and cleanup
Alb-O 94fa598
Merge branch 'dev' into nix-support
Alb-O 123708e
Merge branch 'dev' into nix-support
Alb-O 6c9ec8f
nix flake: add fzf/ripgrep runtime deps to the wrapper
Alb-O 3604e9a
nix: fetch bun deps for all platforms
Alb-O c88230f
nix flake: drop LD_LIBRARY_PATH
Alb-O 2bec841
Merge branch 'dev' into nix-support
Alb-O 8826b06
Update Nix hashes
c1df949
Merge branch 'dev' into nix-support
Alb-O dd21c9e
Update Nix hashes
09295c4
nix flake: update readme to include nix method
Alb-O 07c652d
build: update SDK client utils after build
opencode-agent[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: Update Nix Hashes | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| paths: | ||
| - 'bun.lock' | ||
| - 'package.json' | ||
| - 'packages/*/package.json' | ||
| pull_request: | ||
| paths: | ||
| - 'bun.lock' | ||
| - 'package.json' | ||
| - 'packages/*/package.json' | ||
|
|
||
| jobs: | ||
| update: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| SYSTEM: x86_64-linux | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Nix | ||
| uses: DeterminateSystems/nix-installer-action@v20 | ||
|
|
||
| - name: Configure git | ||
| run: | | ||
| git config --global user.email "opencode@sst.dev" | ||
| git config --global user.name "opencode" | ||
|
|
||
| - name: Update node_modules hash | ||
| run: | | ||
| set -euo pipefail | ||
| nix/scripts/update-hashes.sh | ||
|
|
||
| - name: Commit hash changes | ||
| env: | ||
| TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| summarize() { | ||
| local status="$1" | ||
| { | ||
| echo "### Nix Hash Update" | ||
| echo "" | ||
| echo "- ref: ${GITHUB_REF_NAME}" | ||
| echo "- status: ${status}" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| if [ -n "${GITHUB_SERVER_URL:-}" ] && [ -n "${GITHUB_REPOSITORY:-}" ] && [ -n "${GITHUB_RUN_ID:-}" ]; then | ||
| echo "- run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" >> "$GITHUB_STEP_SUMMARY" | ||
| fi | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| } | ||
|
|
||
| FILES=(flake.nix nix/node-modules.nix nix/hashes.json) | ||
| STATUS="$(git status --short -- "${FILES[@]}" || true)" | ||
| if [ -z "$STATUS" ]; then | ||
| summarize "no changes" | ||
| echo "No changes to tracked Nix files. Hashes are already up to date." | ||
| exit 0 | ||
| fi | ||
|
|
||
| git add "${FILES[@]}" | ||
| git commit -m "Update Nix hashes" | ||
|
|
||
| BRANCH="${TARGET_BRANCH:-${GITHUB_REF_NAME}}" | ||
| git push origin HEAD:"$BRANCH" | ||
|
|
||
| summarize "committed $(git rev-parse --short HEAD)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ dist | |
| .turbo | ||
| **/.serena | ||
| .serena/ | ||
| /result | ||
| refs | ||
| Session.vim | ||
| opencode.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| { | ||
| description = "OpenCode development flake"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
| }; | ||
|
|
||
| outputs = | ||
| { | ||
| nixpkgs, | ||
| ... | ||
| }: | ||
| let | ||
| systems = [ | ||
| "aarch64-linux" | ||
| "x86_64-linux" | ||
| "aarch64-darwin" | ||
| "x86_64-darwin" | ||
| ]; | ||
| lib = nixpkgs.lib; | ||
| forEachSystem = lib.genAttrs systems; | ||
| pkgsFor = system: nixpkgs.legacyPackages.${system}; | ||
| packageJson = builtins.fromJSON (builtins.readFile ./packages/opencode/package.json); | ||
| bunTarget = { | ||
| "aarch64-linux" = "bun-linux-arm64"; | ||
| "x86_64-linux" = "bun-linux-x64"; | ||
| "aarch64-darwin" = "bun-darwin-arm64"; | ||
| "x86_64-darwin" = "bun-darwin-x64"; | ||
| }; | ||
| defaultNodeModules = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; | ||
| hashesFile = "${./nix}/hashes.json"; | ||
| hashesData = | ||
| if builtins.pathExists hashesFile then builtins.fromJSON (builtins.readFile hashesFile) else { }; | ||
| nodeModulesHash = hashesData.nodeModules or defaultNodeModules; | ||
| modelsDev = forEachSystem ( | ||
| system: | ||
| let | ||
| pkgs = pkgsFor system; | ||
| in | ||
| pkgs."models-dev" | ||
| ); | ||
| in | ||
| { | ||
| devShells = forEachSystem ( | ||
| system: | ||
| let | ||
| pkgs = pkgsFor system; | ||
| in | ||
| { | ||
| default = pkgs.mkShell { | ||
| packages = with pkgs; [ | ||
| bun | ||
| nodejs_20 | ||
| pkg-config | ||
| openssl | ||
| git | ||
| ]; | ||
| }; | ||
| } | ||
| ); | ||
|
|
||
| packages = forEachSystem ( | ||
| system: | ||
| let | ||
| pkgs = pkgsFor system; | ||
| mkNodeModules = pkgs.callPackage ./nix/node-modules.nix { | ||
| hash = nodeModulesHash; | ||
| }; | ||
| mkPackage = pkgs.callPackage ./nix/opencode.nix { }; | ||
| in | ||
| { | ||
| default = mkPackage { | ||
| version = packageJson.version; | ||
| src = ./.; | ||
| scripts = ./nix/scripts; | ||
| target = bunTarget.${system}; | ||
| modelsDev = "${modelsDev.${system}}/dist/_api.json"; | ||
| mkNodeModules = mkNodeModules; | ||
| }; | ||
| } | ||
| ); | ||
|
|
||
| apps = forEachSystem ( | ||
| system: | ||
| let | ||
| pkgs = pkgsFor system; | ||
| in | ||
| { | ||
| opencode-dev = { | ||
| type = "app"; | ||
| meta = { | ||
| description = "Nix devshell shell for OpenCode"; | ||
| runtimeInputs = [ pkgs.bun ]; | ||
| }; | ||
| program = "${ | ||
| pkgs.writeShellApplication { | ||
| name = "opencode-dev"; | ||
| text = '' | ||
| exec bun run dev "$@" | ||
| ''; | ||
| } | ||
| }/bin/opencode-dev"; | ||
| }; | ||
| } | ||
| ); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "nodeModules": "sha256-srbGIRjvpqUF+jWq4GAx7sGAasq02dRySnxTjijJJT8=" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { hash, lib, stdenvNoCC, bun, cacert, curl }: | ||
| args: | ||
| stdenvNoCC.mkDerivation { | ||
| pname = "opencode-node_modules"; | ||
| version = args.version; | ||
| src = args.src; | ||
|
|
||
| impureEnvVars = | ||
| lib.fetchers.proxyImpureEnvVars | ||
| ++ [ | ||
| "GIT_PROXY_COMMAND" | ||
| "SOCKS_SERVER" | ||
| ]; | ||
|
|
||
| nativeBuildInputs = [ bun cacert curl ]; | ||
|
|
||
| dontConfigure = true; | ||
|
|
||
| buildPhase = '' | ||
| runHook preBuild | ||
| export HOME=$(mktemp -d) | ||
| export BUN_INSTALL_CACHE_DIR=$(mktemp -d) | ||
| bun install \ | ||
| --cpu="*" \ | ||
| --os="*" \ | ||
| --frozen-lockfile \ | ||
| --ignore-scripts \ | ||
| --no-progress \ | ||
| --linker=isolated | ||
| bun --bun ${args.canonicalizeScript} | ||
| bun --bun ${args.normalizeBinsScript} | ||
| runHook postBuild | ||
| ''; | ||
|
|
||
| installPhase = '' | ||
| runHook preInstall | ||
| mkdir -p $out | ||
| while IFS= read -r dir; do | ||
| rel="''${dir#./}" | ||
| dest="$out/$rel" | ||
| mkdir -p "$(dirname "$dest")" | ||
| cp -R "$dir" "$dest" | ||
| done < <(find . -type d -name node_modules -prune | sort) | ||
| runHook postInstall | ||
| ''; | ||
|
|
||
| dontFixup = true; | ||
|
|
||
| outputHashAlgo = "sha256"; | ||
| outputHashMode = "recursive"; | ||
| outputHash = hash; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.