Skip to content
Merged
Show file tree
Hide file tree
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 Nov 4, 2025
1b698ae
nix flake: bundle TUI worker for nix builds
Alb-O Nov 4, 2025
c47e8bf
nix flake: get the version from package.json instead of hardcoded
Alb-O Nov 5, 2025
aeacf23
nix flake: add github workflow for automatically updating hashes
Alb-O Nov 5, 2025
bd8a5bd
nix flake: support arm64 builds
Alb-O Nov 5, 2025
ddac67f
nix flake: workflow cleanup and tweaks
Alb-O Nov 5, 2025
9304005
nix flake: canonicalize node modules for reproducibility
Alb-O Nov 5, 2025
7e64c36
nix flake: refactor/split bun-build script into script/nix dir
Alb-O Nov 5, 2025
0a57a27
nix flake: refactor/split bun-build script into script/nix dir
Alb-O Nov 5, 2025
ad6ff43
nix flake: completed modularization refactor
Alb-O Nov 5, 2025
e7d5485
nix flake: fix/support aarch64
Alb-O Nov 5, 2025
ca804a1
nix flake: refactor hash collection to unified json file
Alb-O Nov 6, 2025
ae21ae3
nix flake: ensure optional packages list is up-to-date
Alb-O Nov 6, 2025
1bc9ef9
nix flake: rewrite of workflow to hopefully be more robust
Alb-O Nov 6, 2025
04cb545
nix flake: handle version changes of package deps
Alb-O Nov 6, 2025
5fe4051
nix flake: extra fallback to allow script to get actual hash using `n…
Alb-O Nov 6, 2025
431873c
nix flake: trigger workflow on package/bun.lock changes
Alb-O Nov 6, 2025
3c04fe6
nix flake: initial darwin build support
Alb-O Nov 6, 2025
48a3c31
nix flake: workflow: use 4 native system runners
Alb-O Nov 6, 2025
fc367c4
nix flake: pin node_modules metadata so derivation no longer drifts b…
Alb-O Nov 7, 2025
2a68819
nix flake: pin platform specific optional packages
Alb-O Nov 7, 2025
902bc08
nix flake: only npm pack when target bundle is absent
Alb-O Nov 7, 2025
a038fc7
nix flake: add hash guard workflow and add better metadata to auto c…
Alb-O Nov 7, 2025
a1ba48b
nix flake: expanded triggers for the workflow, use hash metadata with…
Alb-O Nov 7, 2025
9b0411b
nix flake: remove direct models.dev json fetching, replace with equiv…
Alb-O Nov 8, 2025
0fb86b4
nix flake: properly cancel previous workflow
Alb-O Nov 8, 2025
f154c25
nix flake: test with missing hashes.json
Alb-O Nov 8, 2025
9d1cba2
nix flake: verify npm packages sri
Alb-O Nov 8, 2025
99d0b45
nix flake: remove infinite loop check block (unnecessary)
Alb-O Nov 8, 2025
d5e802f
nix flake: minor cleanup
Alb-O Nov 8, 2025
08c03d9
nix flake: track every asset Bun emits during compile, install them d…
Alb-O Nov 8, 2025
e80beb0
nix flake: resolve wasm assets to absolute filepaths
Alb-O Nov 8, 2025
77ca898
nix flake: remove (1) of the unneeded scripts
Alb-O Nov 8, 2025
6305089
nix flake: add `[skip ci]` to auto commit message
Alb-O Nov 9, 2025
0dfeaf2
Merge branch 'dev' into nix-support
Alb-O Nov 9, 2025
7cc268f
nix flake: fix commit metadata
Alb-O Nov 9, 2025
94adfae
Merge branch 'dev' into nix-support
Alb-O Nov 10, 2025
eb91395
nix: update hashes (branch:nix-support)
Nov 10, 2025
c3b53cf
nix flake: add more explicit sorting
Alb-O Nov 10, 2025
3071a03
nix: update hashes (branch:nix-support-dev)
Nov 10, 2025
0f79a47
nix flake: add more explicit sorting
Alb-O Nov 10, 2025
0c4ef6c
nix: update hashes (branch:nix-support-dev)
Nov 10, 2025
af12e0d
Merge branch 'dev' into nix-support
Alb-O Nov 11, 2025
bf0093d
Merge branch 'nix-support' into nix-support-dev
Alb-O Nov 11, 2025
45972b5
nix flake: remove a redundant builds from workflow
Alb-O Nov 11, 2025
a7c5b77
Merge branch 'dev' into nix-support-dev
Alb-O Nov 11, 2025
3c160aa
nix flake: remove commit metadata info
Alb-O Nov 11, 2025
22b928f
Update Nix hashes
Nov 11, 2025
bbfa63d
Update Nix hashes
Nov 11, 2025
3851f01
nix flake: use '--linker=isolated' in bun install
Alb-O Nov 12, 2025
1e13436
nix flake: revert bundle-utils
Alb-O Nov 12, 2025
ffff63f
nix flake: revert verify sha script
Alb-O Nov 12, 2025
9d142e2
nix flake: revert excessive optional metadata verification
Alb-O Nov 12, 2025
bef9709
nix flake: attempt full regen of hash file
Alb-O Nov 12, 2025
170d1f7
nix flake: remove all optional metadata/packages handling
Alb-O Nov 12, 2025
9224f35
Update Nix hashes
Nov 12, 2025
e2cd079
Merge branch 'dev' into nix-support-dev
Alb-O Nov 12, 2025
4d613a3
Update Nix hashes
Nov 12, 2025
80685fb
nix flake: test without isolation flags on opentui/watcher
Alb-O Nov 12, 2025
9465c27
Update Nix hashes
Nov 12, 2025
158a46f
Merge branch 'nix-support-dev' into nix-support
Alb-O Nov 12, 2025
668ded5
Update Nix hashes
Nov 12, 2025
83c4e0e
Add workflow to snapshot node modules
Alb-O Nov 13, 2025
459135e
Trigger snapshot workflow on debug branches
Alb-O Nov 13, 2025
cd7f3fa
Fix artifact glob for snapshot workflow
Alb-O Nov 13, 2025
500f49c
Trigger snapshot run #2
Alb-O Nov 13, 2025
b65ee85
Normalize bun .bin directories for determinism
Alb-O Nov 13, 2025
e876e6f
Trigger snapshot run #3
Alb-O Nov 13, 2025
be0b300
Publish hash metadata separately
Alb-O Nov 13, 2025
3aec0ab
Update Nix node_modules hashes
Alb-O Nov 13, 2025
f6addda
Merge branch 'dev' into nix-support-dev
Alb-O Nov 13, 2025
45ce1a3
Merge branch 'debug/node-modules-hash' into nix-support-dev
Alb-O Nov 13, 2025
1222dd5
Update Nix hashes
Nov 13, 2025
679b675
Merge branch 'dev' into nix-support-dev
Alb-O Nov 13, 2025
f08e58e
nix flake: remove debug and cleanup
Alb-O Nov 13, 2025
94fa598
Merge branch 'dev' into nix-support
Alb-O Nov 15, 2025
123708e
Merge branch 'dev' into nix-support
Alb-O Nov 16, 2025
6c9ec8f
nix flake: add fzf/ripgrep runtime deps to the wrapper
Alb-O Nov 16, 2025
3604e9a
nix: fetch bun deps for all platforms
Alb-O Nov 16, 2025
c88230f
nix flake: drop LD_LIBRARY_PATH
Alb-O Nov 16, 2025
2bec841
Merge branch 'dev' into nix-support
Alb-O Nov 17, 2025
8826b06
Update Nix hashes
Nov 17, 2025
c1df949
Merge branch 'dev' into nix-support
Alb-O Nov 17, 2025
dd21c9e
Update Nix hashes
Nov 17, 2025
09295c4
nix flake: update readme to include nix method
Alb-O Nov 18, 2025
07c652d
build: update SDK client utils after build
opencode-agent[bot] Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/update-nix-hashes.yml
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 "[email protected]"
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)"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dist
.turbo
**/.serena
.serena/
/result
refs
Session.vim
opencode.json
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ curl -fsSL https://opencode.ai/install | bash
npm i -g opencode-ai@latest # or bun/pnpm/yarn
scoop bucket add extras; scoop install extras/opencode # Windows
choco install opencode # Windows
brew install opencode # macOS and Linux
brew install opencode # macOS and Linux
paru -S opencode-bin # Arch Linux
mise use --pin -g ubi:sst/opencode # Any OS
nix run nixpkgs#opencode # or github:sst/opencode for latest dev branch
```

> [!TIP]
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions flake.nix
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";
};
}
);
};
}
3 changes: 3 additions & 0 deletions nix/hashes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nodeModules": "sha256-srbGIRjvpqUF+jWq4GAx7sGAasq02dRySnxTjijJJT8="
}
52 changes: 52 additions & 0 deletions nix/node-modules.nix
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;
}
Loading
Loading