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