Merge pull request #155020 from devins2518/discord_mac

discord{,-ptb,-canary}: add derivations for {x86_64,aarch64}-darwin

authored by Ben Siraphob and committed by GitHub f542129a b65da092

+216 -124
-93
pkgs/applications/networking/instant-messengers/discord/base.nix
··· 1 - { pname, version, src, binaryName, desktopName 2 - , autoPatchelfHook, makeDesktopItem, lib, stdenv, wrapGAppsHook 3 - , alsa-lib, at-spi2-atk, at-spi2-core, atk, cairo, cups, dbus, expat, fontconfig 4 - , freetype, gdk-pixbuf, glib, gtk3, libcxx, libdrm, libnotify, libpulseaudio, libuuid 5 - , libX11, libXScrnSaver, libXcomposite, libXcursor, libXdamage, libXext 6 - , libXfixes, libXi, libXrandr, libXrender, libXtst, libxcb, libxshmfence 7 - , mesa, nspr, nss, pango, systemd, libappindicator-gtk3, libdbusmenu 8 - , writeScript, common-updater-scripts 9 - }: 10 - 11 - let 12 - inherit binaryName; 13 - in stdenv.mkDerivation rec { 14 - inherit pname version src; 15 - 16 - nativeBuildInputs = [ 17 - alsa-lib 18 - autoPatchelfHook 19 - cups 20 - libdrm 21 - libuuid 22 - libXdamage 23 - libX11 24 - libXScrnSaver 25 - libXtst 26 - libxcb 27 - libxshmfence 28 - mesa 29 - nss 30 - wrapGAppsHook 31 - ]; 32 - 33 - dontWrapGApps = true; 34 - 35 - libPath = lib.makeLibraryPath [ 36 - libcxx systemd libpulseaudio libdrm mesa 37 - stdenv.cc.cc alsa-lib atk at-spi2-atk at-spi2-core cairo cups dbus expat fontconfig freetype 38 - gdk-pixbuf glib gtk3 libnotify libX11 libXcomposite libuuid 39 - libXcursor libXdamage libXext libXfixes libXi libXrandr libXrender 40 - libXtst nspr nss libxcb pango libXScrnSaver 41 - libappindicator-gtk3 libdbusmenu 42 - ]; 43 - 44 - installPhase = '' 45 - mkdir -p $out/{bin,opt/${binaryName},share/pixmaps} 46 - mv * $out/opt/${binaryName} 47 - 48 - chmod +x $out/opt/${binaryName}/${binaryName} 49 - patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \ 50 - $out/opt/${binaryName}/${binaryName} 51 - 52 - wrapProgram $out/opt/${binaryName}/${binaryName} \ 53 - "''${gappsWrapperArgs[@]}" \ 54 - --prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \ 55 - --prefix LD_LIBRARY_PATH : ${libPath}:$out/opt/${binaryName} 56 - 57 - ln -s $out/opt/${binaryName}/${binaryName} $out/bin/ 58 - # Without || true the install would fail on case-insensitive filesystems 59 - ln -s $out/opt/${binaryName}/${binaryName} $out/bin/${lib.strings.toLower binaryName} || true 60 - ln -s $out/opt/${binaryName}/discord.png $out/share/pixmaps/${pname}.png 61 - 62 - ln -s "${desktopItem}/share/applications" $out/share/ 63 - ''; 64 - 65 - desktopItem = makeDesktopItem { 66 - name = pname; 67 - exec = binaryName; 68 - icon = pname; 69 - inherit desktopName; 70 - genericName = meta.description; 71 - categories = "Network;InstantMessaging;"; 72 - mimeType = "x-scheme-handler/discord"; 73 - }; 74 - 75 - passthru.updateScript = writeScript "discord-update-script" '' 76 - #!/usr/bin/env nix-shell 77 - #!nix-shell -i bash -p curl gnugrep common-updater-scripts 78 - set -eou pipefail; 79 - url=$(curl -sI "https://discordapp.com/api/download/${builtins.replaceStrings ["discord-" "discord"] ["" "stable"] pname}?platform=linux&format=tar.gz" | grep -oP 'location: \K\S+') 80 - version=''${url##https://dl*.discordapp.net/apps/linux/} 81 - version=''${version%%/*.tar.gz} 82 - update-source-version ${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix 83 - ''; 84 - 85 - meta = with lib; { 86 - description = "All-in-one cross-platform voice and text chat for gamers"; 87 - homepage = "https://discordapp.com/"; 88 - downloadPage = "https://discordapp.com/download"; 89 - license = licenses.unfree; 90 - maintainers = with maintainers; [ ldesgoui MP2E ]; 91 - platforms = [ "x86_64-linux" ]; 92 - }; 93 - }
+14
pkgs/applications/networking/instant-messengers/discord/darwin.nix
··· 1 + { pname, version, src, meta, stdenv, binaryName, desktopName, undmg }: 2 + 3 + stdenv.mkDerivation { 4 + inherit pname version src meta; 5 + 6 + nativeBuildInputs = [ undmg ]; 7 + 8 + sourceRoot = "."; 9 + 10 + installPhase = '' 11 + mkdir -p $out/Applications 12 + cp -r "${desktopName}.app" $out/Applications 13 + ''; 14 + }
+82 -28
pkgs/applications/networking/instant-messengers/discord/default.nix
··· 1 - { branch ? "stable", pkgs }: 1 + { branch ? "stable", pkgs, lib, stdenv }: 2 2 let 3 3 inherit (pkgs) callPackage fetchurl; 4 - in { 5 - stable = callPackage ./base.nix rec { 6 - pname = "discord"; 7 - binaryName = "Discord"; 8 - desktopName = "Discord"; 9 - version = "0.0.16"; 10 - src = fetchurl { 11 - url = "https://dl.discordapp.net/apps/linux/${version}/discord-${version}.tar.gz"; 12 - sha256 = "UTVKjs/i7C/m8141bXBsakQRFd/c//EmqqhKhkr1OOk="; 13 - }; 4 + versions = if stdenv.isLinux then { 5 + stable = "0.0.16"; 6 + ptb = "0.0.27"; 7 + canary = "0.0.132"; 8 + } else { 9 + stable = "0.0.264"; 10 + ptb = "0.0.58"; 11 + canary = "0.0.280"; 14 12 }; 15 - ptb = callPackage ./base.nix rec { 16 - pname = "discord-ptb"; 17 - binaryName = "DiscordPTB"; 18 - desktopName = "Discord PTB"; 19 - version = "0.0.27"; 20 - src = fetchurl { 21 - url = "https://dl-ptb.discordapp.net/apps/linux/${version}/discord-ptb-${version}.tar.gz"; 22 - sha256 = "0yphs65wpyr0ap6y24b0nbhq7sm02dg5c1yiym1fxjbynm1mdvqb"; 13 + version = versions.${branch}; 14 + srcs = { 15 + x86_64-linux = { 16 + stable = fetchurl { 17 + url = 18 + "https://dl.discordapp.net/apps/linux/${version}/discord-${version}.tar.gz"; 19 + sha256 = "UTVKjs/i7C/m8141bXBsakQRFd/c//EmqqhKhkr1OOk="; 20 + }; 21 + ptb = fetchurl { 22 + url = 23 + "https://dl-ptb.discordapp.net/apps/linux/${version}/discord-ptb-${version}.tar.gz"; 24 + sha256 = "0yphs65wpyr0ap6y24b0nbhq7sm02dg5c1yiym1fxjbynm1mdvqb"; 25 + }; 26 + canary = fetchurl { 27 + url = 28 + "https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz"; 29 + sha256 = "1jjbd9qllgcdpnfxg5alxpwl050vzg13rh17n638wha0vv4mjhyv"; 30 + }; 31 + }; 32 + x86_64-darwin = { 33 + stable = fetchurl { 34 + url = "https://dl.discordapp.net/apps/osx/${version}/Discord.dmg"; 35 + sha256 = "1jvlxmbfqhslsr16prsgbki77kq7i3ipbkbn67pnwlnis40y9s7p"; 36 + }; 37 + ptb = fetchurl { 38 + url = 39 + "https://dl-ptb.discordapp.net/apps/osx/${version}/DiscordPTB.dmg"; 40 + sha256 = "sha256-GwYUoPBbx9lSaRP1JwzI0UE9gEU+rV4a9BNPVSxHki0="; 41 + }; 42 + canary = fetchurl { 43 + url = 44 + "https://dl-canary.discordapp.net/apps/osx/${version}/DiscordCanary.dmg"; 45 + sha256 = "0ccchsywry68vv81pqzzxmh1r19lnvxr429iwvgfr9y82lyjvz06"; 46 + }; 47 + }; 48 + # Only PTB bundles a MachO Universal binary with ARM support. 49 + aarch64-darwin = { 50 + ptb = fetchurl { 51 + url = 52 + "https://dl-ptb.discordapp.net/apps/osx/${version}/DiscordPTB.dmg"; 53 + sha256 = "sha256-GwYUoPBbx9lSaRP1JwzI0UE9gEU+rV4a9BNPVSxHki0="; 54 + }; 23 55 }; 24 56 }; 25 - canary = callPackage ./base.nix rec { 26 - pname = "discord-canary"; 27 - binaryName = "DiscordCanary"; 28 - desktopName = "Discord Canary"; 29 - version = "0.0.132"; 30 - src = fetchurl { 31 - url = "https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz"; 32 - sha256 = "1jjbd9qllgcdpnfxg5alxpwl050vzg13rh17n638wha0vv4mjhyv"; 57 + src = srcs.${stdenv.hostPlatform.system}.${branch}; 58 + 59 + meta = with lib; { 60 + description = "All-in-one cross-platform voice and text chat for gamers"; 61 + homepage = "https://discordapp.com/"; 62 + downloadPage = "https://discordapp.com/download"; 63 + license = licenses.unfree; 64 + maintainers = with maintainers; [ ldesgoui MP2E devins2518 ]; 65 + platforms = [ "x86_64-linux" "x86_64-darwin" ] 66 + ++ lib.optionals (branch == "ptb") [ "aarch64-darwin" ]; 67 + }; 68 + package = if stdenv.isLinux then ./linux.nix else ./darwin.nix; 69 + packages = { 70 + stable = callPackage package rec { 71 + inherit src version meta; 72 + pname = "discord"; 73 + binaryName = "Discord"; 74 + desktopName = "Discord"; 75 + }; 76 + ptb = callPackage package rec { 77 + inherit src version meta; 78 + pname = "discord-ptb"; 79 + binaryName = "DiscordPTB"; 80 + desktopName = "Discord PTB"; 81 + }; 82 + canary = callPackage package rec { 83 + inherit src version meta; 84 + pname = "discord-canary"; 85 + binaryName = "DiscordCanary"; 86 + desktopName = "Discord Canary"; 33 87 }; 34 88 }; 35 - }.${branch} 89 + in packages.${branch}
+117
pkgs/applications/networking/instant-messengers/discord/linux.nix
··· 1 + { pname, version, src, meta, binaryName, desktopName, autoPatchelfHook 2 + , makeDesktopItem, lib, stdenv, wrapGAppsHook, alsa-lib, at-spi2-atk 3 + , at-spi2-core, atk, cairo, cups, dbus, expat, fontconfig, freetype, gdk-pixbuf 4 + , glib, gtk3, libcxx, libdrm, libnotify, libpulseaudio, libuuid, libX11 5 + , libXScrnSaver, libXcomposite, libXcursor, libXdamage, libXext, libXfixes 6 + , libXi, libXrandr, libXrender, libXtst, libxcb, libxshmfence, mesa, nspr, nss 7 + , pango, systemd, libappindicator-gtk3, libdbusmenu, writeScript 8 + , common-updater-scripts }: 9 + 10 + stdenv.mkDerivation rec { 11 + inherit pname version src meta; 12 + 13 + nativeBuildInputs = [ 14 + alsa-lib 15 + autoPatchelfHook 16 + cups 17 + libdrm 18 + libuuid 19 + libXdamage 20 + libX11 21 + libXScrnSaver 22 + libXtst 23 + libxcb 24 + libxshmfence 25 + mesa 26 + nss 27 + wrapGAppsHook 28 + ]; 29 + 30 + dontWrapGApps = true; 31 + 32 + libPath = lib.makeLibraryPath [ 33 + libcxx 34 + systemd 35 + libpulseaudio 36 + libdrm 37 + mesa 38 + stdenv.cc.cc 39 + alsa-lib 40 + atk 41 + at-spi2-atk 42 + at-spi2-core 43 + cairo 44 + cups 45 + dbus 46 + expat 47 + fontconfig 48 + freetype 49 + gdk-pixbuf 50 + glib 51 + gtk3 52 + libnotify 53 + libX11 54 + libXcomposite 55 + libuuid 56 + libXcursor 57 + libXdamage 58 + libXext 59 + libXfixes 60 + libXi 61 + libXrandr 62 + libXrender 63 + libXtst 64 + nspr 65 + nss 66 + libxcb 67 + pango 68 + libXScrnSaver 69 + libappindicator-gtk3 70 + libdbusmenu 71 + ]; 72 + 73 + installPhase = '' 74 + mkdir -p $out/{bin,opt/${binaryName},share/pixmaps} 75 + mv * $out/opt/${binaryName} 76 + 77 + chmod +x $out/opt/${binaryName}/${binaryName} 78 + patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \ 79 + $out/opt/${binaryName}/${binaryName} 80 + 81 + wrapProgram $out/opt/${binaryName}/${binaryName} \ 82 + "''${gappsWrapperArgs[@]}" \ 83 + --prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \ 84 + --prefix LD_LIBRARY_PATH : ${libPath}:$out/opt/${binaryName} 85 + 86 + ln -s $out/opt/${binaryName}/${binaryName} $out/bin/ 87 + # Without || true the install would fail on case-insensitive filesystems 88 + ln -s $out/opt/${binaryName}/${binaryName} $out/bin/${ 89 + lib.strings.toLower binaryName 90 + } || true 91 + ln -s $out/opt/${binaryName}/discord.png $out/share/pixmaps/${pname}.png 92 + 93 + ln -s "${desktopItem}/share/applications" $out/share/ 94 + ''; 95 + 96 + desktopItem = makeDesktopItem { 97 + name = pname; 98 + exec = binaryName; 99 + icon = pname; 100 + inherit desktopName; 101 + genericName = meta.description; 102 + categories = "Network;InstantMessaging;"; 103 + mimeType = "x-scheme-handler/discord"; 104 + }; 105 + 106 + passthru.updateScript = writeScript "discord-update-script" '' 107 + #!/usr/bin/env nix-shell 108 + #!nix-shell -i bash -p curl gnugrep common-updater-scripts 109 + set -eou pipefail; 110 + url=$(curl -sI "https://discordapp.com/api/download/${ 111 + builtins.replaceStrings [ "discord-" "discord" ] [ "" "stable" ] pname 112 + }?platform=linux&format=tar.gz" | grep -oP 'location: \K\S+') 113 + version=''${url##https://dl*.discordapp.net/apps/linux/} 114 + version=''${version%%/*.tar.gz} 115 + update-source-version ${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix 116 + ''; 117 + }
+3 -3
pkgs/top-level/all-packages.nix
··· 34025 34025 34026 34026 discord = import ../applications/networking/instant-messengers/discord { 34027 34027 branch = "stable"; 34028 - inherit pkgs; 34028 + inherit pkgs lib stdenv; 34029 34029 }; 34030 34030 34031 34031 discord-ptb = import ../applications/networking/instant-messengers/discord { 34032 34032 branch = "ptb"; 34033 - inherit pkgs; 34033 + inherit pkgs lib stdenv; 34034 34034 }; 34035 34035 34036 34036 discord-canary = import ../applications/networking/instant-messengers/discord { 34037 34037 branch = "canary"; 34038 - inherit pkgs; 34038 + inherit pkgs lib stdenv; 34039 34039 }; 34040 34040 34041 34041 golden-cheetah = libsForQt514.callPackage ../applications/misc/golden-cheetah {};