git.iko.soy/typeable/nixpkgs
on master help sign in
wire-desktop: Add darwin support

Wire Desktop is available for linux, mac os and windows. I figured adding darwin support would be cromulent. Note that the versions don't align 100%, this is how it's released upstream. I refactored the derivation to seperate all the linux-specific parts. I also sorted the dependencies and grouped them. The changes were based on the derivation for electron. I changed the construction from calling `mkDerivation` on a conditional merger of two sets by moving the `mkDerivation` calls into the conditional and up to the local bindings for `linux` and `darwin`. This required moving `pname` and `meta` up to local bindings.

commit4665e883b26bee9ca4d351a4a1f6abf0e36cfb25 authortoonn <toonn@toonn.io> dateWed 17 Jul 2019, 00:09 (7 years ago) parent33b6a17
1 file changed+106−89
pkgs/applications/networking/instant-messengers/wire-desktop/default.nix+106−89
pkgs/applications/networking/instant-messengers/wire-desktop/default.nix+106−89
@@ -1,97 +1,29 @@
1−{ stdenv, fetchurl, dpkg, makeDesktopItem, libuuid, gtk3, atk, cairo, pango
2−, gdk_pixbuf, glib, freetype, fontconfig, dbus, libnotify, libX11, xorg, libXi
3−, libXcursor, libXdamage, libXrandr, libXcomposite, libXext, libXfixes
4−, libXrender, libXtst, libXScrnSaver, nss, nspr, alsaLib, cups, expat, udev
5−, xdg_utils, hunspell, pulseaudio, pciutils, at-spi2-atk
6−}:
1+{ stdenv, fetchurl, makeDesktopItem
72
8−let
3+, alsaLib, at-spi2-atk, atk, cairo, cups, dbus, dpkg, expat, fontconfig
4+, freetype, gdk_pixbuf, glib, gtk3, hunspell, libX11, libXScrnSaver
5+, libXcomposite, libXcursor, libXdamage, libXext, libXfixes, libXi, libXrandr
6+, libXrender, libXtst, libnotify, libuuid, nspr, nss, pango, pciutils
7+, pulseaudio, udev, xdg_utils, xorg
98
10− rpath = stdenv.lib.makeLibraryPath [
11− alsaLib
12− atk
13− cairo
14− cups
15− dbus
16− expat
17− fontconfig
18− freetype
19− gdk_pixbuf
20− glib
21− gtk3
22− at-spi2-atk
23− hunspell
24− libuuid
25− libnotify
26− libX11
27− libXcomposite
28− libXcursor
29− libXdamage
30− libXext
31− libXfixes
32− libXi
33− libXrandr
34− libXrender
35− libXScrnSaver
36− libXtst
37− nspr
38− nss
39− pango
40− pciutils
41− pulseaudio
42− stdenv.cc.cc
43− udev
44− xdg_utils
45− xorg.libxcb
46− ];
47−
48−in
49−
50−stdenv.mkDerivation rec {
51− pname = "wire-desktop";
52− version = "3.9.2895";
53−
54− src = fetchurl {
55− url = "https://wire-app.wire.com/linux/debian/pool/main/Wire-${version}_amd64.deb";
56− sha256 = "0wrn95m64j4b7ym44h9zawq13kg4m12aixlyyzp56bfyczmjq4a5";
57− };
58−
59− desktopItem = makeDesktopItem {
60− name = "wire-desktop";
61− exec = "wire-desktop %U";
62− icon = "wire-desktop";
63− comment = "Secure messenger for everyone";
64− desktopName = "Wire Desktop";
65− genericName = "Secure messenger";
66− categories = "Network;InstantMessaging;Chat;VideoConference";
67− };
68−
69− dontBuild = true;
70− dontPatchELF = true;
71− dontConfigure = true;
9+, cpio, xar
10+}:
7211
73− nativeBuildInputs = [ dpkg ];
74− unpackPhase = "dpkg-deb -x $src .";
75− installPhase = ''
76− mkdir -p "$out"
77− cp -R "opt" "$out"
78− cp -R "usr/share" "$out/share"
12+let
7913
80− chmod -R g-w "$out"
14+ inherit (stdenv.hostPlatform) system;
8115
82− # Patch wire-desktop
83− patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
84− --set-rpath "${rpath}:$out/opt/Wire" \
85− "$out/opt/Wire/wire-desktop"
16+ pname = "wire-desktop";
8617
87− # Symlink to bin
88− mkdir -p "$out/bin"
89− ln -s "$out/opt/Wire/wire-desktop" "$out/bin/wire-desktop"
18+ version = {
19+ "x86_64-linux" = "3.9.2895";
20+ "x86_64-darwin" = "3.9.2943";
21+ }.${system};
9022
91− # Desktop file
92− mkdir -p "$out/share/applications"
93− cp "${desktopItem}/share/applications/"* "$out/share/applications"
94− '';
23+ sha256 = {
24+ "x86_64-linux" = "0wrn95m64j4b7ym44h9zawq13kg4m12aixlyyzp56bfyczmjq4a5";
25+ "x86_64-darwin" = "1y1bzsjmjrj518q29xfx6gg1nhdbaz7y5hzaqrp241az6plp090k";
26+ }.${system};
9527
9628 meta = with stdenv.lib; {
9729 description = "A modern, secure messenger for everyone";
@@ -107,9 +39,94 @@ stdenv.mkDerivation rec {
10739 * Synced across your phone, desktop and tablet
10840 '';
10941 homepage = https://wire.com/;
110− platforms = [ "x86_64-linux" ];
11142 downloadPage = https://wire.com/download/;
11243 license = licenses.gpl3Plus;
11344 maintainers = with maintainers; [ toonn worldofpeace ];
45+ platforms = [ "x86_64-darwin" "x86_64-linux" ];
11446 };
115−}
47+
48+ linux = stdenv.mkDerivation rec {
49+ inherit pname version meta;
50+
51+ src = fetchurl {
52+ url = "https://wire-app.wire.com/linux/debian/pool/main/"
53+ + "Wire-${version}_amd64.deb";
54+ inherit sha256;
55+ };
56+
57+ desktopItem = makeDesktopItem {
58+ name = "wire-desktop";
59+ exec = "wire-desktop %U";
60+ icon = "wire-desktop";
61+ comment = "Secure messenger for everyone";
62+ desktopName = "Wire Desktop";
63+ genericName = "Secure messenger";
64+ categories = "Network;InstantMessaging;Chat;VideoConference";
65+ };
66+
67+ dontBuild = true;
68+ dontPatchELF = true;
69+ dontConfigure = true;
70+
71+ nativeBuildInputs = [ dpkg ];
72+ rpath = stdenv.lib.makeLibraryPath [
73+ alsaLib at-spi2-atk atk cairo cups dbus expat fontconfig freetype
74+ gdk_pixbuf glib gtk3 hunspell libX11 libXScrnSaver libXcomposite
75+ libXcursor libXdamage libXext libXfixes libXi libXrandr libXrender
76+ libXtst libnotify libuuid nspr nss pango pciutils pulseaudio
77+ stdenv.cc.cc udev xdg_utils xorg.libxcb
78+ ];
79+
80+ unpackPhase = "dpkg-deb -x $src .";
81+
82+ installPhase = ''
83+ mkdir -p "$out"
84+ cp -R "opt" "$out"
85+ cp -R "usr/share" "$out/share"
86+ chmod -R g-w "$out"
87+
88+ # Patch wire-desktop
89+ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
90+ --set-rpath "${rpath}:$out/opt/Wire" \
91+ "$out/opt/Wire/wire-desktop"
92+
93+ # Symlink to bin
94+ mkdir -p "$out/bin"
95+ ln -s "$out/opt/Wire/wire-desktop" "$out/bin/wire-desktop"
96+
97+ # Desktop file
98+ mkdir -p "$out/share/applications"
99+ cp "${desktopItem}/share/applications/"* "$out/share/applications"
100+ '';
101+ };
102+
103+ darwin = stdenv.mkDerivation rec {
104+ inherit pname version meta;
105+
106+ src = fetchurl {
107+ url = "https://github.com/wireapp/wire-desktop/releases/download/"
108+ + "macos%2F${version}/Wire.pkg";
109+ inherit sha256;
110+ };
111+
112+ buildInputs = [ cpio xar ];
113+
114+ unpackPhase = ''
115+ xar -xf $src
116+ cd com.wearezeta.zclient.mac.pkg
117+ '';
118+
119+
120+ buildPhase = ''
121+ cat Payload | gunzip -dc | cpio -i
122+ '';
123+
124+ installPhase = ''
125+ mkdir -p $out/Applications
126+ cp -r Wire.app $out/Applications
127+ '';
128+ };
129+
130+in if stdenv.isDarwin
131+ then darwin
132+ else linux