Skip to content

Commit b94166b

Browse files
mumble: Enable build on Darwin (#384691)
2 parents 33a1178 + 50a753f commit b94166b

File tree

3 files changed

+121
-35
lines changed

3 files changed

+121
-35
lines changed

pkgs/applications/networking/mumble/default.nix

Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
boost,
1111
libopus,
1212
libsndfile,
13+
speexdsp,
1314
protobuf,
14-
speex,
1515
libcap,
1616
alsa-lib,
1717
python3,
@@ -22,16 +22,21 @@
2222
libogg,
2323
libvorbis,
2424
stdenv_32bit,
25+
alsaSupport ? stdenv.hostPlatform.isLinux,
2526
iceSupport ? true,
2627
zeroc-ice,
2728
jackSupport ? false,
2829
libjack2,
29-
pipewireSupport ? true,
30+
pipewireSupport ? stdenv.hostPlatform.isLinux,
3031
pipewire,
3132
pulseSupport ? true,
3233
libpulseaudio,
3334
speechdSupport ? false,
3435
speechd-minimal,
36+
microsoft-gsl,
37+
nlohmann_json,
38+
xar,
39+
makeWrapper,
3540
}:
3641

3742
let
@@ -52,18 +57,24 @@ let
5257
qt5.qttools
5358
] ++ (overrides.nativeBuildInputs or [ ]);
5459

55-
buildInputs = [
56-
avahi
57-
boost
58-
poco
59-
protobuf
60-
] ++ (overrides.buildInputs or [ ]);
60+
buildInputs =
61+
[
62+
boost
63+
poco
64+
protobuf
65+
microsoft-gsl
66+
nlohmann_json
67+
]
68+
++ lib.optionals stdenv.hostPlatform.isLinux [ avahi ]
69+
++ (overrides.buildInputs or [ ]);
6170

6271
cmakeFlags = [
6372
"-D g15=OFF"
6473
"-D CMAKE_CXX_STANDARD=17" # protobuf >22 requires C++ 17
6574
"-D BUILD_NUMBER=${lib.versions.patch source.version}"
66-
] ++ (overrides.configureFlags or [ ]);
75+
"-D bundled-gsl=OFF"
76+
"-D bundled-json=OFF"
77+
] ++ (overrides.cmakeFlags or [ ]);
6778

