fix: strip leading whitespace before shebang in mcpedia-web wrapper script
CI / typecheck + tests (push) Canceled after 0s
CI / build + deploy (Nix) — api (push) Canceled after 0s
CI / build + deploy (Nix) — mcp (push) Canceled after 0s
CI / build + deploy (Nix) — worker (push) Canceled after 0s
CI / build + deploy (web) (push) Canceled after 0s

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.
This commit is contained in:
MythEclipse
2026-08-21 21:24:16 +07:00
parent c22e394f98
commit 2a70a111a2
+13 -20
View File
@@ -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 <nixpkgs> {}; 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 <<WRAPPER
#!/usr/bin/env bash
export NODE_ENV=production
export PORT=4016
cd /home/code/mcpedia/apps/web
rm -f .next
ln -s "$NEXT_DIR" .next
exec "$BUN_BIN" x next start -p 4016
WRAPPER
chmod +x $out/bin/mcpedia-web
cp ${mcpedia-web-script}/bin/mcpedia-web $out/bin/mcpedia-web
'';
}