Skip to content

Commit bc0f86a

Browse files
committed
signal-desktop-source: init at 7.45.1
1 parent 36fd87b commit bc0f86a

File tree

2 files changed

+353
-0
lines changed

2 files changed

+353
-0
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
{
2+
stdenv,
3+
lib,
4+
nodejs_20,
5+
pnpm_10,
6+
electron_33,
7+
python3,
8+
makeWrapper,
9+
libpulseaudio,
10+
fetchFromGitHub,
11+
runCommand,
12+
fetchurl,
13+
fetchzip,
14+
autoPatchelfHook,
15+
makeDesktopItem,
16+
copyDesktopItems,
17+
replaceVars,
18+
noto-fonts-color-emoji,
19+
withAppleEmojis ? false,
20+
}:
21+
let
22+
nodejs = nodejs_20;
23+
pnpm = pnpm_10;
24+
electron = electron_33;
25+
26+
electron-headers = runCommand "electron-headers" { } ''
27+
mkdir -p $out
28+
tar -C $out --strip-components=1 -xvf ${electron.headers}
29+
'';
30+
31+
sqlcipher = fetchurl {
32+
# https://github.com/signalapp/Signal-Sqlcipher-Extension
33+
url = "https://build-artifacts.signal.org/desktop/sqlcipher-v2-4.6.1-signal-patch2--0.2.1-asm2-6253f886c40e49bf892d5cdc92b2eb200b12cd8d80c48ce5b05967cfd01ee8c7.tar.gz";
34+
hash = "sha256-YlP4hsQOSb+JLVzckrLrIAsSzY2AxIzlsFlnz9Ae6Mc=";
35+
};
36+
37+
ringrtc = stdenv.mkDerivation (finalAttrs: {
38+
pname = "ringrtc-bin";
39+
version = "2.50.1";
40+
src = fetchzip {
41+
url = "https://build-artifacts.signal.org/libraries/ringrtc-desktop-build-v${finalAttrs.version}.tar.gz";
42+
hash = "sha256-KHNTw5ScBdYAAyKFdJ6PTmFr+7GYHqgnb4mmNUJZvzM=";
43+
};
44+
45+
installPhase = ''
46+
cp -r . $out
47+
'';
48+
49+
nativeBuildInputs = [ autoPatchelfHook ];
50+
buildInputs = [ libpulseaudio ];
51+
meta = {
52+
homepage = "https://github.com/signalapp/ringrtc";
53+
license = lib.licenses.agpl3Only;
54+
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
55+
};
56+
});
57+
58+
# Noto Color Emoji PNG files for emoji replacement; see below.
59+
noto-fonts-color-emoji-png = noto-fonts-color-emoji.overrideAttrs (prevAttrs: {
60+
pname = "noto-fonts-color-emoji-png";
61+
62+
# The build produces 136×128 PNGs by default for arcane font
63+
# reasons, but we want square PNGs.
64+
buildFlags = prevAttrs.buildFlags or [ ] ++ [ "BODY_DIMENSIONS=128x128" ];
65+
66+
makeTargets = [ "compressed" ];
67+
68+
installPhase = ''
69+
runHook preInstall
70+
71+
mkdir -p $out/share
72+
mv build/compressed_pngs $out/share/noto-fonts-color-emoji-png
73+
python3 add_aliases.py --srcdir=$out/share/noto-fonts-color-emoji-png
74+
75+
runHook postInstall
76+
'';
77+
});
78+
in
79+
stdenv.mkDerivation (finalAttrs: {
80+
pname = "signal-desktop-source";
81+
version = "7.45.1";
82+
83+
src = fetchFromGitHub {
84+
owner = "signalapp";
85+
repo = "Signal-Desktop";
86+
tag = "v${finalAttrs.version}";
87+
hash = "sha256-VtnER2NsVh/YH4V9skq0QQ6daHAqne4mu+wUnGUgb4g=";
88+
};
89+
90+
nativeBuildInputs = [
91+
nodejs
92+
(pnpm.override { inherit nodejs; }).configHook
93+
makeWrapper
94+
copyDesktopItems
95+
python3
96+
];
97+
buildInputs = (lib.optional (!withAppleEmojis) noto-fonts-color-emoji-png);
98+
99+
patches = lib.optional (!withAppleEmojis) (
100+
replaceVars ./replace-apple-emoji-with-noto-emoji.patch {
101+
noto-emoji-pngs = "${noto-fonts-color-emoji-png}/share/noto-fonts-color-emoji-png";
102+
}
103+
);
104+
105+
pnpmDeps = pnpm.fetchDeps {
106+
inherit (finalAttrs)
107+
pname
108+
version
109+
src
110+
patches
111+
;
112+
hash =
113+
if withAppleEmojis then
114+
"sha256-5A2MP6HiRt6KhUvqChnzH903CU7xbnSMrX8ELQIrtoc="
115+
else
116+
"sha256-z1HjmbaOYjNkA6ios2iSvFDjlPKh8/jLr8WiEMGnXok=";
117+
};
118+
119+
env = {
120+
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
121+
SIGNAL_ENV = "production";
122+
SOURCE_DATE_EPOCH = 1741560867;
123+
};
124+
125+
preBuild = ''
126+
substituteInPlace node_modules/@signalapp/better-sqlite3/deps/download.js \
127+
--replace-fail "path.join(__dirname, 'sqlcipher.tar.gz')" "'${sqlcipher}'"
128+
129+
cp -r ${ringrtc} node_modules/@signalapp/ringrtc/build
130+
'';
131+
132+
buildPhase = ''
133+
runHook preBuild
134+
135+
export npm_config_nodedir=${electron-headers}
136+
cp -r ${electron.dist} electron-dist
137+
chmod -R u+w electron-dist
138+
139+
pnpm run generate
140+
pnpm exec electron-builder \
141+
--dir \
142+
--config.extraMetadata.environment=$SIGNAL_ENV \
143+
-c.electronDist=electron-dist \
144+
-c.electronVersion=${electron.version}
145+
146+
runHook postBuild
147+
'';
148+
149+
installPhase = ''
150+
runHook preInstall
151+
152+
mkdir -p $out/share/
153+
cp -r dist/*-unpacked/resources $out/share/signal-desktop
154+
155+
for icon in build/icons/png/*
156+
do
157+
install -Dm644 $icon $out/share/icons/hicolor/`basename ''${icon%.png}`/apps/signal-desktop.png
158+
done
159+
160+
makeWrapper '${lib.getExe electron}' "$out/bin/signal-desktop" \
161+
--add-flags "$out/share/signal-desktop/app.asar" \
162+
--set-default ELECTRON_FORCE_IS_PACKAGED 1 \
163+
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"
164+
165+
runHook postInstall
166+
'';
167+
168+
desktopItems = [
169+
(makeDesktopItem {
170+
name = finalAttrs.pname;
171+
desktopName = "Signal";
172+
exec = "${finalAttrs.meta.mainProgram} %U";
173+
type = "Application";
174+
terminal = false;
175+
icon = "signal-desktop";
176+
comment = "Private messaging from your desktop";
177+
startupWMClass = "signal";
178+
mimeTypes = [
179+
"x-scheme-handler/sgnl"
180+
"x-scheme-handler/signalcaptcha"
181+
];
182+
categories = [
183+
"Network"
184+
"InstantMessaging"
185+
"Chat"
186+
];
187+
})
188+
];
189+
190+
meta = {
191+
description = "Private, simple, and secure messenger (nixpkgs build)";
192+
longDescription = ''
193+
Signal Desktop is an Electron application that links with your
194+
"Signal Android" or "Signal iOS" app.
195+
'';
196+
homepage = "https://signal.org/";
197+
changelog = "https://github.com/signalapp/Signal-Desktop/releases/tag/v${finalAttrs.version}";
198+
license =
199+
with lib.licenses;
200+
[
201+
agpl3Only
202+
203+
# Various npm packages
204+
free
205+
]
206+
++ lib.optional withAppleEmojis unfree;
207+
maintainers = with lib.maintainers; [
208+
marcin-serwin
209+
];
210+
mainProgram = "signal-desktop";
211+
platforms = [
212+
"x86_64-linux"
213+
"aarch64-linux"
214+
];
215+
sourceProvenance = with lib.sourceTypes; [
216+
fromSource
217+
218+
# sqlcipher
219+
# ringrtc
220+
# node_modules/@signalapp/libsignal-client/prebuilds/
221+
binaryNativeCode
222+
];
223+
};
224+
})
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
diff --git a/ACKNOWLEDGMENTS.md b/ACKNOWLEDGMENTS.md
2+
index aed1048..e4c1f50 100644
3+
--- a/ACKNOWLEDGMENTS.md
4+
+++ b/ACKNOWLEDGMENTS.md
5+
@@ -745,30 +745,6 @@ Signal Desktop makes use of the following open source projects.
6+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7+
SOFTWARE.
8+
9+
-## emoji-datasource-apple
10+
-
11+
- The MIT License (MIT)
12+
-
13+
- Copyright (c) 2013 Cal Henderson
14+
-
15+
- Permission is hereby granted, free of charge, to any person obtaining a copy
16+
- of this software and associated documentation files (the "Software"), to deal
17+
- in the Software without restriction, including without limitation the rights
18+
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19+
- copies of the Software, and to permit persons to whom the Software is
20+
- furnished to do so, subject to the following conditions:
21+
-
22+
- The above copyright notice and this permission notice shall be included in all
23+
- copies or substantial portions of the Software.
24+
-
25+
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28+
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29+
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30+
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31+
- SOFTWARE.
32+
-
33+
## emoji-regex
34+
35+
Copyright Mathias Bynens <https://mathiasbynens.be/>
36+
diff --git a/app/protocol_filter.ts b/app/protocol_filter.ts
37+
index 68dceea..4b35bb1 100644
38+
--- a/app/protocol_filter.ts
39+
+++ b/app/protocol_filter.ts
40+
@@ -59,6 +59,7 @@ function _createFileHandler({
41+
const allowedRoots = [
42+
userDataPath,
43+
installPath,
44+
+ "@noto-emoji-pngs@",
45+
getAvatarsPath(userDataPath),
46+
getBadgesPath(userDataPath),
47+
getDraftPath(userDataPath),
48+
diff --git a/package.json b/package.json
49+
index 3a6ac26..40cdb25 100644
50+
--- a/package.json
51+
+++ b/package.json
52+
@@ -130,7 +130,6 @@
53+
"dashdash": "2.0.0",
54+
"direction": "1.0.4",
55+
"emoji-datasource": "15.1.2",
56+
- "emoji-datasource-apple": "15.1.2",
57+
"emoji-regex": "10.4.0",
58+
"encoding": "0.1.13",
59+
"fabric": "4.6.0",
60+
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
61+
index ba2f205..705e454 100644
62+
--- a/pnpm-lock.yaml
63+
+++ b/pnpm-lock.yaml
64+
@@ -169,9 +169,6 @@ importers:
65+
emoji-datasource:
66+
specifier: 15.1.2
67+
version: 15.1.2
68+
- emoji-datasource-apple:
69+
- specifier: 15.1.2
70+
- version: 15.1.2
71+
emoji-regex:
72+
specifier: 10.4.0
73+
version: 10.4.0
74+
@@ -4790,9 +4787,6 @@ packages:
75+
resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==}
76+
engines: {node: '>=12'}
77+
78+
79+
- resolution: {integrity: sha512-32UZTK36x4DlvgD1smkmBlKmmJH7qUr5Qut4U/on2uQLGqNXGbZiheq6/LEA8xRQEUrmNrGEy25wpEI6wvYmTg==}
80+
-
81+
82+
resolution: {integrity: sha512-tXAqGsrDVhgCRpFePtaD9P4Z8Ro2SUQSL/4MIJBG0SxqQJaMslEbin8J53OaFwEBu6e7JxFaIF6s4mw9+8acAQ==}
83+
84+
@@ -14929,8 +14923,6 @@ snapshots:
85+
86+
87+
88+
89+
-
90+
91+
92+
93+
diff --git a/ts/components/conversation/Emojify.tsx b/ts/components/conversation/Emojify.tsx
94+
index f0b1115..7613230 100644
95+
--- a/ts/components/conversation/Emojify.tsx
96+
+++ b/ts/components/conversation/Emojify.tsx
97+
@@ -35,8 +35,15 @@ function getImageTag({
98+
}
99+
100+
let srcSet: string | undefined;
101+
+ const emojiToNotoName = (emoji: string): string =>
102+
+ `emoji_u${
103+
+ [...emoji]
104+
+ .filter(c => c != "\ufe0f")
105+
+ .map(c => c.codePointAt(0)?.toString(16).padStart(4, "0"))
106+
+ .join("_")
107+
+ }.png`;
108+
if (sizeClass != null && JUMBO_SIZES.has(sizeClass)) {
109+
- srcSet = `emoji://jumbo?emoji=${encodeURIComponent(match)} 2x, ${img}`;
110+
+ srcSet = `file://@noto-emoji-pngs@/${emojiToNotoName(match)} 2x, ${img}`;
111+
}
112+
113+
return (
114+
diff --git a/ts/components/emoji/lib.ts b/ts/components/emoji/lib.ts
115+
index 9753017..cf51d3d 100644
116+
--- a/ts/components/emoji/lib.ts
117+
+++ b/ts/components/emoji/lib.ts
118+
@@ -102,7 +102,10 @@ const ROOT_PATH = get(
119+
);
120+
121+
const makeImagePath = (src: string) => {
122+
- return `${ROOT_PATH}node_modules/emoji-datasource-apple/img/apple/64/${src}`;
123+
+ const datasourceToNoto = (name: string): string =>
124+
+ `emoji_u${name.slice(0,-4).split("-").filter(c => c != "fe0f").join("_")}.png`;
125+
+
126+
+ return `@noto-emoji-pngs@/${datasourceToNoto(src)}`;
127+
};
128+
129+
const imageQueue = new PQueue({

0 commit comments

Comments
 (0)