tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
telegram-desktop: build on Darwin
Ilya Fedin
2 years ago
533df7ae
12a0ade5
+167
-24
4 changed files
expand all
collapse all
unified
split
pkgs
applications
networking
instant-messengers
telegram
telegram-desktop
default.nix
macos.patch
tg_owt.nix
top-level
all-packages.nix
+72
-18
pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix
···
60
60
, mm-common
61
61
, rlottie
62
62
, stdenv
63
63
+
, darwin
64
64
+
, lld
65
65
+
, libicns
63
66
, nix-update-script
64
67
}:
65
68
···
72
75
73
76
let
74
77
tg_owt = callPackage ./tg_owt.nix {
78
78
+
inherit stdenv;
75
79
abseil-cpp = abseil-cpp.override {
76
80
cxxStandard = "20";
77
81
};
···
100
104
perlPackages.XMLParser
101
105
];
102
106
});
107
107
+
mainProgram = if stdenv.isLinux then "telegram-desktop" else "Telegram";
103
108
in
104
109
stdenv.mkDerivation rec {
105
110
pname = "telegram-desktop";
···
114
119
};
115
120
116
121
patches = [
122
122
+
./macos.patch
117
123
# the generated .desktop files contains references to unwrapped tdesktop, breaking scheme handling
118
124
# and the scheme handler is already registered in the packaged .desktop file, rendering this unnecessary
119
125
# see https://github.com/NixOS/nixpkgs/issues/218370
···
123
129
})
124
130
];
125
131
126
126
-
postPatch = ''
132
132
+
postPatch = lib.optionalString stdenv.isLinux ''
127
133
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \
128
134
--replace '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"'
129
135
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \
···
143
149
cmake
144
150
ninja
145
151
python3
152
152
+
wrapQtAppsHook
153
153
+
] ++ lib.optionals stdenv.isLinux [
146
154
gobject-introspection
147
155
wrapGAppsHook
148
148
-
wrapQtAppsHook
149
156
extra-cmake-modules
157
157
+
] ++ lib.optionals stdenv.isDarwin [
158
158
+
lld
150
159
];
151
160
152
161
buildInputs = [
153
162
qtbase
154
154
-
qtwayland
155
163
qtsvg
156
164
qtimageformats
157
157
-
gtk3
158
165
boost
159
159
-
fmt
160
160
-
libdbusmenu
161
166
lz4
162
167
xxHash
163
168
ffmpeg
164
169
openalSoft
165
170
minizip
166
171
libopus
172
172
+
range-v3
173
173
+
tl-expected
174
174
+
rnnoise
175
175
+
protobuf
176
176
+
tg_owt
177
177
+
microsoft-gsl
178
178
+
rlottie
179
179
+
] ++ lib.optionals stdenv.isLinux [
180
180
+
qtwayland
181
181
+
gtk3
182
182
+
fmt
183
183
+
libdbusmenu
167
184
alsa-lib
168
185
libpulseaudio
169
186
pipewire
170
170
-
range-v3
171
171
-
tl-expected
172
187
hunspell
173
188
glibmm
174
189
webkitgtk_6_0
175
190
jemalloc
176
176
-
rnnoise
177
177
-
protobuf
178
178
-
tg_owt
179
191
# Transitive dependencies:
180
192
util-linuxMinimal # Required for libmount thus not nativeBuildInputs.
181
193
pcre
···
192
204
libsysprof-capture
193
205
libpsl
194
206
brotli
195
195
-
microsoft-gsl
196
196
-
rlottie
197
197
-
];
207
207
+
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [
208
208
+
Cocoa
209
209
+
CoreFoundation
210
210
+
CoreServices
211
211
+
CoreText
212
212
+
CoreGraphics
213
213
+
CoreMedia
214
214
+
OpenGL
215
215
+
AudioUnit
216
216
+
ApplicationServices
217
217
+
Foundation
218
218
+
AGL
219
219
+
Security
220
220
+
SystemConfiguration
221
221
+
Carbon
222
222
+
AudioToolbox
223
223
+
VideoToolbox
224
224
+
VideoDecodeAcceleration
225
225
+
AVFoundation
226
226
+
CoreAudio
227
227
+
CoreVideo
228
228
+
CoreMediaIO
229
229
+
QuartzCore
230
230
+
AppKit
231
231
+
CoreWLAN
232
232
+
WebKit
233
233
+
IOKit
234
234
+
GSS
235
235
+
MediaPlayer
236
236
+
IOSurface
237
237
+
Metal
238
238
+
NaturalLanguage
239
239
+
libicns
240
240
+
]);
241
241
+
242
242
+
env = lib.optionalAttrs stdenv.isDarwin {
243
243
+
NIX_CFLAGS_LINK = "-fuse-ld=lld";
244
244
+
};
198
245
199
246
cmakeFlags = [
200
247
"-Ddisable_autoupdate=ON"
···
210
257
export GI_GIR_PATH="$XDG_DATA_DIRS"
211
258
'';
212
259
213
213
-
postFixup = ''
260
260
+
installPhase = lib.optionalString stdenv.isDarwin ''
261
261
+
mkdir -p $out/Applications
262
262
+
cp -r ${mainProgram}.app $out/Applications
263
263
+
ln -s $out/{Applications/${mainProgram}.app/Contents/MacOS,bin}
264
264
+
'';
265
265
+
266
266
+
postFixup = lib.optionalString stdenv.isLinux ''
214
267
# This is necessary to run Telegram in a pure environment.
215
268
# We also use gappsWrapperArgs from wrapGAppsHook.
216
216
-
wrapProgram $out/bin/telegram-desktop \
269
269
+
wrapProgram $out/bin/${mainProgram} \
217
270
"''${gappsWrapperArgs[@]}" \
218
271
"''${qtWrapperArgs[@]}" \
219
272
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
273
273
+
'' + lib.optionalString stdenv.isDarwin ''
274
274
+
wrapQtApp $out/Applications/${mainProgram}.app/Contents/MacOS/${mainProgram}
220
275
'';
221
276
222
277
passthru = {
···
231
286
the MTProto secure protocol.
232
287
'';
233
288
license = licenses.gpl3Only;
234
234
-
platforms = platforms.linux;
235
289
homepage = "https://desktop.telegram.org/";
236
290
changelog = "https://github.com/telegramdesktop/tdesktop/releases/tag/v${version}";
237
291
maintainers = with maintainers; [ nickcao ];
238
238
-
mainProgram = "telegram-desktop";
292
292
+
inherit mainProgram;
239
293
};
240
294
}
+69
pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/macos.patch
···
1
1
+
diff --git a/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm b/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
2
2
+
index ef544803e9..69c61b3139 100644
3
3
+
--- a/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
4
4
+
+++ b/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
5
5
+
@@ -97,9 +97,11 @@ void MacOverlayWidgetHelper::updateStyles(bool fullscreen) {
6
6
+
[window setTitleVisibility:NSWindowTitleHidden];
7
7
+
[window setTitlebarAppearsTransparent:YES];
8
8
+
[window setStyleMask:[window styleMask] | NSWindowStyleMaskFullSizeContentView];
9
9
+
+#if 0
10
10
+
if (@available(macOS 12.0, *)) {
11
11
+
_data->topNotchSkip = [[window screen] safeAreaInsets].top;
12
12
+
}
13
13
+
+#endif
14
14
+
}
15
15
+
16
16
+
void MacOverlayWidgetHelper::refreshButtons(bool fullscreen) {
17
17
+
Submodule Telegram/lib_base contains modified content
18
18
+
diff --git a/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm b/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
19
19
+
index 7ce90d3..dac3c2c 100644
20
20
+
--- a/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
21
21
+
+++ b/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
22
22
+
@@ -138,6 +138,7 @@ BatterySaving::BatterySaving(Fn<void()> changedCallback) {
23
23
+
_observer = [[LowPowerModeObserver alloc] initWithCallback:std::move(wrapped)];
24
24
+
25
25
+
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
26
26
+
+#if 0
27
27
+
if (@available(macOS 12.0, *)) {
28
28
+
[center
29
29
+
addObserver: _observer
30
30
+
@@ -145,6 +146,7 @@ BatterySaving::BatterySaving(Fn<void()> changedCallback) {
31
31
+
name: NSProcessInfoPowerStateDidChangeNotification
32
32
+
object: nil];
33
33
+
}
34
34
+
+#endif
35
35
+
[center
36
36
+
addObserver: _observer
37
37
+
selector: @selector(powerStateChanged:)
38
38
+
@@ -178,11 +180,13 @@ std::optional<bool> BatterySaving::enabled() const {
39
39
+
return std::nullopt;
40
40
+
}
41
41
+
NSProcessInfo *info = [NSProcessInfo processInfo];
42
42
+
+#if 0
43
43
+
if (@available(macOS 12.0, *)) {
44
44
+
if ([info isLowPowerModeEnabled]) {
45
45
+
return true;
46
46
+
}
47
47
+
}
48
48
+
+#endif
49
49
+
const auto state = DetectBatteryState();
50
50
+
if (!state.has || !state.draining) {
51
51
+
return false;
52
52
+
Submodule Telegram/lib_webview contains modified content
53
53
+
diff --git a/Telegram/lib_webview/webview/platform/mac/webview_mac.mm b/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
54
54
+
index 738e574..80ff5f0 100644
55
55
+
--- a/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
56
56
+
+++ b/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
57
57
+
@@ -254,10 +254,12 @@ void *Instance::winId() {
58
58
+
}
59
59
+
60
60
+
void Instance::setOpaqueBg(QColor opaqueBg) {
61
61
+
+#if 0
62
62
+
if (@available(macOS 12.0, *)) {
63
63
+
[_webview setValue: @NO forKey: @"drawsBackground"];
64
64
+
[_webview setUnderPageBackgroundColor:[NSColor clearColor]];
65
65
+
}
66
66
+
+#endif
67
67
+
}
68
68
+
69
69
+
void Instance::resizeToWindow() {
+21
-5
pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/tg_owt.nix
···
4
4
, openh264, usrsctp, libevent, libvpx
5
5
, libX11, libXtst, libXcomposite, libXdamage, libXext, libXrender, libXrandr, libXi
6
6
, glib, abseil-cpp, pcre, util-linuxMinimal, libselinux, libsepol, pipewire
7
7
-
, mesa, libepoxy, libglvnd, unstableGitUpdater
7
7
+
, mesa, libepoxy, libglvnd, unstableGitUpdater, darwin
8
8
}:
9
9
10
10
stdenv.mkDerivation {
···
24
24
nativeBuildInputs = [ pkg-config cmake ninja yasm ];
25
25
26
26
buildInputs = [
27
27
-
libjpeg libopus ffmpeg alsa-lib libpulseaudio protobuf
28
28
-
openh264 usrsctp libevent libvpx
27
27
+
libjpeg libopus ffmpeg protobuf openh264 usrsctp libevent libvpx abseil-cpp
28
28
+
] ++ lib.optionals stdenv.isLinux [
29
29
libX11 libXtst libXcomposite libXdamage libXext libXrender libXrandr libXi
30
30
-
glib abseil-cpp pcre util-linuxMinimal libselinux libsepol pipewire
30
30
+
glib pcre util-linuxMinimal libselinux libsepol pipewire alsa-lib libpulseaudio
31
31
mesa libepoxy libglvnd
32
32
-
];
32
32
+
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
33
33
+
Cocoa
34
34
+
AppKit
35
35
+
IOKit
36
36
+
IOSurface
37
37
+
Foundation
38
38
+
AVFoundation
39
39
+
CoreMedia
40
40
+
VideoToolbox
41
41
+
CoreGraphics
42
42
+
CoreVideo
43
43
+
OpenGL
44
44
+
Metal
45
45
+
MetalKit
46
46
+
CoreFoundation
47
47
+
ApplicationServices
48
48
+
]);
33
49
34
50
patches = [
35
51
# GCC 12 Fix
+5
-1
pkgs/top-level/all-packages.nix
···
35720
35720
35721
35721
taskopen = callPackage ../applications/misc/taskopen { };
35722
35722
35723
35723
-
telegram-desktop = qt6Packages.callPackage ../applications/networking/instant-messengers/telegram/telegram-desktop { };
35723
35723
+
telegram-desktop = qt6Packages.callPackage ../applications/networking/instant-messengers/telegram/telegram-desktop {
35724
35724
+
stdenv = if stdenv.isDarwin
35725
35725
+
then overrideSDK stdenv "11.0"
35726
35726
+
else stdenv;
35727
35727
+
};
35724
35728
35725
35729
telegram-bot-api = callPackage ../servers/telegram-bot-api { };
35726
35730