fix(nix): keep runtime mode out of agent environment (#2697)
This commit is contained in:
@@ -230,7 +230,6 @@ in
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
NODE_ENV = "production";
|
|
||||||
PASEO_HOME = cfg.dataDir;
|
PASEO_HOME = cfg.dataDir;
|
||||||
PASEO_LISTEN = "${cfg.listenAddress}:${toString cfg.port}";
|
PASEO_LISTEN = "${cfg.listenAddress}:${toString cfg.port}";
|
||||||
} // lib.optionalAttrs cfg.inheritUserEnvironment (
|
} // lib.optionalAttrs cfg.inheritUserEnvironment (
|
||||||
|
|||||||
+2
-1
@@ -114,9 +114,10 @@ buildNpmPackage rec {
|
|||||||
|
|
||||||
# Create wrapper for the server entry point (for systemd / direct use)
|
# Create wrapper for the server entry point (for systemd / direct use)
|
||||||
mkdir -p $out/bin
|
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 \
|
makeWrapper ${nodejs}/bin/node $out/bin/paseo-server \
|
||||||
--add-flags "$out/lib/paseo/packages/server/dist/scripts/supervisor-entrypoint.js" \
|
--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
|
# Create wrapper for the CLI
|
||||||
makeWrapper ${nodejs}/bin/node $out/bin/paseo \
|
makeWrapper ${nodejs}/bin/node $out/bin/paseo \
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const serverConnectionOfferE2ePath = join(
|
|||||||
);
|
);
|
||||||
const desktopRuntimePathsPath = join(repoRoot, "packages/desktop/src/daemon/runtime-paths.ts");
|
const desktopRuntimePathsPath = join(repoRoot, "packages/desktop/src/daemon/runtime-paths.ts");
|
||||||
const nixPackagePath = join(repoRoot, "nix/package.nix");
|
const nixPackagePath = join(repoRoot, "nix/package.nix");
|
||||||
|
const nixModulePath = join(repoRoot, "nix/module.nix");
|
||||||
|
|
||||||
function assertNoDirectWorkerLaunch(label: string, command: string): void {
|
function assertNoDirectWorkerLaunch(label: string, command: string): void {
|
||||||
assert(
|
assert(
|
||||||
@@ -100,6 +101,24 @@ assert(
|
|||||||
"Nix paseo-server wrapper should use dist/scripts/supervisor-entrypoint.js",
|
"Nix paseo-server wrapper should use dist/scripts/supervisor-entrypoint.js",
|
||||||
);
|
);
|
||||||
assertNoDirectWorkerLaunch("Nix package wrapper", nixPackage);
|
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 ===");
|
console.log("=== Daemon launch supervision regression test passed ===");
|
||||||
|
|||||||
Reference in New Issue
Block a user