nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 pname,
3 version,
4 packageVersion ? version,
5 meta,
6 updateScript ? null,
7 binaryName ? "firefox",
8 application ? "browser",
9 applicationName ? "Firefox",
10 branding ? null,
11 requireSigning ? true,
12 allowAddonSideload ? false,
13 src,
14 unpackPhase ? null,
15 extraPatches ? [ ],
16 extraPostPatch ? "",
17 extraNativeBuildInputs ? [ ],
18 extraConfigureFlags ? [ ],
19 extraBuildInputs ? [ ],
20 extraMakeFlags ? [ ],
21 extraPassthru ? { },
22 tests ? { },
23}:
24
25let
26 # Rename the variables to prevent infinite recursion
27 requireSigningDefault = requireSigning;
28 allowAddonSideloadDefault = allowAddonSideload;
29
30 # Specifying --(dis|en)able-elf-hack on a platform for which it's not implemented will give `--disable-elf-hack is not available in this configuration`
31 # This is declared here because it's used in the default value of elfhackSupport
32 isElfhackPlatform =
33 stdenv:
34 stdenv.hostPlatform.isElf
35 && (
36 stdenv.hostPlatform.isi686
37 || stdenv.hostPlatform.isx86_64
38 || stdenv.hostPlatform.isAarch32
39 || stdenv.hostPlatform.isAarch64
40 );
41in
42
43{
44 lib,
45 pkgs,
46 stdenv,
47 patchelf,
48 fetchpatch,
49
50 # build time
51 autoconf,
52 cargo,
53 dump_syms,
54 makeBinaryWrapper,
55 mimalloc,
56 nodejs,
57 perl,
58 pkg-config,
59 pkgsCross, # wasm32 rlbox
60 python3,
61 runCommand,
62 rustc,
63 rust-cbindgen,
64 rustPlatform,
65 unzip,
66 which,
67 wrapGAppsHook3,
68
69 # runtime
70 bzip2,
71 dbus,
72 dbus-glib,
73 file,
74 fontconfig,
75 freetype,
76 glib,
77 gnum4,
78 gtk3,
79 libGL,
80 libGLU,
81 libevent,
82 libffi,
83 libjpeg,
84 libpng,
85 libstartup_notification,
86 libvpx,
87 libwebp,
88 nasm,
89 nspr,
90 nss_esr,
91 nss_latest,
92 onnxruntime,
93 pango,
94 libxt,
95 libxtst,
96 libxrender,
97 libxi,
98 libxft,
99 libxext,
100 libxdamage,
101 libxcursor,
102 libx11,
103 xorgproto,
104 pixman,
105 zip,
106 zlib,
107 pkgsBuildBuild,
108
109 # Darwin
110 apple-sdk_14,
111 apple-sdk_15,
112 apple-sdk_26,
113 cups,
114 rsync, # used when preparing .app directory
115
116 # optionals
117
118 ## addon signing/sideloading
119 requireSigning ? requireSigningDefault,
120 allowAddonSideload ? allowAddonSideloadDefault,
121
122 ## debugging
123
124 debugBuild ? false,
125
126 # On 32bit platforms, we disable adding "-g" for easier linking.
127 enableDebugSymbols ? !stdenv.hostPlatform.is32bit,
128
129 ## optional libraries
130
131 alsaSupport ? stdenv.hostPlatform.isLinux,
132 alsa-lib,
133 ffmpegSupport ? true,
134 gssSupport ? true,
135 libkrb5,
136 jackSupport ? stdenv.hostPlatform.isLinux,
137 libjack2,
138 jemallocSupport ? !stdenv.hostPlatform.isMusl,
139 jemalloc,
140 ltoSupport ? (
141 (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin)
142 && stdenv.hostPlatform.is64bit
143 && !stdenv.hostPlatform.isRiscV
144 ),
145 overrideCC,
146 buildPackages,
147 pgoSupport ? (stdenv.hostPlatform.isLinux && stdenv.hostPlatform == stdenv.buildPlatform),
148 xvfb-run,
149 elfhackSupport ?
150 isElfhackPlatform stdenv && !(stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isAarch64),
151 pipewireSupport ? waylandSupport && webrtcSupport,
152 pulseaudioSupport ? stdenv.hostPlatform.isLinux,
153 libpulseaudio,
154 sndioSupport ? stdenv.hostPlatform.isLinux,
155 sndio,
156 waylandSupport ? !stdenv.hostPlatform.isDarwin,
157 libxkbcommon,
158 libdrm,
159
160 ## privacy-related options
161
162 privacySupport ? false,
163
164 # WARNING: NEVER set any of the options below to `true` by default.
165 # Set to `!privacySupport` or `false`.
166
167 crashreporterSupport ?
168 !privacySupport
169 && !stdenv.hostPlatform.isLoongArch64
170 && !stdenv.hostPlatform.isRiscV
171 && !stdenv.hostPlatform.isMusl,
172 curl,
173 geolocationSupport ? !privacySupport,
174 webrtcSupport ? !privacySupport,
175
176 # digital rights management
177
178 # This flag controls whether Firefox will show the nagbar, that allows
179 # users at runtime the choice to enable Widevine CDM support when a site
180 # requests it.
181 # Controlling the nagbar and widevine CDM at runtime is possible by setting
182 # `browser.eme.ui.enabled` and `media.gmp-widevinecdm.enabled` accordingly
183 drmSupport ? true,
184
185 # As stated by Sylvestre Ledru (@sylvestre) on Nov 22, 2017 at
186 # https://github.com/NixOS/nixpkgs/issues/31843#issuecomment-346372756 we
187 # have permission to use the official firefox branding.
188 #
189 # For purposes of documentation the statement of @sylvestre:
190 # > As the person who did part of the work described in the LWN article
191 # > and release manager working for Mozilla, I can confirm the statement
192 # > that I made in
193 # > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815006
194 # >
195 # > @garbas shared with me the list of patches applied for the Nix package.
196 # > As they are just for portability and tiny modifications, they don't
197 # > alter the experience of the product. In parallel, Rok also shared the
198 # > build options. They seem good (even if I cannot judge the quality of the
199 # > packaging of the underlying dependencies like sqlite, png, etc).
200 # > Therefor, as long as you keep the patch queue sane and you don't alter
201 # > the experience of Firefox users, you won't have any issues using the
202 # > official branding.
203 enableOfficialBranding ? true,
204}:
205
206assert stdenv.cc.libc or null != null;
207assert
208 pipewireSupport
209 -> !waylandSupport || !webrtcSupport
210 -> throw "${pname}: pipewireSupport requires both wayland and webrtc support.";
211assert elfhackSupport -> isElfhackPlatform stdenv;
212
213let
214 inherit (lib) enableFeature;
215
216 # Target the LLVM version that rustc is built with for LTO.
217 llvmPackages0 = rustc.llvmPackages;
218 llvmPackagesBuildBuild0 = pkgsBuildBuild.rustc.llvmPackages;
219
220 # Force the use of lld and other llvm tools for LTO
221 llvmPackages = llvmPackages0.override {
222 bootBintoolsNoLibc = null;
223 bootBintools = null;
224 };
225 llvmPackagesBuildBuild = llvmPackagesBuildBuild0.override {
226 bootBintoolsNoLibc = null;
227 bootBintools = null;
228 };
229
230 # LTO requires LLVM bintools including ld.lld and llvm-ar.
231 buildStdenv = overrideCC llvmPackages.stdenv (
232 llvmPackages.stdenv.cc.override {
233 bintools = if ltoSupport then buildPackages.rustc.llvmPackages.bintools else stdenv.cc.bintools;
234 }
235 );
236
237 # Compile the wasm32 sysroot to build the RLBox Sandbox
238 # https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/
239 # We only link c++ libs here, our compiler wrapper can find wasi libc and crt itself.
240 wasiSysRoot = runCommand "wasi-sysroot" { } ''
241 mkdir -p $out/lib/wasm32-wasi
242 for lib in ${pkgsCross.wasi32.llvmPackages.libcxx}/lib/*; do
243 ln -s $lib $out/lib/wasm32-wasi
244 done
245 '';
246
247 distributionIni =
248 let
249 platform = if stdenv.hostPlatform.isDarwin then "Nix on MacOS" else "NixOS";
250 in
251 pkgs.writeText "distribution.ini" (
252 lib.generators.toINI { } {
253 # Some light branding indicating this build uses our distro preferences
254 Global = {
255 id = "nixos";
256 version = "1.0";
257 about = "${applicationName} for ${platform}";
258 };
259 Preferences = {
260 # These values are exposed through telemetry
261 "app.distributor" = "nixos";
262 "app.distributor.channel" = "nixpkgs";
263 };
264 }
265 );
266
267 defaultPrefs =
268 if geolocationSupport then
269 {
270 "geo.provider.network.url" = {
271 value = "https://api.beacondb.net/v1/geolocate";
272 reason = "We have no Google API keys and Mozilla Location Services were retired.";
273 };
274 }
275 else
276 {
277 "geo.provider.use_geoclue" = {
278 value = false;
279 reason = "Geolocation support has been disabled through the `geolocationSupport` package attribute.";
280 };
281 };
282
283 defaultPrefsFile = pkgs.writeText "nixos-default-prefs.js" (
284 lib.concatStringsSep "\n" (
285 lib.mapAttrsToList (key: value: ''
286 // ${value.reason}
287 pref("${key}", ${builtins.toJSON value.value});
288 '') defaultPrefs
289 )
290 );
291
292 toolkit =
293 if stdenv.hostPlatform.isDarwin then
294 "cairo-cocoa"
295 else
296 "cairo-gtk3${lib.optionalString waylandSupport "-wayland"}";
297
298in
299
300buildStdenv.mkDerivation {
301 pname = "${pname}-unwrapped";
302 version = packageVersion;
303
304 inherit src unpackPhase;
305
306 meta =
307 meta
308 // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
309 # MacOS builds may take a long time and sometimes hit the default timeout
310 timeout = lib.max (24 * 60 * 60) (meta.timeout or 0);
311 };
312
313 outputs = [
314 "out"
315 ]
316 ++ lib.optionals crashreporterSupport [ "symbols" ];
317
318 # Add another configure-build-profiling run before the final configure phase if we build with pgo
319 preConfigurePhases = lib.optionals pgoSupport [
320 "configurePhase"
321 "buildPhase"
322 "profilingPhase"
323 ];
324
325 patches =
326 # Remove references to the build clsoure
327 lib.optionals (lib.versionAtLeast version "136") [ ./136-no-buildconfig.patch ]
328 # Add MOZ_SYSTEM_DIR env var for native messaging host support
329 ++ lib.optionals (lib.versionAtLeast version "133") [ ./133-env-var-for-system-dir.patch ]
330 ++ lib.optionals (lib.versionAtLeast version "139" && lib.versionOlder version "141") [
331 # https://bugzilla.mozilla.org/show_bug.cgi?id=1955112
332 # https://hg-edge.mozilla.org/mozilla-central/rev/aa8a29bd1fb9
333 ./139-wayland-drag-animation.patch
334 ]
335 # Revert apple sdk bump to 26.1 and 26.2
336 ++
337 lib.optionals (lib.versionAtLeast version "148" && lib.versionOlder apple-sdk_26.version "26.2")
338 [
339 (fetchpatch {
340 url = "https://github.com/mozilla-firefox/firefox/commit/73cbb9ff0fdbf8b13f38d078ce01ef6ec0794f9c.patch";
341 hash = "sha256-ghdddJxsaxXzLZpOOfwss+2S/UUcbLqKGzWWqKy9h/k=";
342 revert = true;
343 })
344 ]
345 ++
346 lib.optionals (lib.versionAtLeast version "146" && lib.versionOlder apple-sdk_26.version "26.1")
347 [
348 (fetchpatch {
349 url = "https://github.com/mozilla-firefox/firefox/commit/c1cd0d56e047a40afb2a59a56e1fd8043e448e05.patch";
350 hash = "sha256-bFHLy3b0jOcROqltIwHwSAqWYve8OZHbiPMOdhLUCLc=";
351 revert = true;
352 })
353 ]
354 ++ extraPatches;
355
356 postPatch = ''
357 rm -rf obj-x86_64-pc-linux-gnu
358 patchShebangs mach build
359 ''
360 + extraPostPatch;
361
362 # Ignore trivial whitespace changes in patches, this fixes compatibility of
363 # ./env_var_for_system_dir-*.patch with Firefox >=65 without having to track
364 # two patches.
365 patchFlags = [
366 "-p1"
367 "-l"
368 ];
369
370 # if not explicitly set, wrong cc from buildStdenv would be used
371 HOST_CC = "${llvmPackagesBuildBuild.stdenv.cc}/bin/cc";
372 HOST_CXX = "${llvmPackagesBuildBuild.stdenv.cc}/bin/c++";
373
374 nativeBuildInputs = [
375 autoconf
376 cargo
377 gnum4
378 llvmPackagesBuildBuild.bintools
379 makeBinaryWrapper
380 nodejs
381 perl
382 python3
383 rust-cbindgen
384 rustPlatform.bindgenHook
385 rustc
386 unzip
387 which
388 ]
389 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
390 pkg-config
391 wrapGAppsHook3
392 ]
393 ++ lib.optionals stdenv.hostPlatform.isDarwin [ rsync ]
394 ++ lib.optionals stdenv.hostPlatform.isx86 [ nasm ]
395 ++ lib.optionals crashreporterSupport [
396 dump_syms
397 patchelf
398 ]
399 ++ lib.optionals pgoSupport [ xvfb-run ]
400 ++ extraNativeBuildInputs;
401
402 setOutputFlags = false; # `./mach configure` doesn't understand `--*dir=` flags.
403
404 preConfigure = ''
405 # Runs autoconf through ./mach configure in configurePhase
406 configureScript="$(realpath ./mach) configure"
407
408 # Set reproducible build date; https://bugzilla.mozilla.org/show_bug.cgi?id=885777#c21
409 export MOZ_BUILD_DATE=$(head -n1 sourcestamp.txt)
410
411 # Set predictable directories for build and state
412 export MOZ_OBJDIR=$(pwd)/objdir
413 export MOZBUILD_STATE_PATH=$TMPDIR/mozbuild
414
415 # Don't try to send libnotify notifications during build
416 export MOZ_NOSPAM=1
417
418 # Set consistent remoting name to ensure wmclass matches with desktop file
419 export MOZ_APP_REMOTINGNAME="${binaryName}"
420
421 # AS=as in the environment causes build failure
422 # https://bugzilla.mozilla.org/show_bug.cgi?id=1497286
423 unset AS
424
425 # Use our own python
426 export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
427
428 # RBox WASM Sandboxing
429 export WASM_CC=${pkgsCross.wasi32.stdenv.cc}/bin/${pkgsCross.wasi32.stdenv.cc.targetPrefix}cc
430 export WASM_CXX=${pkgsCross.wasi32.stdenv.cc}/bin/${pkgsCross.wasi32.stdenv.cc.targetPrefix}c++
431 ''
432 + lib.optionalString pgoSupport ''
433 if [ -e "$TMPDIR/merged.profdata" ]; then
434 echo "Configuring with profiling data"
435 for i in "''${!configureFlagsArray[@]}"; do
436 if [[ ''${configureFlagsArray[i]} = "--enable-profile-generate=cross" ]]; then
437 unset 'configureFlagsArray[i]'
438 fi
439 done
440 appendToVar configureFlags --enable-profile-use=cross
441 appendToVar configureFlags --with-pgo-profile-path=$TMPDIR/merged.profdata
442 appendToVar configureFlags --with-pgo-jarlog=$TMPDIR/jarlog
443 ${lib.optionalString stdenv.hostPlatform.isMusl ''
444 LDFLAGS="$OLD_LDFLAGS"
445 unset OLD_LDFLAGS
446 ''}
447 else
448 echo "Configuring to generate profiling data"
449 configureFlagsArray+=(
450 "--enable-profile-generate=cross"
451 )
452 ${lib.optionalString stdenv.hostPlatform.isMusl
453 # Set the rpath appropriately for the profiling run
454 # During the profiling run, loading libraries from $out would fail,
455 # since the profiling build has not been installed to $out
456 ''
457 OLD_LDFLAGS="$LDFLAGS"
458 LDFLAGS="-Wl,-rpath,$(pwd)/objdir/dist/${binaryName}"
459 ''
460 }
461 fi
462 ''
463 + lib.optionalString (enableOfficialBranding && !stdenv.hostPlatform.is32bit) ''
464 export MOZILLA_OFFICIAL=1
465 ''
466 + lib.optionalString (!requireSigning) ''
467 export MOZ_REQUIRE_SIGNING=
468 ''
469 + lib.optionalString stdenv.hostPlatform.isMusl ''
470 # linking firefox hits the vm.max_map_count kernel limit with the default musl allocator
471 # TODO: Default vm.max_map_count has been increased, retest without this
472 export LD_PRELOAD=${mimalloc}/lib/libmimalloc.so
473 '';
474
475 # firefox has a different definition of configurePlatforms from nixpkgs, see configureFlags
476 configurePlatforms = [ ];
477
478 configureFlags = [
479 "--disable-tests"
480 "--disable-updater"
481 "--enable-application=${application}"
482 "--enable-default-toolkit=${toolkit}"
483 "--with-app-name=${binaryName}"
484 "--with-distribution-id=org.nixos"
485 "--with-libclang-path=${lib.getLib llvmPackagesBuildBuild.libclang}/lib"
486 "--with-wasi-sysroot=${wasiSysRoot}"
487 # for firefox, host is buildPlatform, target is hostPlatform
488 "--host=${buildStdenv.buildPlatform.config}"
489 "--target=${buildStdenv.hostPlatform.config}"
490 ]
491 # LTO is done using clang and lld.
492 ++ lib.optionals ltoSupport [
493 "--enable-lto=cross,full" # Cross-Language LTO
494 "--enable-linker=lld"
495 ]
496 ++ lib.optional (isElfhackPlatform stdenv) (enableFeature elfhackSupport "elf-hack")
497 ++ lib.optional (!drmSupport) "--disable-eme"
498 ++ lib.optional allowAddonSideload "--allow-addon-sideload"
499 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
500 # MacOS builds use bundled versions of libraries: https://bugzilla.mozilla.org/show_bug.cgi?id=1776255
501 "--enable-system-pixman"
502 "--with-system-ffi"
503 # Mozilla vendors 10+ patches and ICU upstream is very slow to adopt them
504 # "--with-system-icu"
505 "--with-system-jpeg"
506 "--with-system-libevent"
507 "--with-system-libvpx"
508 "--with-system-nspr"
509 "--with-system-nss"
510 "--with-system-png" # needs APNG support
511 "--with-system-webp"
512 "--with-system-zlib"
513
514 # These options are not available on MacOS, even --disable-*
515 (enableFeature alsaSupport "alsa")
516 (enableFeature jackSupport "jack")
517 (enableFeature pulseaudioSupport "pulseaudio")
518 (enableFeature sndioSupport "sndio")
519 ]
520 ++ lib.optionals (!buildStdenv.hostPlatform.isDarwin && lib.versionAtLeast version "141") [
521 "--with-onnx-runtime=${lib.getLib onnxruntime}/lib"
522 ]
523 ++ [
524 (enableFeature crashreporterSupport "crashreporter")
525 (enableFeature ffmpegSupport "ffmpeg")
526 (enableFeature geolocationSupport "necko-wifi")
527 (enableFeature gssSupport "negotiateauth")
528 (enableFeature jemallocSupport "jemalloc")
529 (enableFeature webrtcSupport "webrtc")
530
531 (enableFeature debugBuild "debug")
532 (if debugBuild then "--enable-profiling" else "--enable-optimize")
533 # --enable-release adds -ffunction-sections & LTO that require a big amount
534 # of RAM, and the 32-bit memory space cannot handle that linking
535 (enableFeature (!debugBuild && !stdenv.hostPlatform.is32bit) "release")
536 (enableFeature enableDebugSymbols "debug-symbols")
537 ]
538 ++ lib.optionals enableDebugSymbols [
539 "--disable-strip"
540 "--disable-install-strip"
541 ]
542 # As of Firefox 137 (https://bugzilla.mozilla.org/show_bug.cgi?id=1943009),
543 # the --enable-official-branding flag overrides the --with-branding flag.
544 ++ lib.optional (enableOfficialBranding && branding == null) "--enable-official-branding"
545 ++ lib.optional (branding != null) "--with-branding=${branding}"
546 ++ extraConfigureFlags;
547
548 buildInputs = [
549 bzip2
550 file
551 libGL
552 libGLU
553 libstartup_notification
554 perl
555 zip
556 ]
557 ++ lib.optionals stdenv.hostPlatform.isDarwin [
558 (
559 if lib.versionAtLeast version "145" then
560 apple-sdk_26
561 else if lib.versionAtLeast version "138" then
562 apple-sdk_15
563 else
564 apple-sdk_14
565 )
566 cups
567 ]
568 ++ (lib.optionals (!stdenv.hostPlatform.isDarwin) (
569 [
570 dbus
571 dbus-glib
572 fontconfig
573 freetype
574 glib
575 gtk3
576 libffi
577 libevent
578 libjpeg
579 libpng
580 libvpx
581 libwebp
582 nspr
583 pango
584 libx11
585 libxcursor
586 libxdamage
587 libxext
588 libxft
589 libxi
590 libxrender
591 libxt
592 libxtst
593 pixman
594 xorgproto
595 zlib
596 (if (lib.versionAtLeast version "144") then nss_latest else nss_esr)
597 ]
598 ++ lib.optional alsaSupport alsa-lib
599 ++ lib.optional jackSupport libjack2
600 ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
601 ++ lib.optional sndioSupport sndio
602 ++ lib.optionals waylandSupport [
603 libxkbcommon
604 libdrm
605 ]
606 ))
607 ++ lib.optional gssSupport libkrb5
608 ++ lib.optional jemallocSupport jemalloc
609 ++ extraBuildInputs;
610
611 profilingPhase = lib.optionalString pgoSupport ''
612 # Avoid compressing the instrumented build with high levels of compression
613 export MOZ_PKG_FORMAT=tar
614
615 # Package up Firefox for profiling
616 ./mach package
617
618 # Run profiling
619 (
620 export HOME=$TMPDIR
621 export LLVM_PROFDATA=llvm-profdata
622 export JARLOG_FILE="$TMPDIR/jarlog"
623
624 xvfb-run -w 10 -s "-screen 0 1920x1080x24" \
625 ./mach python ./build/pgo/profileserver.py
626 )
627
628 # Copy profiling data to a place we can easily reference
629 cp ./merged.profdata $TMPDIR/merged.profdata
630
631 # Clean build dir
632 ./mach clobber
633 '';
634
635 preBuild = ''
636 cd objdir
637 '';
638
639 postBuild = ''
640 cd ..
641 '';
642
643 makeFlags = extraMakeFlags;
644 separateDebugInfo = enableDebugSymbols;
645 enableParallelBuilding = true;
646 env = lib.optionalAttrs stdenv.hostPlatform.isMusl {
647 # Firefox relies on nonstandard behavior of the glibc dynamic linker. It re-uses
648 # previously loaded libraries even though they are not in the rpath of the newly loaded binary.
649 # On musl we have to explicitly set the rpath to include these libraries.
650 LDFLAGS = "-Wl,-rpath,${placeholder "out"}/lib/${binaryName}";
651 };
652
653 # tests were disabled in configureFlags
654 doCheck = false;
655
656 # Generate build symbols once after the final build
657 # https://firefox-source-docs.mozilla.org/crash-reporting/uploading_symbol.html
658 preInstall =
659 lib.optionalString crashreporterSupport ''
660 ./mach buildsymbols
661 mkdir -p $symbols/
662 cp objdir/dist/*.crashreporter-symbols.zip $symbols/
663 ''
664 + ''
665 cd objdir
666 '';
667
668 # The target will prepare .app bundle
669 installTargets = lib.optionalString stdenv.hostPlatform.isDarwin "stage-package";
670
671 postInstall =
672 lib.optionalString stdenv.hostPlatform.isDarwin ''
673 mkdir -p $out/Applications
674 cp -r dist/${binaryName}/*.app "$out/Applications/${applicationName}.app"
675
676 resourceDir="$out/Applications/${applicationName}.app/Contents/Resources"
677
678 ''
679 + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
680 # Remove SDK cruft. FIXME: move to a separate output?
681 rm -rf $out/share/idl $out/include $out/lib/${binaryName}-devel-*
682
683 resourceDir=$out/lib/${binaryName}
684 ''
685 + ''
686 # Install distribution customizations
687 install -Dvm644 ${distributionIni} "$resourceDir/distribution/distribution.ini"
688 install -Dvm644 ${defaultPrefsFile} "$resourceDir/browser/defaults/preferences/nixos-default-prefs.js"
689
690 cd ..
691 '';
692
693 postFixup = lib.optionalString (crashreporterSupport && buildStdenv.hostPlatform.isLinux) ''
694 patchelf --add-rpath "${lib.makeLibraryPath [ curl ]}" $out/lib/${binaryName}/crashreporter
695 '';
696
697 # Some basic testing
698 doInstallCheck = true;
699 installCheckPhase =
700 lib.optionalString buildStdenv.hostPlatform.isDarwin ''
701 bindir="$out/Applications/${applicationName}.app/Contents/MacOS"
702 ''
703 + lib.optionalString (!buildStdenv.hostPlatform.isDarwin) ''
704 bindir=$out/bin
705 ''
706 + ''
707 "$bindir/${binaryName}" --version
708 '';
709
710 passthru = {
711 inherit applicationName;
712 inherit application extraPatches;
713 inherit updateScript;
714 inherit alsaSupport;
715 inherit binaryName;
716 inherit requireSigning allowAddonSideload;
717 inherit jackSupport;
718 inherit pipewireSupport;
719 inherit sndioSupport;
720 inherit nspr;
721 inherit ffmpegSupport;
722 inherit gssSupport;
723 inherit tests;
724 inherit gtk3;
725 inherit wasiSysRoot;
726 version = packageVersion;
727 }
728 // extraPassthru;
729
730 hardeningDisable = [ "format" ]; # -Werror=format-security
731
732 # the build system verifies checksums of the bundled rust sources
733 # ./third_party/rust is be patched by our libtool fixup code in stdenv
734 # unfortunately we can't just set this to `false` when we do not want it.
735 # See https://github.com/NixOS/nixpkgs/issues/77289 for more details
736 # Ideally we would figure out how to tell the build system to not
737 # care about changed hashes as we are already doing that when we
738 # fetch the sources. Any further modifications of the source tree
739 # is on purpose by some of our tool (or by accident and a bug?).
740 dontFixLibtool = true;
741
742 # on aarch64 this is also required
743 dontUpdateAutotoolsGnuConfigScripts = true;
744
745 requiredSystemFeatures = [ "big-parallel" ];
746}