fix(nix): shrink desktop runtime output (#2550)

Package only the traced desktop and daemon runtime graph, preserve required runtime entrypoints, and exclude the npm Electron distribution supplied by nixpkgs.
This commit is contained in:
Ivan Malison
2026-08-01 01:37:18 +02:00
committed by GitHub
parent b560c1184c
commit b960594d44
2 changed files with 63 additions and 14 deletions
+24 -1
View File
@@ -28,14 +28,24 @@ const { sherpaPlatformPackageName } = await import(
).href
);
const traceDesktop = process.env.PASEO_TRACE_DESKTOP === "1";
// Daemon entry points. Workers forked into their own Node processes have
// independent require trees; nft does not follow fork boundaries, so trace
// them separately.
// them separately. The desktop derivation opts into tracing its Electron main
// process and preloads as well.
const entries = [
"packages/cli/dist/index.js",
"packages/server/dist/scripts/supervisor-entrypoint.js",
"packages/server/dist/server/terminal/terminal-worker-process.js",
"packages/server/dist/server/server/speech/providers/local/worker-process.js",
...(traceDesktop
? [
"packages/desktop/dist/main.js",
"packages/desktop/dist/preload.js",
"packages/desktop/dist/features/browser-keyboard/guest-preload.js",
]
: []),
];
// Files read at runtime via fs APIs rather than `require`. nft only
@@ -59,6 +69,16 @@ const additionalInputs = [
// Copy the wrapper plus the host platform package explicitly.
"node_modules/sherpa-onnx-node/**",
`node_modules/${sherpaPlatformPackageName()}/**`,
...(traceDesktop
? [
// The unpackaged Nix launcher resolves these beside desktop/dist.
"packages/desktop/package.json",
"packages/desktop/assets/**",
// resolveExternalCliEntrypoint() looks up the workspace through this
// link at runtime; nft traces the target files but not the link.
"node_modules/@getpaseo/cli",
]
: []),
];
// Trace.
@@ -83,6 +103,9 @@ const { fileList, warnings } = await nodeFileTrace(entries, {
// tries to walk into them via index files. Belt and suspenders.
"**/*.test.js",
"**/*.e2e.test.js",
// The Nix desktop package runs under nixpkgs' Electron. Tracing the npm
// package would duplicate the complete Electron distribution in $out.
...(traceDesktop ? ["node_modules/electron/**"] : []),
],
});