From 2a70a111a23b7c88405443491a0becb8012b2d6f Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Fri, 21 Aug 2026 21:24:16 +0700 Subject: [PATCH] fix: strip leading whitespace before shebang in mcpedia-web wrapper script The heredoc-based script writer in web.nix was indenting content inside a nix '' string, which caused bash to prepend whitespace before the #!/usr/bin/env bash shebang. The kernel rejected this as 'Exec format error' (203/EXEC), preventing systemd from starting mcpedia-web.service. Fix: use writeShellScriptBin instead of a raw heredoc. This ensures the shebang starts at column 0 and uses the nix-resolved bash path. --- web.nix | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/web.nix b/web.nix index 94b8ae6..65fcdd0 100644 --- a/web.nix +++ b/web.nix @@ -1,12 +1,6 @@ -# ─── Web: packages pre-built .next into a Nix store path ────────────────── +# ─── Web: packages pre-built .next into a Nix store path ─── # Next.js 16/Turbopack has a Bun incompatibility in the Nix sandbox, # so .next is built in CI via `bun run build` and packaged here. -# -# Usage: -# nix-build -E 'with import {}; callPackage ./web.nix { webNextDir = /abs/apps/web/.next; }' -# -# The wrapper symlinks .next from the Nix store (read-only, instant), -# then runs `bunx next start` from the repo checkout. { pkgs , stdenv , writeShellScriptBin @@ -15,6 +9,17 @@ , ... }: +let + mcpedia-web-script = writeShellScriptBin "mcpedia-web" '' + #!${pkgs.bash}/bin/bash + export NODE_ENV=production + export PORT=4016 + cd /home/code/mcpedia/apps/web + rm -f .next + ln -s "${webNextDir}" .next + exec "${bun}/bin/bun" x next start -p 4016 + ''; +in stdenv.mkDerivation { pname = "mcpedia-web"; version = "1.0.0"; @@ -25,19 +30,7 @@ stdenv.mkDerivation { mkdir -p $out/share/mcpedia-web/.next cp -r "${webNextDir}/." $out/share/mcpedia-web/.next/ - NEXT_DIR="$out/share/mcpedia-web/.next" - BUN_BIN="${bun}/bin/bun" - mkdir -p $out/bin - cat > $out/bin/mcpedia-web <