From a54cb66bf621aa6c198a9f9f86be7cd65ce643ce Mon Sep 17 00:00:00 2001 From: Shintaro Sakata <56592600+shin-sakata@users.noreply.github.com> Date: Sat, 1 Aug 2026 06:29:02 +0900 Subject: [PATCH] fix(nix): keep runtime mode out of agent environment (#2697) --- nix/module.nix | 1 - nix/package.nix | 3 ++- .../26-daemon-launch-supervision.test.ts | 21 ++++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/nix/module.nix b/nix/module.nix index 72ab1bf812..ae7f4a91ef 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -230,7 +230,6 @@ in ''; environment = { - NODE_ENV = "production"; PASEO_HOME = cfg.dataDir; PASEO_LISTEN = "${cfg.listenAddress}:${toString cfg.port}"; } // lib.optionalAttrs cfg.inheritUserEnvironment ( diff --git a/nix/package.nix b/nix/package.nix index 4b4ca73f1e..b30665b8c9 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -114,9 +114,10 @@ buildNpmPackage rec { # Create wrapper for the server entry point (for systemd / direct use) mkdir -p $out/bin + # Keep Paseo's runtime mode separate from NODE_ENV, which belongs to spawned agents. makeWrapper ${nodejs}/bin/node $out/bin/paseo-server \ --add-flags "$out/lib/paseo/packages/server/dist/scripts/supervisor-entrypoint.js" \ - --set NODE_ENV production + --set PASEO_NODE_ENV production # Create wrapper for the CLI makeWrapper ${nodejs}/bin/node $out/bin/paseo \ diff --git a/packages/cli/tests/26-daemon-launch-supervision.test.ts b/packages/cli/tests/26-daemon-launch-supervision.test.ts index e0e00bd002..bf9f2fa164 100644 --- a/packages/cli/tests/26-daemon-launch-supervision.test.ts +++ b/packages/cli/tests/26-daemon-launch-supervision.test.ts @@ -18,6 +18,7 @@ const serverConnectionOfferE2ePath = join( ); const desktopRuntimePathsPath = join(repoRoot, "packages/desktop/src/daemon/runtime-paths.ts"); const nixPackagePath = join(repoRoot, "nix/package.nix"); +const nixModulePath = join(repoRoot, "nix/module.nix"); function assertNoDirectWorkerLaunch(label: string, command: string): void { assert( @@ -100,6 +101,24 @@ assert( "Nix paseo-server wrapper should use dist/scripts/supervisor-entrypoint.js", ); assertNoDirectWorkerLaunch("Nix package wrapper", nixPackage); -console.log("✓ desktop runtime and Nix wrapper enter supervisor\n"); +assert( + nixPackage.includes("--set PASEO_NODE_ENV production"), + "Nix paseo-server wrapper should keep the daemon runtime mode Paseo-scoped", +); +assert( + !/--set(-default)?\s+NODE_ENV\b/.test(nixPackage), + "Nix paseo-server wrapper must not leak NODE_ENV to external agent processes", +); + +const nixModule = await readFile(nixModulePath, "utf-8"); +assert( + !/\bNODE_ENV\b\s*=/.test(nixModule), + "NixOS module must not leak NODE_ENV to external agent processes", +); +assert( + !/\bPASEO_NODE_ENV\b/.test(nixModule), + "NixOS module must not duplicate the packaged daemon runtime mode", +); +console.log("✓ desktop runtime and Nix wrapper enter supervisor without leaking runtime env\n"); console.log("=== Daemon launch supervision regression test passed ===");