mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
discord: recreate module symlinks on every launch
As of commitb49b623a("discord: use distro layout for stable on Linux", PR #515876), Discord's launch script runs a `discord-stage-modules` script defined in `linux.nix`, which creates symlinks from `~/.config/discord/<version>/modules/<module_name>` to the corresponding Nix store paths so Discord can find them. It checks whether this has already been done by looking for `installed.json` in the same dir, which it also creates, and skips link creation if so. However, since the dir is indexed by Discord version number, the links are not refreshed when opening a new build of Discord with the same version number as an older build. If the old build is then GC'd, the links break and Discord fails to start with an error such as `Cannot find module 'discord_desktop_core'`. Deleting the module folder entirely allows for it to be recreated and for Discord to start without issue. This problem and solution are attested on the wiki, albeit with less explanation: https://wiki.nixos.org/wiki/Discord#Crash_on_start-up. The package fix is to delete and recreate the `modules` folder on each launch, as it is small and does not contain any data meant to persist between launches: it has only the module links, `installed.json`, and a `pending/` download directory recreated by Discord's updater on startup. The fix ensures that the links always point to the Nix store of the build of Discord being run, so they will not be broken by GC. Assisted-by: Claude Fable 5 in Claude Code (cherry picked from commit8f5437cf20)
This commit is contained in:
parent
3a45106ee8
commit
ccfb602b88
1 changed files with 7 additions and 8 deletions
|
|
@ -152,14 +152,13 @@ let
|
|||
stageModules = writeShellScript "discord-stage-modules" ''
|
||||
store_modules="$1"
|
||||
modules_dir="''${XDG_CONFIG_HOME:-$HOME/.config}/${lib.toLower binaryName}/${version}/modules"
|
||||
if [ ! -f "$modules_dir/installed.json" ]; then
|
||||
mkdir -p "$modules_dir"
|
||||
for m in ${lib.concatStringsSep " " (lib.attrNames moduleSrcs)}; do
|
||||
ln -sfn "$store_modules/$m" "$modules_dir/$m"
|
||||
done
|
||||
echo '${builtins.toJSON (lib.mapAttrs (_: mod: { installedVersion = mod; }) moduleVersions)}' \
|
||||
> "$modules_dir/installed.json"
|
||||
fi
|
||||
rm -rf "$modules_dir"
|
||||
mkdir -p "$modules_dir"
|
||||
for m in ${lib.concatStringsSep " " (lib.attrNames moduleSrcs)}; do
|
||||
ln -sn "$store_modules/$m" "$modules_dir/$m"
|
||||
done
|
||||
echo '${builtins.toJSON (lib.mapAttrs (_: mod: { installedVersion = mod; }) moduleVersions)}' \
|
||||
> "$modules_dir/installed.json"
|
||||
'';
|
||||
|
||||
disableBreakingUpdates =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue