From 738856c15fdf12a51cfea623fe7b0d2f2fda7b0b Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Thu, 2 Apr 2026 04:41:02 +0000 Subject: [PATCH] fix agent-browser --- home/agent-browser.nix | 18 +++++++++++++++--- hosts/netty/configuration.nix | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/home/agent-browser.nix b/home/agent-browser.nix index 0121295..0e3b54b 100644 --- a/home/agent-browser.nix +++ b/home/agent-browser.nix @@ -12,7 +12,10 @@ lib.mkIf (!hostConfig.isDarwin) { args = "--no-sandbox,--disable-gpu,--disable-dev-shm-usage"; }; - # Install agent-browser globally via npm at activation time + # Install agent-browser globally via npm at activation time. + # npm's postinstall symlinks the glibc binary, which fails on NixOS + # (no /lib64/ld-linux-x86-64.so.2). Re-point the symlink at the + # statically-linked musl binary that works everywhere. home.activation.installAgentBrowser = lib.hm.dag.entryAfter [ "writeBoundary" ] '' export PATH="${ lib.makeBinPath [ @@ -21,9 +24,18 @@ lib.mkIf (!hostConfig.isDarwin) { ] }:$PATH" - npm_bin="$(npm prefix -g 2>/dev/null)/bin" - if [ ! -x "$npm_bin/agent-browser" ]; then + npm_prefix="$(npm prefix -g 2>/dev/null)" + npm_bin="$npm_prefix/bin" + pkg_bin="$npm_prefix/lib/node_modules/agent-browser/bin" + + if [ ! -e "$pkg_bin/agent-browser-linux-musl-x64" ]; then npm install -g agent-browser 2>/dev/null || true fi + + # Fix: replace glibc symlink with statically-linked musl binary + if [ -e "$pkg_bin/agent-browser-linux-musl-x64" ]; then + chmod +x "$pkg_bin/agent-browser-linux-musl-x64" 2>/dev/null || true + ln -sf "$pkg_bin/agent-browser-linux-musl-x64" "$npm_bin/agent-browser" + fi ''; } diff --git a/hosts/netty/configuration.nix b/hosts/netty/configuration.nix index a91d9b0..86803d0 100644 --- a/hosts/netty/configuration.nix +++ b/hosts/netty/configuration.nix @@ -105,6 +105,10 @@ in services.journald.extraConfig = "MaxRetainedFileSec=1week"; + # Provide /lib64/ld-linux-x86-64.so.2 so unpatched binaries + # from npm, cargo-install, etc. can run without patchelf. + programs.nix-ld.enable = true; + virtualisation.docker.enable = true; environment.systemPackages = packageSets.extras ++ [