1{
2 branch ? "stable",
3 callPackage,
4 fetchurl,
5 lib,
6 stdenv,
7}:
8let
9 versions =
10 if stdenv.hostPlatform.isLinux then
11 {
12 stable = "0.0.103";
13 ptb = "0.0.154";
14 canary = "0.0.730";
15 development = "0.0.84";
16 }
17 else
18 {
19 stable = "0.0.355";
20 ptb = "0.0.184";
21 canary = "0.0.836";
22 development = "0.0.97";
23 };
24 version = versions.${branch};
25 srcs = rec {
26 x86_64-linux = {
27 stable = fetchurl {
28 url = "https://stable.dl2.discordapp.net/apps/linux/${version}/discord-${version}.tar.gz";
29 hash = "sha256-WNLyBBQFqAEiPpv1JpoFrgKgCH3PBOTxFWxdHcqNAl8=";
30 };
31 ptb = fetchurl {
32 url = "https://ptb.dl2.discordapp.net/apps/linux/${version}/discord-ptb-${version}.tar.gz";
33 hash = "sha256-ZAjewH/lOby3O7dQXy4igKd0DiZuwuhBitSlbr3hyjs=";
34 };
35 canary = fetchurl {
36 url = "https://canary.dl2.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
37 hash = "sha256-lDmhJhhI9oD89fIGctcalO0pf2SjikRdsIWVIpkfGpk=";
38 };
39 development = fetchurl {
40 url = "https://development.dl2.discordapp.net/apps/linux/${version}/discord-development-${version}.tar.gz";
41 hash = "sha256-0SmCBi/fl77m5PzI5O38CpAoIzyQc+eRUKLyKVMQ6Dc=";
42 };
43 };
44 x86_64-darwin = {
45 stable = fetchurl {
46 url = "https://stable.dl2.discordapp.net/apps/osx/${version}/Discord.dmg";
47 hash = "sha256-RV/qyguxpdgL0T6AJHvP40LzFxSLI57bCGEpgZxLZmI=";
48 };
49 ptb = fetchurl {
50 url = "https://ptb.dl2.discordapp.net/apps/osx/${version}/DiscordPTB.dmg";
51 hash = "sha256-BWsnv22blA+1oAWGbYxXgwo0i9LvaAAqjUuwSRlfkTw=";
52 };
53 canary = fetchurl {
54 url = "https://canary.dl2.discordapp.net/apps/osx/${version}/DiscordCanary.dmg";
55 hash = "sha256-XVznNMnhEgX2YXUj0+5cQNxB2RR2ybUS3UcHqlSiHOk=";
56 };
57 development = fetchurl {
58 url = "https://development.dl2.discordapp.net/apps/osx/${version}/DiscordDevelopment.dmg";
59 hash = "sha256-BVTQPr3Oox/mTNE7LTJfYuKhI8PlkJlznKiOffqpECs=";
60 };
61 };
62 aarch64-darwin = x86_64-darwin;
63 };
64 src =
65 srcs.${stdenv.hostPlatform.system}.${branch}
66 or (throw "${stdenv.hostPlatform.system} not supported on ${branch}");
67
68 meta = {
69 description = "All-in-one cross-platform voice and text chat for gamers";
70 downloadPage = "https://discordapp.com/download";
71 homepage = "https://discordapp.com/";
72 license = lib.licenses.unfree;
73 mainProgram = "discord";
74 maintainers = with lib.maintainers; [
75 artturin
76 donteatoreo
77 infinidoge
78 jopejoe1
79 Scrumplex
80 ];
81 platforms = [
82 "x86_64-linux"
83 "x86_64-darwin"
84 "aarch64-darwin"
85 ];
86 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
87 };
88 package = if stdenv.hostPlatform.isLinux then ./linux.nix else ./darwin.nix;
89
90 packages = (
91 builtins.mapAttrs
92 (
93 _: value:
94 callPackage package (
95 value
96 // {
97 inherit src version branch;
98 meta = meta // {
99 mainProgram = value.binaryName;
100 };
101 }
102 )
103 )
104 {
105 stable = {
106 pname = "discord";
107 binaryName = "Discord";
108 desktopName = "Discord";
109 };
110 ptb = rec {
111 pname = "discord-ptb";
112 binaryName = if stdenv.hostPlatform.isLinux then "DiscordPTB" else desktopName;
113 desktopName = "Discord PTB";
114 };
115 canary = rec {
116 pname = "discord-canary";
117 binaryName = if stdenv.hostPlatform.isLinux then "DiscordCanary" else desktopName;
118 desktopName = "Discord Canary";
119 };
120 development = rec {
121 pname = "discord-development";
122 binaryName = if stdenv.hostPlatform.isLinux then "DiscordDevelopment" else desktopName;
123 desktopName = "Discord Development";
124 };
125 }
126 );
127in
128packages.${branch}