Split runtime node_modules into reusable layers
- Add shared installFlags support to the common Bun node_modules builder - Factor base and desktop overlay node_modules derivations for reuse - Reuse the new runtime node_modules outputs in desktop and server builds
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
|
||||
pname = "t3code-desktop";
|
||||
version = desktopPackageJson.version;
|
||||
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
inherit pname version;
|
||||
@@ -71,6 +70,42 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
runtimeNodeModules = common.mkNodeModules {
|
||||
inherit (finalAttrs) pname version src;
|
||||
outputHash = "sha256-q1xo2GiU3Ct4Sq5+qGsfXMI0ei1c5AXkdq0GaBWr1PI=";
|
||||
installFlags = [
|
||||
"--production"
|
||||
];
|
||||
filters = [
|
||||
"."
|
||||
"./apps/desktop"
|
||||
"./apps/server"
|
||||
"./apps/web"
|
||||
"./packages/client-runtime"
|
||||
"./packages/contracts"
|
||||
"./packages/effect-acp"
|
||||
"./packages/effect-codex-app-server"
|
||||
"./packages/shared"
|
||||
];
|
||||
impureEnvVars =
|
||||
lib.fetchers.proxyImpureEnvVars
|
||||
++ [
|
||||
"GIT_PROXY_COMMAND"
|
||||
"SOCKS_SERVER"
|
||||
];
|
||||
extraNativeBuildInputs = [
|
||||
gcc
|
||||
gnumake
|
||||
pkg-config
|
||||
python3
|
||||
];
|
||||
extraEnv = ''
|
||||
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
|
||||
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
export npm_config_build_from_source=true
|
||||
'';
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
asar
|
||||
bun
|
||||
@@ -104,8 +139,10 @@ in
|
||||
|
||||
bun run build:desktop
|
||||
node ${./build-nix-desktop-package.mjs} --output-dir packaged-app
|
||||
cp -R node_modules packaged-app/node_modules
|
||||
cp -R ${finalAttrs.runtimeNodeModules} packaged-app/node_modules
|
||||
chmod -R u+rwX packaged-app/node_modules
|
||||
rm -rf packaged-app/node_modules/node-pty
|
||||
cp -R node_modules/node-pty packaged-app/node_modules/
|
||||
patchShebangs packaged-app/node_modules
|
||||
find packaged-app/node_modules -xtype l -delete
|
||||
rm -rf packaged-app/node_modules/electron
|
||||
@@ -132,9 +169,9 @@ in
|
||||
--set-default ELECTRON_FORCE_IS_PACKAGED 1 \
|
||||
--set-default ELECTRON_IS_DEV 0 \
|
||||
--prefix PATH : ${lib.makeBinPath [
|
||||
git
|
||||
xdg-utils
|
||||
]} \
|
||||
git
|
||||
xdg-utils
|
||||
]} \
|
||||
--add-flags "$out/share/${pname}/resources/app.asar"
|
||||
|
||||
export out
|
||||
|
||||
Reference in New Issue
Block a user