Skip to content

discord: use distro layout for stable and Darwin - #515876

Merged
jopejoe1 merged 11 commits into
NixOS:masterfrom
4evy:flameflag/push-umluxmqntwuy
May 13, 2026
Merged

jopejoe1 merged 11 commits into
NixOS:masterfrom
4evy:flameflag/push-umluxmqntwuy

Conversation

@4evy

@4evy 4evy commented May 2, 2026 •

Copy link
Copy Markdown
Member

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@nixpkgs-ci nixpkgs-ci Bot added 8.has: package (update) This PR updates a package to a newer version 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. labels May 2, 2026
@4evy

This comment has been minimized.

@ofborg ofborg Bot added the 6.topic: darwin Running or building packages on Darwin label May 2, 2026
@4evy 4evy changed the title discord: use distro layout for macOS and drop OpenSSL 1.1 discord: use distro layout for macOS May 2, 2026
@4evy
4evy force-pushed the flameflag/push-umluxmqntwuy branch from dbfa93c to 50e92b6 Compare May 2, 2026 21:12
@nixpkgs-ci nixpkgs-ci Bot removed the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label May 2, 2026
@4evy

This comment has been minimized.

@4evy 4evy added the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label May 2, 2026
@nixpkgs-ci nixpkgs-ci Bot removed the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label May 2, 2026
@4evy
4evy force-pushed the flameflag/push-umluxmqntwuy branch from 50e92b6 to b49b623 Compare May 6, 2026 23:58
@4evy

4evy commented May 6, 2026

Copy link
Copy Markdown
Member Author

Repurposing this PR a bit: while working through the macOS distro layout change, I found that Linux stable finally got the distro layout too, so let's deal with that while we're here

@4evy 4evy changed the title discord: use distro layout for macOS discord: use distro layout for stable and Darwin May 6, 2026
Comment on lines +47 to +63
fixDistroSymlinks = writeScript "discord-fix-distro-symlinks.py" ''
#!${python3.interpreter}
import pathlib
import sys
import tarfile

with tarfile.open(sys.argv[1]) as tar:
for member in tar:
if not member.issym():
continue
parts = pathlib.PurePosixPath(member.name).parts[1:]
if not parts:
continue
path = pathlib.Path(sys.argv[2], *parts)
path.unlink(missing_ok=True)
path.symlink_to(member.linkname)
'';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discord's macOS distro tarballs store framework symlinks with mode 000, recreate them so the app bundle has readable symlinks

@nixpkgs-ci nixpkgs-ci Bot added the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label May 7, 2026
Comment on lines +65 to +76
stageModules = writeShellScript "discord-stage-modules" ''
store_modules="$1"
modules_dir="$HOME/Library/Application Support/${configDirName}/${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
'';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darwin still defaults to the legacy module updater path, which only adds the per-user <version>/modules directory to Node's module search path

The distro modules are stored in the Nix store, so this stages symlinks plus installed.json there to make Discord load the pinned modules instead of bootstrapping them at runtime

@4evy

4evy commented May 7, 2026

Copy link
Copy Markdown
Member Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 515876
Commit: b49b623ae22c544c250e891d3fdbec82ed5f3393 (subsequent changes)
Merge: 0e5c787eb2e94a8acc1b97295bfab28da10c55eb

Logs: https://github.com/FlameFlag/nixpkgs-review-gha/actions/runs/25467968754


x86_64-linux

✅ 4 packages built:
  • discord
  • discord-canary
  • discord-development
  • discord-ptb

aarch64-linux

✅ No rebuilds


x86_64-darwin (sandbox = relaxed)

✅ 4 packages built:
  • discord
  • discord-canary
  • discord-development
  • discord-ptb

aarch64-darwin (sandbox = relaxed)

✅ 4 packages built:
  • discord
  • discord-canary
  • discord-development
  • discord-ptb

@jopejoe1
jopejoe1 added this pull request to the merge queue May 13, 2026
@jopejoe1

Copy link
Copy Markdown
Member

Thanks for putting all this research into how the new discord update process work ^^

Merged via the queue into NixOS:master with commit fff0186 May 13, 2026
33 of 35 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Backport failed for release-25.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-25.11
git worktree add -d .worktree/backport-515876-to-release-25.11 origin/release-25.11
cd .worktree/backport-515876-to-release-25.11
git switch --create backport-515876-to-release-25.11
git cherry-pick -x f069e07d2bff540335b01f31920c54c6877f5e97 b45dc30858ce125bb5ba6d117a2072df10783909 a7c378c095f4f13bd1be524c4f668dd95e60259b 48dd7b3c34fff167391ced88bc97a1b66e7cd353 0f6c97b536c10d40518fb2dbc28e5b747f137374 fda82730c08c4dc68f53917f8530a635aae60279 19aa7391cae79ed6b97917f5f331ddee0fc476cb b851333c77487f0e6a680bc0305d4b321b4ca0df b7c15d7f2e30e0db5549f1deb97eb2519fde1233 2a82a95464b9aae569a39e9018cf12e25b3d9fc3 b49b623ae22c544c250e891d3fdbec82ed5f3393

@4evy
4evy deleted the flameflag/push-umluxmqntwuy branch May 13, 2026 22:29
Mathtician added a commit to Mathtician/nixpkgs that referenced this pull request Jun 11, 2026
As of commit b49b623 ("discord: use distro layout for stable on Linux", PR NixOS#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
@ap-1 ap-1 mentioned this pull request Jun 15, 2026
8 of 14 tasks
nixos-cuda-channel-updater Bot pushed a commit to nixos-cuda/nixpkgs that referenced this pull request Jun 27, 2026
As of commit b49b623 ("discord: use distro layout for stable on Linux", PR NixOS#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 commit 8f5437c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 8.has: failed backport 8.has: package (update) This PR updates a package to a newer version 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants