1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
{ stdenv
, lib
, fetchurl
, autoPatchelfHook
, dpkg
, wrapGAppsHook
, makeWrapper
, nixosTests
, gtk3
, atk
, at-spi2-atk
, cairo
, pango
, pipewire
, gdk-pixbuf
, glib
, freetype
, fontconfig
, dbus
, libX11
, xorg
, libXi
, libXcursor
, libXdamage
, libXrandr
, libXcomposite
, libXext
, libXfixes
, libXrender
, libXtst
, libXScrnSaver
, nss
, nspr
, alsa-lib
, cups
, expat
, libuuid
, at-spi2-core
, libappindicator-gtk3
, mesa
# Runtime dependencies:
, systemd
, libnotify
, libdbusmenu
, libpulseaudio
, xdg-utils
, wayland
}:
{ pname
, dir
, version
, hash
, url
}:
let
inherit (stdenv) targetPlatform;
ARCH = if targetPlatform.isAarch64 then "arm64" else "x64";
in stdenv.mkDerivation rec {
inherit pname version;
# Please backport all updates to the stable channel.
# All releases have a limited lifetime and "expire" 90 days after the release.
# When releases "expire" the application becomes unusable until an update is
# applied. The expiration date for the current release can be extracted with:
# $ grep -a "^{\"buildExpiration" "${signal-desktop}/lib/${dir}/resources/app.asar"
# (Alternatively we could try to patch the asar archive, but that requires a
# few additional steps and might not be the best idea.)
src = fetchurl {
inherit url hash;
};
nativeBuildInputs = [
autoPatchelfHook
dpkg
(wrapGAppsHook.override { inherit makeWrapper; })
];
buildInputs = [
alsa-lib
at-spi2-atk
at-spi2-core
atk
cairo
cups
dbus
expat
fontconfig
freetype
gdk-pixbuf
glib
gtk3
libX11
libXScrnSaver
libXcomposite
libXcursor
libXdamage
libXext
libXfixes
libXi
libXrandr
libXrender
libXtst
libappindicator-gtk3
libnotify
libuuid
mesa # for libgbm
nspr
nss
pango
systemd
xorg.libxcb
xorg.libxshmfence
];
runtimeDependencies = [
(lib.getLib systemd)
libappindicator-gtk3
libnotify
libdbusmenu
pipewire
stdenv.cc.cc
xdg-utils
wayland
];
unpackPhase = "dpkg-deb -x $src .";
dontBuild = true;
dontConfigure = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib
mv usr/share $out/share
mv "opt/${dir}" "$out/lib/${dir}"
# Symlink to bin
mkdir -p $out/bin
ln -s "$out/lib/${dir}/${pname}" $out/bin/${pname}
# Create required symlinks:
ln -s libGLESv2.so "$out/lib/${dir}/libGLESv2.so.2"
runHook postInstall
'';
preFixup = ''
gappsWrapperArgs+=(
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
)
# Fix the desktop link and fix showing application icon in tray
substituteInPlace $out/share/applications/${pname}.desktop \
--replace "/opt/${dir}/${pname}" $out/bin/${pname} \
${if pname == "signal-desktop" then "--replace \"bin/signal-desktop\" \"bin/signal-desktop --use-tray-icon\"" else ""}
# Note: The following path contains bundled libraries:
# $out/lib/${dir}/resources/app.asar.unpacked/node_modules/
patchelf --add-needed ${libpulseaudio}/lib/libpulse.so "$out/lib/${dir}/resources/app.asar.unpacked/node_modules/@signalapp/ringrtc/build/linux/libringrtc-${ARCH}.node"
'';
passthru = {
# Tests if the application launches and waits for "Link your phone to Signal Desktop":
tests.application-launch = nixosTests.signal-desktop;
updateScript.command = [ ./update.sh ];
};
meta = {
description = "Private, simple, and secure messenger";
longDescription = ''
Signal Desktop is an Electron application that links with your
"Signal Android" or "Signal iOS" app.
'';
homepage = "https://signal.org/";
changelog = "https://github.com/signalapp/Signal-Desktop/releases/tag/v${version}";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ eclairevoyant mic92 equirosa urandom bkchr ];
mainProgram = pname;
platforms = [ "x86_64-linux" "aarch64-linux" ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
};
}
|