6879
preConfigure = ''
6980
patchShebangs scripts
@@ -79,7 +90,7 @@ let
7990
felixsinger
8091
lilacious
8192
];
82-
platforms = platforms.linux;
93+
platforms = platforms.linux ++ (overrides.platforms or [ ]);
8394
};
8495
}
8596
);
@@ -89,66 +100,107 @@ let
89100
generic {
90101
type = "mumble";
91102

92-
nativeBuildInputs = [ qt5.qttools ];
103+
platforms = lib.platforms.darwin;
104+
nativeBuildInputs =
105+
[ qt5.qttools ]
106+
++ lib.optionals stdenv.hostPlatform.isDarwin [
107+
makeWrapper
108+
];
109+
93110
buildInputs =
94111
[
95112
flac
96113
libogg
97114
libopus
98115
libsndfile
99116
libvorbis
117+
speexdsp
100118
qt5.qtsvg
101119
rnnoise
102-
speex
103120
]
104-
++ lib.optional (!jackSupport) alsa-lib
121+
++ lib.optional (!jackSupport && alsaSupport) alsa-lib
105122
++ lib.optional jackSupport libjack2
106123
++ lib.optional speechdSupport speechd-minimal
107124
++ lib.optional pulseSupport libpulseaudio
108-
++ lib.optional pipewireSupport pipewire;
125+
++ lib.optional pipewireSupport pipewire
126+
++ lib.optionals stdenv.hostPlatform.isDarwin [
127+
xar
128+
];
109129

110-
configureFlags =
111-
[
112-
"-D server=OFF"
113-
"-D bundled-celt=ON"
114-
"-D bundled-opus=OFF"
115-
"-D bundled-speex=OFF"
116-
"-D bundle-qt-translations=OFF"
117-
"-D update=OFF"
118-
"-D overlay-xcompile=OFF"
119-
"-D oss=OFF"
120-
"-D warnings-as-errors=OFF" # conversion error workaround
121-
]
122-
++ lib.optional (!speechdSupport) "-D speechd=OFF"
123-
++ lib.optional (!pulseSupport) "-D pulseaudio=OFF"
124-
++ lib.optional (!pipewireSupport) "-D pipewire=OFF"
125-
++ lib.optional jackSupport "-D alsa=OFF -D jackaudio=ON";
130+
cmakeFlags = [
131+
"-D server=OFF"
132+
"-D bundled-speex=OFF"
133+
"-D bundle-qt-translations=OFF"
134+
"-D update=OFF"
135+
"-D overlay-xcompile=OFF"
136+
"-D oss=OFF"
137+
"-D warnings-as-errors=OFF" # conversion error workaround
138+
# building the overlay on darwin does not work in nipxkgs (yet)
139+
# also see the patch below to disable scripts the build option misses
140+
# see https://github.com/mumble-voip/mumble/issues/6816
141+
(lib.cmakeBool "overlay" (!stdenv.hostPlatform.isDarwin))
142+
(lib.cmakeBool "speechd" speechdSupport)
143+
(lib.cmakeBool "pulseaudio" pulseSupport)
144+
(lib.cmakeBool "pipewire" pipewireSupport)
145+
(lib.cmakeBool "jackaudio" jackSupport)
146+
(lib.cmakeBool "alsa" (!jackSupport && alsaSupport))
147+
];
126148

127149
env.NIX_CFLAGS_COMPILE = lib.optionalString speechdSupport "-I${speechd-minimal}/include/speech-dispatcher";
128150

129-
postFixup = ''
151+
patches = [
152+
./disable-overlay-build.patch
153+
./fix-plugin-copy.patch
154+
# Can be removed before the next update of Mumble, as that fix was upstreamed
155+
# fix version display in MacOS Finder
156+
(fetchpatch {
157+
url = "https://github.com/mumble-voip/mumble/commit/fbd21bd422367bed19f801bf278562f567cbb8b7.patch";
158+
sha256 = "sha256-qFhC2j/cOWzAhs+KTccDIdcgFqfr4y4VLjHiK458Ucs=";
159+
})
160+
];
161+
162+
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
163+
# The build erraneously marks the *.dylib as executable
164+
# which causes the qt-hook to wrap it, which then prevents the app from loading it
165+
chmod -x $out/lib/mumble/plugins/*.dylib
166+
167+
# Post-processing for the app bundle
168+
$NIX_BUILD_TOP/source/macx/scripts/osxdist.py \
169+
--source-dir=$NIX_BUILD_TOP/source/ \
170+
--binary-dir=$out \
171+
--only-appbundle \
172+
--version "${source.version}"
173+
174+
mkdir -p $out/Applications $out/bin
175+
mv $out/Mumble.app $out/Applications/Mumble.app
176+
177+
# ensure that the app can be started from the shell
178+
makeWrapper $out/Applications/Mumble.app/Contents/MacOS/mumble $out/bin/mumble
179+
'';
180+
181+
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
130182
wrapProgram $out/bin/mumble \
131183
--prefix LD_LIBRARY_PATH : "${
132184
lib.makeLibraryPath (
133185
lib.optional pulseSupport libpulseaudio ++ lib.optional pipewireSupport pipewire
134186
)
135187
}"
136188
'';
189+
137190
} source;
138191

139192
server =
140193
source:
141194
generic {
142195
type = "murmur";
143196

144-
configureFlags =
197+
cmakeFlags =
145198
[
146199
"-D client=OFF"
200+
(lib.cmakeBool "ice" iceSupport)
147201
]
148-
++ lib.optional (!iceSupport) "-D ice=OFF"
149202
++ lib.optionals iceSupport [
150203
"-D Ice_HOME=${lib.getDev zeroc-ice};${lib.getLib zeroc-ice}"
151-
"-D CMAKE_PREFIX_PATH=${lib.getDev zeroc-ice};${lib.getLib zeroc-ice}"
152204
"-D Ice_SLICE_DIR=${lib.getDev zeroc-ice}/share/ice/slice"
153205
];
154206

@@ -161,7 +213,7 @@ let
161213
stdenv = stdenv_32bit;
162214
type = "mumble-overlay";
163215

164-
configureFlags = [
216+
cmakeFlags = [
165217
"-D server=OFF"
166218
"-D client=OFF"
167219
"-D overlay=ON"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/macx/scripts/osxdist.py b/macx/scripts/osxdist.py
2+
index bdc7fcbd2..2114caf37 100755
3+
--- a/macx/scripts/osxdist.py
4+
+++ b/macx/scripts/osxdist.py
5+
@@ -128,7 +128,7 @@ class AppBundle(object):
6+
shutil.copy(rsrc, os.path.join(rsrcpath, b))
7+
8+
# Extras
9+
- shutil.copy(os.path.join(options.binary_dir, 'MumbleOverlay.pkg'), os.path.join(rsrcpath, 'MumbleOverlay.pkg'))
10+
+ # shutil.copy(os.path.join(options.binary_dir, 'MumbleOverlay.pkg'), os.path.join(rsrcpath, 'MumbleOverlay.pkg'))
11+
12+
def copy_codecs(self):
13+
'''
14+
@@ -275,7 +276,7 @@ def package_client():
15+
title = 'Mumble %s' % ver
16+
17+
# Fix overlay installer package
18+
- create_overlay_package()
19+
+ # create_overlay_package()
20+
if options.only_overlay:
21+
sys.exit(0)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/macx/scripts/osxdist.py b/macx/scripts/osxdist.py
2+
index bdc7fcbd2..2114caf37 100755
3+
--- a/macx/scripts/osxdist.py
4+
+++ b/macx/scripts/osxdist.py
5+
@@ -151,7 +151,7 @@ class AppBundle(object):
6+
dst = os.path.join(self.bundle, 'Contents', 'Plugins')
7+
if not os.path.exists(dst):
8+
os.makedirs(dst)
9+
- for plugin in glob.glob(os.path.join(options.binary_dir, 'plugins') + '/*.dylib'):
10+
+ for plugin in glob.glob(os.path.join(options.binary_dir, 'lib/mumble/plugins') + '/*.dylib'):
11+
shutil.copy(plugin, dst)
12+
13+
def update_plist(self):

0 commit comments

Comments
 (0)