Skip to content

Commit 1e69b37

Browse files
author
atomic-235
committed
fix: patchelf opencode to fix glibc mismatch segfault on WSL2
nixpkgs opencode uses stdenvNoCC with no patchelf — binary gets mismatched glibc versions (ld-linux 2.40 vs libc 2.42). OverrideAttrs adds patchelf postFixup to force consistent glibc. See: anomalyco/opencode#26846
1 parent 5458d6e commit 1e69b37

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎modules/packages.nix‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{ pkgs, ... }:
22

3+
let
4+
# Fix opencode segfault on WSL2 — nixpkgs bug: glibc 2.42/2.40 mismatch
5+
# opencode derivation uses stdenvNoCC with no patchelf, causing
6+
# ld-linux (glibc 2.40) to mismatch libc.so.6 (glibc 2.42)
7+
# See: https://github.com/anomalyco/opencode/issues/26846
8+
opencode-fixed = pkgs.opencode.overrideAttrs (old: {
9+
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.patchelf ];
10+
postFixup = (old.postFixup or "") + ''
11+
${pkgs.patchelf}/bin/patchelf --set-rpath ${pkgs.glibc}/lib $out/bin/opencode
12+
${pkgs.patchelf}/bin/patchelf --set-interpreter ${pkgs.glibc}/lib64/ld-linux-x86-64.so.2 $out/bin/opencode
13+
'';
14+
});
15+
in
316
{
417
home.packages = with pkgs; [
518
# Editors
@@ -33,7 +46,7 @@
3346
fastfetch
3447

3548
# AI coding agent
36-
opencode
49+
opencode-fixed
3750

3851
# Build tools (needed by nvim-treesitter to compile parsers)
3952
gcc

0 commit comments

Comments
 (0)