@@ -8,120 +8,146 @@ let
88
99 version = "4.2.0";
1010
11− rpath = stdenv.lib.makeLibraryPath [
12− alsaLib
13− at-spi2-atk
14− at-spi2-core
15− atk
16− cairo
17− cups
18− curl
19− dbus
20− expat
21− fontconfig
22− freetype
23− glib
24− gnome2.GConf
25− gdk-pixbuf
26− gtk3
27− pango
28− libnotify
29− libxcb
30− libappindicator-gtk3
31− nspr
32− nss
33− stdenv.cc.cc
34− systemd
35− libuuid
36− libpulseaudio
11+ inherit (stdenv.hostPlatform) system;
3712
38− xorg.libxkbfile
39− xorg.libX11
40− xorg.libXcomposite
41− xorg.libXcursor
42− xorg.libXdamage
43− xorg.libXext
44− xorg.libXfixes
45− xorg.libXi
46− xorg.libXrandr
47− xorg.libXrender
48− xorg.libXtst
49− xorg.libXScrnSaver
50− ] + ":${stdenv.cc.cc.lib}/lib64";
13+ throwSystem = throw "Unsupported system: ${system}";
5114
52− src =
53− if stdenv.hostPlatform.system == "x86_64-linux" then
54− fetchurl {
55− url = "https://downloads.slack-edge.com/linux_releases/slack-desktop-${version}-amd64.deb";
56− sha256 = "01b2klhky04fijdqcpfafgdqx2c5nh2fpnzvzgvz10hv7h16cinv";
57− }
58− else
59− throw "Slack is not supported on ${stdenv.hostPlatform.system}";
60−
61−in stdenv.mkDerivation {
6215 pname = "slack";
63− inherit version;
64−
65− inherit src;
66−
67− buildInputs = [
68− gtk3 # needed for GSETTINGS_SCHEMAS_PATH
69− ];
70−
71− nativeBuildInputs = [ dpkg makeWrapper nodePackages.asar ];
72−
73− dontUnpack = true;
74− dontBuild = true;
75− dontPatchELF = true;
7616
77− installPhase = ''
78− # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here
79− dpkg --fsys-tarfile $src | tar --extract
80− rm -rf usr/share/lintian
17+ sha256 = {
18+ x86_64-darwin = "0947a98m7yz4hldjvcqnv9s17dpvlsk9sflc1zc99hf500zck0w1";
19+ x86_64-linux = "01b2klhky04fijdqcpfafgdqx2c5nh2fpnzvzgvz10hv7h16cinv";
20+ }.${system} or throwSystem;
8121
82− mkdir -p $out
83− mv usr/* $out
84−
85− # Otherwise it looks "suspicious"
86− chmod -R g-w $out
87−
88− for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
89− patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
90− patchelf --set-rpath ${rpath}:$out/lib/slack $file || true
91− done
92−
93− # Replace the broken bin/slack symlink with a startup wrapper
94− rm $out/bin/slack
95− makeWrapper $out/lib/slack/slack $out/bin/slack \
96− --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
97− --prefix PATH : ${xdg_utils}/bin
98−
99− # Fix the desktop link
100− substituteInPlace $out/share/applications/slack.desktop \
101− --replace /usr/bin/ $out/bin/ \
102− --replace /usr/share/ $out/share/
103− '' + stdenv.lib.optionalString (theme != null) ''
104− asar extract $out/lib/slack/resources/app.asar $out/lib/slack/resources/app.asar.unpacked
105− cat <<EOF >> $out/lib/slack/resources/app.asar.unpacked/dist/ssb-interop.bundle.js
106−
107− var fs = require('fs');
108− document.addEventListener('DOMContentLoaded', function() {
109− fs.readFile('${theme}/theme.css', 'utf8', function(err, css) {
110− let s = document.createElement('style');
111− s.type = 'text/css';
112− s.innerHTML = css;
113− document.head.appendChild(s);
114− });
115− });
116− EOF
117− asar pack $out/lib/slack/resources/app.asar.unpacked $out/lib/slack/resources/app.asar
118− '';
11922
12023 meta = with stdenv.lib; {
12124 description = "Desktop client for Slack";
12225 homepage = https://slack.com;
12326 license = licenses.unfree;
12427 maintainers = [ maintainers.mmahut ];
125− platforms = [ "x86_64-linux" ];
28+ platforms = [ "x86_64-darwin" "x86_64-linux" ];
29+ };
30+
31+ linux = stdenv.mkDerivation rec {
32+ inherit pname version meta;
33+ src = fetchurl {
34+ url = "https://downloads.slack-edge.com/linux_releases/slack-desktop-${version}-amd64.deb";
35+ inherit sha256;
36+ };
37+
38+ rpath = stdenv.lib.makeLibraryPath [
39+ alsaLib
40+ at-spi2-atk
41+ at-spi2-core
42+ atk
43+ cairo
44+ cups
45+ curl
46+ dbus
47+ expat
48+ fontconfig
49+ freetype
50+ glib
51+ gnome2.GConf
52+ gdk-pixbuf
53+ gtk3
54+ pango
55+ libnotify
56+ libxcb
57+ libappindicator-gtk3
58+ nspr
59+ nss
60+ stdenv.cc.cc
61+ systemd
62+ libuuid
63+ libpulseaudio
64+
65+ xorg.libxkbfile
66+ xorg.libX11
67+ xorg.libXcomposite
68+ xorg.libXcursor
69+ xorg.libXdamage
70+ xorg.libXext
71+ xorg.libXfixes
72+ xorg.libXi
73+ xorg.libXrandr
74+ xorg.libXrender
75+ xorg.libXtst
76+ xorg.libXScrnSaver
77+ ] + ":${stdenv.cc.cc.lib}/lib64";
78+
79+ buildInputs = [
80+ gtk3 # needed for GSETTINGS_SCHEMAS_PATH
81+ ];
82+
83+ nativeBuildInputs = [ dpkg makeWrapper nodePackages.asar ];
84+
85+ dontUnpack = true;
86+ dontBuild = true;
87+ dontPatchELF = true;
88+
89+ installPhase = ''
90+ # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here
91+ dpkg --fsys-tarfile $src | tar --extract
92+ rm -rf usr/share/lintian
93+
94+ mkdir -p $out
95+ mv usr/* $out
96+
97+ # Otherwise it looks "suspicious"
98+ chmod -R g-w $out
99+
100+ for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
101+ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
102+ patchelf --set-rpath ${rpath}:$out/lib/slack $file || true
103+ done
104+
105+ # Replace the broken bin/slack symlink with a startup wrapper
106+ rm $out/bin/slack
107+ makeWrapper $out/lib/slack/slack $out/bin/slack \
108+ --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
109+ --prefix PATH : ${xdg_utils}/bin
110+
111+ # Fix the desktop link
112+ substituteInPlace $out/share/applications/slack.desktop \
113+ --replace /usr/bin/ $out/bin/ \
114+ --replace /usr/share/ $out/share/
115+ '' + stdenv.lib.optionalString (theme != null) ''
116+ asar extract $out/lib/slack/resources/app.asar $out/lib/slack/resources/app.asar.unpacked
117+ cat <<EOF >> $out/lib/slack/resources/app.asar.unpacked/dist/ssb-interop.bundle.js
118+
119+ var fs = require('fs');
120+ document.addEventListener('DOMContentLoaded', function() {
121+ fs.readFile('${theme}/theme.css', 'utf8', function(err, css) {
122+ let s = document.createElement('style');
123+ s.type = 'text/css';
124+ s.innerHTML = css;
125+ document.head.appendChild(s);
126+ });
127+ });
128+ EOF
129+ asar pack $out/lib/slack/resources/app.asar.unpacked $out/lib/slack/resources/app.asar
130+ '';
131+ };
132+
133+ darwin = stdenv.mkDerivation {
134+ inherit pname version meta;
135+
136+ phases = [ "installPhase" ];
137+
138+ src = fetchurl {
139+ url = "https://downloads.slack-edge.com/mac_releases/Slack-${version}-macOS.dmg";
140+ inherit sha256;
141+ };
142+
143+ installPhase = ''
144+ /usr/bin/hdiutil mount -nobrowse -mountpoint slack-mnt $src
145+ mkdir -p $out/Applications
146+ cp -r ./slack-mnt/Slack.app $out/Applications
147+ /usr/bin/hdiutil unmount slack-mnt
148+ defaults write com.tinyspeck.slackmacgap SlackNoAutoUpdates -bool YES
149+ '';
126150 };
127−}
151+in if stdenv.isDarwin
152+ then darwin
153+ else linux