Compare commits

..

3 Commits

Author SHA1 Message Date
m3tm3re
1c7a7f0c82 fix: remove deprecated opencode update logic 2026-01-20 19:36:51 +01:00
m3tm3re
4597384291 fix(opencode): patch bun version requirement to match upstream lockfile
- Upstream v1.1.27 requires Bun 1.3.5 but provides 1.3.6
- Patch package.json to accept Bun 1.3.6
- Propagate patched opencode to opencode-desktop
2026-01-20 18:49:18 +01:00
m3tm3re
de3850fb1b feat: replace local opencode with upstream flake input v1.1.27
- Add `opencode` flake input pinned to v1.1.27 for stability
- Remove local `pkgs/opencode` derivation and overlay
- Add `opencode` and `opencode-desktop` to `pkgs/default.nix` from input
2026-01-20 18:32:28 +01:00
10 changed files with 163 additions and 295 deletions

View File

@@ -52,6 +52,74 @@ jobs:
"https://m3tam3re@code.m3ta.dev/m3tam3re/nixpkgs.git" \
"$REPO_DIR"
- name: Update opencode Flake Input
id: update-opencode
run: |
cd "$REPO_DIR"
echo "::group::Checking for opencode updates"
# Get latest release from GitHub API
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/anomalyco/opencode/releases/latest" | jq -r '.tag_name')
# Extract current version from flake.nix
CURRENT_VERSION=$(grep -oP 'opencode\.url = "github:anomalyco/opencode/v\K[^"]+' flake.nix)
echo "Current opencode version: $CURRENT_VERSION"
echo "Latest opencode version: $LATEST_RELEASE"
# Check if update is needed
if [ "$LATEST_RELEASE" != "$CURRENT_VERSION" ]; then
echo "🔄 Updating opencode from $CURRENT_VERSION to $LATEST_RELEASE"
# Update flake.nix with new version
sed -i 's|opencode\.url = "github:anomalyco/opencode/v.*"|opencode.url = "github:anomalyco/opencode/'"$LATEST_VERSION"'"| flake.nix
# Update flake lock to fetch new revision
nix flake update opencode
# Format with alejandra
nix fmt
# Verify the update
echo "::endgroup::"
echo "::group::Verifying opencode update"
# Run flake check
if ! nix flake check; then
echo "❌ Flake check failed after opencode update"
git checkout flake.nix flake.lock
exit 1
fi
# Build opencode package
if ! nix build .#opencode 2>&1 | tee /tmp/opencode-build.log; then
echo "❌ Build failed for opencode"
git checkout flake.nix flake.lock
exit 1
fi
echo "✅ Flake check passed"
echo "✅ Build successful for opencode"
echo "::endgroup::"
# Commit the change
echo "::group::Committing opencode update"
git add flake.nix flake.lock
git commit -m "chore: update opencode flake input to $LATEST_RELEASE"
echo "opencode_update=true" >> $GITHUB_OUTPUT
echo "opencode_version=${LATEST_RELEASE}" >> $GITHUB_OUTPUT
echo "::endgroup::"
echo "✅ Updated opencode to $LATEST_RELEASE"
else
echo "✓ opencode is already up to date"
echo "opencode_update=false" >> $GITHUB_OUTPUT
echo "opencode_version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
echo "::endgroup::"
fi
- name: Check Prerequisites
id: check
run: |
@@ -89,19 +157,14 @@ jobs:
}
run_update() {
local pkg=$1
local before_hash=$(git rev-parse HEAD)
local pkg=$1
local before_hash=$(git rev-parse HEAD)
echo "::group::Updating $pkg"
echo "::group::Updating $pkg"
local args=("--flake" "--commit" "--use-github-releases")
local args=("--flake" "--commit" "--use-github-releases")
# Handle subpackages (opencode has node_modules)
if [ "$pkg" = "opencode" ]; then
args+=("--subpackage" "node_modules")
fi
args+=("$pkg")
args+=("$pkg")
if nix-update "${args[@]}" 2>&1 | tee /tmp/update-${pkg}.log; then
if [ "$(check_commit "$before_hash")" = "true" ]; then
@@ -201,7 +264,7 @@ jobs:
fi
- name: Verify Builds
if: steps.update.outputs.has_updates == 'true'
if: steps.update.outputs.has_updates == 'true' || steps.update-opencode.outputs.opencode_update == 'true'
run: |
cd "$REPO_DIR"
@@ -253,11 +316,20 @@ jobs:
echo "✅ All packages built successfully: ${SUCCESSFUL_PACKAGES[*]}"
- name: Push Changes
if: steps.update.outputs.has_updates == 'true'
if: steps.update.outputs.has_updates == 'true' || steps.update-opencode.outputs.opencode_update == 'true'
run: |
cd "$REPO_DIR"
PACKAGES="${{ steps.update.outputs.updated_packages }}"
# Add opencode to packages list if it was updated
if [ "${{ steps.update-opencode.outputs.opencode_update }}" = "true" ]; then
if [ -n "$PACKAGES" ]; then
PACKAGES="$PACKAGES, opencode"
else
PACKAGES="opencode"
fi
fi
echo "::group::Git Operations"
echo "Current commit: $(git rev-parse HEAD)"
echo "Pending commits: $(git rev-list --count origin/master..HEAD)"
@@ -290,6 +362,7 @@ jobs:
path: |
/tmp/update-*.log
/tmp/build-*.log
/tmp/opencode-build.log
retention-days: 7
- name: Cleanup
@@ -303,7 +376,7 @@ jobs:
rm -rf "$REPO_DIR"
# Remove all log files
rm -f /tmp/update-*.log /tmp/build-*.log /tmp/update-log.txt /tmp/success-packages.txt
rm -f /tmp/update-*.log /tmp/build-*.log /tmp/opencode-build.log /tmp/update-log.txt /tmp/success-packages.txt
# Clear sensitive environment variables
unset GIT_AUTHOR_EMAIL GIT_COMMITTER_EMAIL
@@ -311,17 +384,31 @@ jobs:
- name: Summary
if: always()
run: |
HAS_UPDATES="false"
if [ "${{ steps.update.outputs.has_updates }}" = "true" ]; then
HAS_UPDATES="true"
echo "# ✅ Update Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Updated Packages" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`${{ steps.update.outputs.updated_packages }}\`" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ steps.update-opencode.outputs.opencode_update }}" = "true" ]; then
HAS_UPDATES="true"
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Updated Flake Input" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **opencode**: \`v${{ steps.update-opencode.outputs.opencode_version }}\`" >> $GITHUB_STEP_SUMMARY
fi
if [ "$HAS_UPDATES" = "true" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- ✅ All packages validated with \`nix flake check\`" >> $GITHUB_STEP_SUMMARY
echo "- ✅ All packages built successfully" >> $GITHUB_STEP_SUMMARY
echo "- ✅ All updates validated with \`nix flake check\`" >> $GITHUB_STEP_SUMMARY
echo "- ✅ All builds successful" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Changes pushed to master" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Workflow Performance" >> $GITHUB_STEP_SUMMARY
@@ -332,5 +419,5 @@ jobs:
else
echo "# No Updates Required" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "No package updates found this run. All packages are up to date." >> $GITHUB_STEP_SUMMARY
echo "No updates found this run. All packages and flake inputs are up to date." >> $GITHUB_STEP_SUMMARY
fi

38
flake.lock generated
View File

@@ -16,9 +16,45 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1768569498,
"narHash": "sha256-bB6Nt99Cj8Nu5nIUq0GLmpiErIT5KFshMQJGMZwgqUo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "be5afa0fcb31f0a96bf9ecba05a516c66fcd8114",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"opencode": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1768911228,
"narHash": "sha256-iJ4WLNyP9i8baxp1FJJLv2VBD3XcE8nCruwO3GmSmK4=",
"owner": "anomalyco",
"repo": "opencode",
"rev": "e521fee0023a604bb6d5ef39b4b892cbf1a0f9d4",
"type": "github"
},
"original": {
"owner": "anomalyco",
"ref": "v1.1.27",
"repo": "opencode",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"opencode": "opencode"
}
}
},

View File

@@ -3,6 +3,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
opencode.url = "github:anomalyco/opencode/v1.1.27";
# Optional: Add stable channel if needed
# nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
@@ -36,18 +37,18 @@
system: let
pkgs = pkgsFor system;
in
import ./pkgs {inherit pkgs;}
import ./pkgs {inherit pkgs inputs;}
);
# Overlays - can be imported in your system configuration
overlays = {
# Default overlay: adds all custom packages
default = final: prev:
import ./pkgs {pkgs = final;};
import ./pkgs {pkgs = final; inputs = inputs;};
# Individual overlays for more granular control
additions = final: prev:
import ./pkgs {pkgs = final;};
import ./pkgs {pkgs = final; inputs = inputs;};
modifications = final: prev:
import ./overlays/mods {inherit prev;};

View File

@@ -3,7 +3,6 @@
# This overlay contains package overrides and modifications
# n8n = import ./n8n.nix {inherit prev;};
# opencode = import ./opencode.nix {inherit prev;};
# beads = import ./beads.nix {inherit prev;};
# Add more modifications here as needed

View File

@@ -1,16 +0,0 @@
{prev}:
prev.opencode.overrideAttrs (oldAttrs: rec {
version = "1.1.18";
src = prev.fetchFromGitHub {
owner = "anomalyco";
repo = "opencode";
tag = "v${version}";
hash = "sha256-3A4s0FpjZuGB0HGMQVBXfWq+0yHmeIvnEQTSX3amV4I=";
};
node_modules = oldAttrs.node_modules.overrideAttrs (old: {
inherit version src;
outputHash = "sha256-zSco4ORQQOqV3vMPuP+M/q/hBa+MJGnTKIlxgngMA3g=";
});
})

View File

@@ -11,16 +11,16 @@
}:
buildGoModule (finalAttrs: {
pname = "beads";
version = "0.47.1";
version = "0.48.0";
src = fetchFromGitHub {
owner = "steveyegge";
repo = "beads";
tag = "v${finalAttrs.version}";
hash = "sha256-DwIR/r1TJnpVd/CT1E2OTkAjU7k9/KHbcVwg5zziFVg=";
hash = "sha256-baOx+L+arkzcBqMXvN8r7rHSZGfDMRJMpgUEB9gEAls=";
};
vendorHash = "sha256-pY5m5ODRgqghyELRwwxOr+xlW41gtJWLXaW53GlLaFw=";
vendorHash = "sha256-YU+bRLVlWtHzJ1QPzcKJ70f+ynp8lMoIeFlm+29BNPE=";
subPackages = ["cmd/bd"];

View File

@@ -1,4 +1,12 @@
{pkgs, ...}: {
{pkgs, inputs ? null, ...}: let
# Upstream opencode v1.1.27 strictly requires Bun 1.3.5 but its locked nixpkgs provides 1.3.6
# We patch package.json to match the environment version to fix the build
opencode = inputs.opencode.packages.${pkgs.system}.opencode.overrideAttrs (old: {
postPatch = (old.postPatch or "") + ''
substituteInPlace package.json --replace-fail "bun@1.3.5" "bun@1.3.6"
'';
});
in {
# Custom packages registry
# Each package is defined in its own directory under pkgs/
beads = pkgs.callPackage ./beads {};
@@ -8,10 +16,13 @@
mem0 = pkgs.callPackage ./mem0 {};
msty-studio = pkgs.callPackage ./msty-studio {};
n8n = pkgs.callPackage ./n8n {};
opencode = pkgs.callPackage ./opencode {};
pomodoro-timer = pkgs.callPackage ./pomodoro-timer {};
rofi-project-opener = pkgs.callPackage ./rofi-project-opener {};
stt-ptt = pkgs.callPackage ./stt-ptt {};
tuxedo-backlight = pkgs.callPackage ./tuxedo-backlight {};
zellij-ps = pkgs.callPackage ./zellij-ps {};
# Imported from flake inputs
inherit opencode;
opencode-desktop = inputs.opencode.packages.${pkgs.system}.desktop.override { inherit opencode; };
}

View File

@@ -18,20 +18,20 @@
}:
stdenv.mkDerivation (finalAttrs: {
pname = "n8n";
version = "n8n@2.3.6";
version = "n8n@2.4.4";
src = fetchFromGitHub {
owner = "n8n-io";
repo = "n8n";
tag = finalAttrs.version;
hash = "sha256-9TGX99elCmB0Y/ttfQrC2HNxyQQcdGIazo8BWqhN634=";
hash = "sha256-cp8Wpgocj+wrHwTkTvVyldAn/E9IiYnC65vxAFAG/jg=";
};
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version src;
pnpm = pnpm_10;
fetcherVersion = 3;
hash = "sha256-dSofdsoTERdq28ZGyz+Nza1Y5fnyPcuRIk38WeLqNVE=";
hash = "sha256-QtusZm9WaLMjfopsX4t2WiiU++j3V/PQHbelKubhMII=";
};
nativeBuildInputs =

View File

@@ -1,222 +0,0 @@
{
lib,
stdenvNoCC,
bun,
fetchFromGitHub,
fzf,
makeBinaryWrapper,
models-dev,
nix-update-script,
ripgrep,
testers,
installShellFiles,
writableTmpDirAsHomeHook,
}: let
pname = "opencode";
version = "1.1.25";
src = fetchFromGitHub {
owner = "anomalyco";
repo = "opencode";
tag = "v${version}";
hash = "sha256-aF+4LL0x9wU2Ktrv/nJE2VXgUeXFrwJ16pa1sGNhpi4=";
};
node_modules = stdenvNoCC.mkDerivation {
pname = "${pname}-node_modules";
inherit version src;
impureEnvVars =
lib.fetchers.proxyImpureEnvVars
++ ["GIT_PROXY_COMMAND" "SOCKS_SERVER"];
nativeBuildInputs = [bun writableTmpDirAsHomeHook];
dontConfigure = true;
buildPhase = ''
runHook preBuild
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
bun install \
--cpu="*" \
--filter=./packages/opencode \
--force \
--frozen-lockfile \
--ignore-scripts \
--no-progress \
--os="*" \
--production
bun run ./nix/scripts/canonicalize-node-modules.ts
bun run ./nix/scripts/normalize-bun-binaries.ts
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
find . -type d -name node_modules -exec cp -R --parents {} $out \;
runHook postInstall
'';
# NOTE: Required else we get errors that our fixed-output derivation references store paths
dontFixup = true;
outputHash = "sha256-qheQCN71VM3M35+j9XhaCdxQNo5ze8mV8sDFaX0WVWM=";
outputHashAlgo = "sha256";
outputHashMode = "recursive";
};
in
stdenvNoCC.mkDerivation (finalAttrs: {
inherit pname version src node_modules;
nativeBuildInputs = [
bun
installShellFiles
makeBinaryWrapper
models-dev
writableTmpDirAsHomeHook
];
patches = [
# NOTE: Relax Bun version check to be a warning instead of an error
./relax-bun-version-check.patch
];
dontConfigure = true;
env.MODELS_DEV_API_JSON = "${models-dev}/dist/_api.json";
env.OPENCODE_VERSION = finalAttrs.version;
env.OPENCODE_CHANNEL = "stable";
buildPhase = ''
runHook preBuild
# Copy all node_modules including the .bun directory with actual packages
cp -r ${finalAttrs.node_modules}/node_modules .
cp -r ${finalAttrs.node_modules}/packages .
(
cd packages/opencode
# Fix symlinks to workspace packages
chmod -R u+w ./node_modules
mkdir -p ./node_modules/@opencode-ai
rm -f ./node_modules/@opencode-ai/{script,sdk,plugin}
ln -s $(pwd)/../../packages/script ./node_modules/@opencode-ai/script
ln -s $(pwd)/../../packages/sdk/js ./node_modules/@opencode-ai/sdk
ln -s $(pwd)/../../packages/plugin ./node_modules/@opencode-ai/plugin
# Use upstream bundle.ts for Nix-compatible bundling
cp ../../nix/bundle.ts ./bundle.ts
chmod +x ./bundle.ts
bun run ./bundle.ts
)
runHook postBuild
'';
installPhase = ''
runHook preInstall
cd packages/opencode
if [ ! -d dist ]; then
echo "ERROR: dist directory missing after bundle step"
exit 1
fi
mkdir -p $out/lib/opencode
cp -r dist $out/lib/opencode/
chmod -R u+w $out/lib/opencode/dist
# Select bundled worker assets deterministically (sorted find output)
worker_file=$(find "$out/lib/opencode/dist" -type f \( -path '*/tui/worker.*' -o -name 'worker.*' \) | sort | head -n1)
parser_worker_file=$(find "$out/lib/opencode/dist" -type f -name 'parser.worker.*' | sort | head -n1)
if [ -z "$worker_file" ]; then
echo "ERROR: bundled worker not found"
exit 1
fi
main_wasm=$(printf '%s\n' "$out"/lib/opencode/dist/tree-sitter-*.wasm | sort | head -n1)
wasm_list=$(find "$out/lib/opencode/dist" -maxdepth 1 -name 'tree-sitter-*.wasm' -print)
for patch_file in "$worker_file" "$parser_worker_file"; do
[ -z "$patch_file" ] && continue
[ ! -f "$patch_file" ] && continue
if [ -n "$wasm_list" ] && grep -q 'tree-sitter' "$patch_file"; then
# Rewrite wasm references to absolute store paths to avoid runtime resolve failures.
bun --bun ../../nix/scripts/patch-wasm.ts "$patch_file" "$main_wasm" $wasm_list
fi
done
mkdir -p $out/lib/opencode/node_modules
cp -r ../../node_modules/.bun $out/lib/opencode/node_modules/
mkdir -p $out/lib/opencode/node_modules/@opentui
# Generate and install JSON schema
mkdir -p $out/share/opencode
HOME=$TMPDIR bun --bun script/schema.ts $out/share/opencode/schema.json
mkdir -p $out/bin
makeWrapper ${lib.getExe bun} $out/bin/opencode \
--add-flags "run" \
--add-flags "$out/lib/opencode/dist/src/index.js" \
--prefix PATH : ${lib.makeBinPath [fzf ripgrep]} \
--argv0 opencode
runHook postInstall
'';
postInstall = ''
# Add symlinks for platform-specific native modules
pkgs=(
$out/lib/opencode/node_modules/.bun/@opentui+core-*
$out/lib/opencode/node_modules/.bun/@opentui+solid-*
$out/lib/opencode/node_modules/.bun/@opentui+core@*
$out/lib/opencode/node_modules/.bun/@opentui+solid@*
)
for pkg in "''${pkgs[@]}"; do
if [ -d "$pkg" ]; then
pkgName=$(basename "$pkg" | sed 's/@opentui+\([^@]*\)@.*/\1/')
ln -sf ../.bun/$(basename "$pkg")/node_modules/@opentui/$pkgName \
$out/lib/opencode/node_modules/@opentui/$pkgName
fi
done
${lib.optionalString
((stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform)
&& (stdenvNoCC.hostPlatform.system != "x86_64-darwin")) ''
installShellCompletion --cmd opencode \
--bash <($out/bin/opencode completion)
''}
'';
passthru = {
jsonschema = "${placeholder "out"}/share/opencode/schema.json";
tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "HOME=$(mktemp -d) opencode --version";
inherit (finalAttrs) version;
};
updateScript =
nix-update-script {extraArgs = ["--subpackage" "node_modules"];};
};
meta = {
description = "AI coding agent built for the terminal";
longDescription = ''
OpenCode is a terminal-based agent that can build anything.
It combines a TypeScript/JavaScript core with a Go-based TUI
to provide an interactive AI coding experience.
'';
homepage = "https://github.com/anomalyco/opencode";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [delafthi];
sourceProvenance = with lib.sourceTypes; [fromSource];
platforms = ["aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
mainProgram = "opencode";
};
})

View File

@@ -1,28 +0,0 @@
From 0e07ea8225f5667e39c6aa59eea726266f0afab0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Thu, 13 Nov 2025 10:16:31 +0100
Subject: [PATCH] Change Bun version check from error to warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
---
packages/script/src/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts
index 141d2b75..de06d0dc 100644
--- a/packages/script/src/index.ts
+++ b/packages/script/src/index.ts
@@ -10,7 +10,7 @@ if (!expectedBunVersion) {
}
if (process.versions.bun !== expectedBunVersion) {
- throw new Error(`This script requires bun@${expectedBunVersion}, but you are using bun@${process.versions.bun}`)
+ console.warn(`Warning: This script expects bun@${expectedBunVersion}, but you are using bun@${process.versions.bun}`)
}
const CHANNEL = process.env["OPENCODE_CHANNEL"] ?? (await $`git branch --show-current`.text().then((x) => x.trim()))
--
2.51.0