mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-16 18:24:04 +00:00
discord: use distro layout for stable on Linux
This commit is contained in:
@@ -87,31 +87,13 @@ let
|
||||
];
|
||||
enabledDiscordModsCount = builtins.length (lib.filter (x: x) discordMods);
|
||||
|
||||
# Starting with discord-development 0.0.235, the linux tarball ships only a
|
||||
# small `updater_bootstrap` ELF that downloads the real app at first launch
|
||||
#
|
||||
# That binary always fetches the latest version from Discord's CDN with no way
|
||||
# to pin, making the build impure and the nix version a lie
|
||||
#
|
||||
# Instead we fetch the app directly from the distributions API at build time:
|
||||
# https://updates.discord.com/distributions/app/manifests/latest?channel=...
|
||||
# The host + module distros are brotli-compressed tars on Discord's CDN at
|
||||
# predictable URLs with SHA256 hashes in the manifest
|
||||
isDistro = source.kind == "distro";
|
||||
|
||||
inherit (source) version;
|
||||
|
||||
src =
|
||||
if isDistro then
|
||||
fetchurl { inherit (source.distro) url hash; }
|
||||
else
|
||||
fetchurl { inherit (source) url hash; };
|
||||
src = fetchurl { inherit (source.distro) url hash; };
|
||||
|
||||
moduleSrcs = lib.optionalAttrs isDistro (
|
||||
lib.mapAttrs (_: mod: fetchurl { inherit (mod) url hash; }) source.modules
|
||||
);
|
||||
moduleSrcs = lib.mapAttrs (_: mod: fetchurl { inherit (mod) url hash; }) source.modules;
|
||||
|
||||
moduleVersions = lib.optionalAttrs isDistro (lib.mapAttrs (_: mod: mod.version) source.modules);
|
||||
moduleVersions = lib.mapAttrs (_: mod: mod.version) source.modules;
|
||||
|
||||
libPath = lib.makeLibraryPath (
|
||||
[
|
||||
@@ -218,8 +200,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
libxshmfence
|
||||
wrapGAppsHook3
|
||||
makeShellWrapper
|
||||
]
|
||||
++ lib.optionals isDistro [ brotli ];
|
||||
brotli
|
||||
];
|
||||
|
||||
dontWrapGApps = true;
|
||||
|
||||
@@ -228,20 +210,20 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
libgbm
|
||||
nspr
|
||||
nss
|
||||
]
|
||||
# The new distro layout ships prebuilt `.node` modules:
|
||||
# discord_dispatch is linked against openssl 1.1, discord_voice against libpulseaudio.
|
||||
# Ignore the missing dependency on insecure openssl_1_1: discord_dispatch is
|
||||
# effectively unused in practice.
|
||||
++ lib.optionals isDistro [ libpulseaudio ];
|
||||
# The distro layout ships prebuilt `.node` modules:
|
||||
# discord_dispatch is linked against openssl 1.1, discord_voice against libpulseaudio.
|
||||
# Ignore the missing dependency on insecure openssl_1_1: discord_dispatch is
|
||||
# effectively unused in practice.
|
||||
libpulseaudio
|
||||
];
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
dontUnpack = isDistro;
|
||||
dontUnpack = true;
|
||||
|
||||
inherit libPath;
|
||||
|
||||
autoPatchelfIgnoreMissingDeps = lib.optionals isDistro [
|
||||
autoPatchelfIgnoreMissingDeps = [
|
||||
"libssl.so.1.1"
|
||||
"libcrypto.so.1.1"
|
||||
];
|
||||
@@ -250,41 +232,22 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{bin,opt/${binaryName},share/icons/hicolor/256x256/apps}
|
||||
''
|
||||
+ (
|
||||
if isDistro then
|
||||
''
|
||||
# Distro layout (currently discord-ptb, discord-canary and discord-development):
|
||||
#
|
||||
# The host distro is a brotli-compressed tar with all files under a `files/`
|
||||
# prefix (the channel binary, libffmpeg.so, resources/, etc). Module distros
|
||||
# follow the same format with module contents under `files/`
|
||||
#
|
||||
# The module directory layout must match what Discord's node runtime
|
||||
# expects: modules/<name>/ (the moduleUpdater extracts zips into
|
||||
# path.join(moduleInstallPath, moduleName) see processUnzipQueue)
|
||||
|
||||
brotli -d < $src | tar xf - --strip-components=1 -C $out/opt/${binaryName}
|
||||
chmod +x $out/opt/${binaryName}/${binaryName}
|
||||
# The host distro is a brotli-compressed tar with all files under a `files/`
|
||||
# prefix (the channel binary, libffmpeg.so, resources/, etc). Module distros
|
||||
# follow the same format with module contents under `files/`
|
||||
brotli -d < $src | tar xf - --strip-components=1 -C $out/opt/${binaryName}
|
||||
chmod +x $out/opt/${binaryName}/${binaryName}
|
||||
|
||||
# Extract native modules
|
||||
${lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (name: src: ''
|
||||
mkdir -p $out/opt/${binaryName}/modules/${name}
|
||||
brotli -d < ${src} | tar xf - --strip-components=1 -C $out/opt/${binaryName}/modules/${name}
|
||||
'') moduleSrcs
|
||||
)}
|
||||
|
||||
''
|
||||
else
|
||||
''
|
||||
# Tarball layout (stable): the tarball unpacks into a
|
||||
# directory containing the channel binary directly
|
||||
mv * $out/opt/${binaryName}
|
||||
chmod +x $out/opt/${binaryName}/${binaryName}
|
||||
''
|
||||
)
|
||||
+ ''
|
||||
# The module directory layout must match what Discord's node runtime
|
||||
# expects: modules/<name>/ (the moduleUpdater extracts zips into
|
||||
# path.join(moduleInstallPath, moduleName) see processUnzipQueue)
|
||||
${lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (name: src: ''
|
||||
mkdir -p $out/opt/${binaryName}/modules/${name}
|
||||
brotli -d < ${src} | tar xf - --strip-components=1 -C $out/opt/${binaryName}/modules/${name}
|
||||
'') moduleSrcs
|
||||
)}
|
||||
|
||||
wrapProgramShell $out/opt/${binaryName}/${binaryName} \
|
||||
"''${gappsWrapperArgs[@]}" \
|
||||
@@ -297,7 +260,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
|
||||
--prefix LD_LIBRARY_PATH : ${finalAttrs.libPath}:$out/opt/${binaryName} \
|
||||
${lib.strings.optionalString disableUpdates "--run ${lib.getExe disableBreakingUpdates}"} \
|
||||
${lib.strings.optionalString isDistro ''--run "${stageModules} $out/opt/${binaryName}/modules"''} \
|
||||
--run "${stageModules} $out/opt/${binaryName}/modules" \
|
||||
--add-flags ${lib.escapeShellArg commandLineArgs}
|
||||
|
||||
ln -s $out/opt/${binaryName}/${binaryName} $out/bin/
|
||||
|
||||
@@ -210,10 +210,74 @@
|
||||
"version": "1.0.189"
|
||||
},
|
||||
"linux-stable": {
|
||||
"hash": "sha256-vMuoz1OR0cKvrfT/ilkNXEtEP3zEwyNGh6AW5iQADws=",
|
||||
"kind": "legacy",
|
||||
"url": "https://stable.dl2.discordapp.net/apps/linux/0.0.135/discord-0.0.135.tar.gz",
|
||||
"version": "0.0.135"
|
||||
"distro": {
|
||||
"hash": "sha256-RlQEGuQlnvISzvNAXtJAEaHSvC/8AhNcfEc8paV9JKA=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/full.distro"
|
||||
},
|
||||
"kind": "distro",
|
||||
"modules": {
|
||||
"discord_cloudsync": {
|
||||
"hash": "sha256-9x/7+65hT5mcOOlUcSkWa7As+6Bxdv9vps/ZYgj+8TI=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_cloudsync/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_desktop_core": {
|
||||
"hash": "sha256-9ocCcvhubWXUCwPewJdKolt0CRbunzVIjWUsser1NA4=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_desktop_core/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_dispatch": {
|
||||
"hash": "sha256-3Hqi3/5zfmDheMIbWN9l8qb/bNo9/pzfxQqYureCfMI=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_dispatch/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_erlpack": {
|
||||
"hash": "sha256-lSR9PV2nG5+vgNqpjUrC8ygKv8bfvUk+i+F7nCEjV1Q=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_erlpack/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_game_utils": {
|
||||
"hash": "sha256-jf3Gf95QmZVjzAB0Ui2eSErP58hNd+YRyyYKe9xtQlQ=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_game_utils/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_krisp": {
|
||||
"hash": "sha256-jrEaudW1wI4dKIvZd+1/CfybdWainF9TApptzffxQiI=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_krisp/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_modules": {
|
||||
"hash": "sha256-jN+R1e8aDVXyq6J+1+h8Hienli7pj+xhZU8PUKCtXn8=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_modules/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_rpc": {
|
||||
"hash": "sha256-f/rSx/dFSmORLVPNvG5iqJb1KN5CBchXEUzwJwP21zU=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_rpc/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_spellcheck": {
|
||||
"hash": "sha256-t1Y8DGpVQ1pzCz6tScaTnY9KvxSnUnIk26twTVupdX4=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_spellcheck/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_utils": {
|
||||
"hash": "sha256-FH0Fb4M+L+WETHQBJuFqbS/h0nLlWTTTnV7lp1lqcCU=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_utils/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_voice": {
|
||||
"hash": "sha256-X5u3XuXdco84LG0lZS0uAgks0XjesxOltYGn0XP3akQ=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_voice/1/full.distro",
|
||||
"version": 1
|
||||
},
|
||||
"discord_zstd": {
|
||||
"hash": "sha256-tZgzaVh2/CrvtYPOVJE3vrZuWbs9JxQSi74KeNf0mJw=",
|
||||
"url": "https://stable.dl2.discordapp.net/distro/app/stable/linux/x64/1.0.137/discord_zstd/1/full.distro",
|
||||
"version": 1
|
||||
}
|
||||
},
|
||||
"version": "1.0.137"
|
||||
},
|
||||
"osx-canary": {
|
||||
"distro": {
|
||||
|
||||
Reference in New Issue
Block a user