fix: skip ELECTRON_FORCE_IS_PACKAGED for NixOS builds

On NixOS, Electron is a separate Nix store path from the app, so
process.resourcesPath points to Electron's resources dir rather than
the app's. Claude's app code uses app.isPackaged to choose between
resourcesPath-based and development-style fallback paths. Setting
ELECTRON_FORCE_IS_PACKAGED=true (introduced by PR #305) forces the
resourcesPath code paths, which resolve to the wrong location on
NixOS, causing a silent startup hang.

Skip the env var for 'nix' package type so isPackaged remains false,
restoring the working behavior from before PR #305.

Fixes #311

Co-Authored-By: Claude <claude@anthropic.com>
This commit is contained in:
aaddrick
2026-03-20 09:46:57 -04:00
parent 1e2db5c0fe
commit c3cc5a6b16
2 changed files with 15 additions and 2 deletions

View File

@@ -169,7 +169,7 @@ fi
# Setup logging and environment
setup_logging || exit 1
setup_electron_env
setup_electron_env 'nix'
cleanup_stale_lock
cleanup_stale_cowork_socket

View File

@@ -147,8 +147,21 @@ cleanup_stale_cowork_socket() {
}
# Set common environment variables
# Arguments: $1 = package type ("deb", "appimage", "rpm", or "nix")
setup_electron_env() {
export ELECTRON_FORCE_IS_PACKAGED=true
local package_type="${1:-deb}"
# ELECTRON_FORCE_IS_PACKAGED makes app.isPackaged return true, which
# causes the Claude app to resolve resources via process.resourcesPath.
# On NixOS, Electron is a separate store path so resourcesPath points
# to Electron's resources dir, not the app's. The frame-fix-wrapper
# corrects this at JS load time, but some app code may run before the
# fix or cache the original value. Skipping this env var for Nix
# keeps isPackaged=false, using development-style fallback paths that
# work correctly with NixOS's split-package layout.
if [[ $package_type != 'nix' ]]; then
export ELECTRON_FORCE_IS_PACKAGED=true
fi
export ELECTRON_USE_SYSTEM_TITLE_BAR=1
}