From 350f1345a7ae141afdd4bb1eddc2baf67313ef5f Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 03:38:13 +0100 Subject: [PATCH 01/12] firefox: unpin autoconf & icu, drop yasm Let's not be the package that is stuck on arbitrarily old dependency versions that should be removed anyway. --- .../networking/browsers/firefox/common.nix | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 019c623e100a..779cfb92d88b 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -7,11 +7,11 @@ { lib, stdenv, pkg-config, pango, perl, python3, zip , libjpeg, zlib, dbus, dbus-glib, bzip2, xorg , freetype, fontconfig, file, nspr, nss -, yasm, libGLU, libGL, sqlite, unzip, makeWrapper +, libGLU, libGL, sqlite, unzip, makeWrapper , hunspell, libevent, libstartup_notification , libvpx -, icu70, libpng, glib, pciutils -, autoconf213, which, gnused, rustPackages, rustPlatform +, icu, libpng, glib, pciutils +, autoconf, which, gnused, rustPackages, rustPlatform , rust-cbindgen, nodejs, nasm, fetchpatch , gnum4 , gtk3, wrapGAppsHook @@ -157,18 +157,14 @@ buildStdenv.mkDerivation ({ gnum4 gtk3 perl zip libjpeg zlib bzip2 dbus dbus-glib pango freetype fontconfig xorg.libXi xorg.libXcursor xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file - xorg.pixman yasm libGLU libGL + xorg.pixman libGLU libGL xorg.xorgproto xorg.libXdamage xorg.libXext xorg.libXtst - libevent libstartup_notification /* cairo */ + libevent libstartup_notification libpng glib - nasm icu70 libvpx - # >= 66 requires nasm for the AV1 lib dav1d - # yasm can potentially be removed in future versions - # https://bugzilla.mozilla.org/show_bug.cgi?id=1501796 - # https://groups.google.com/forum/#!msg/mozilla.dev.platform/o-8levmLU80/SM_zQvfzCQAJ + nasm icu libvpx nspr nss ] ++ lib.optional alsaSupport alsa-lib @@ -193,7 +189,7 @@ buildStdenv.mkDerivation ({ nativeBuildInputs = [ - autoconf213 + autoconf cargo gnused llvmPackages.llvm # llvm-objdump @@ -220,7 +216,7 @@ buildStdenv.mkDerivation ({ rm -f configure rm -f js/src/configure rm -f .mozconfig* - # this will run autoconf213 + # this will run autoconf configureScript="$(realpath ./mach) configure" export MOZBUILD_STATE_PATH=$(pwd)/mozbuild From 2f31fe95fdb2387b6d187272c300284d9232cfa0 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 03:44:02 +0100 Subject: [PATCH 02/12] firefox: rename patches arg to extraPatches This is for consistency with other extra arguments that can be handed to firefox common.nix. Also pull the patch phase of the derivation closer together and use the same list concat style as elsewhere. --- .../networking/browsers/firefox/common.nix | 38 +++++++++++-------- .../browsers/firefox/librewolf/default.nix | 4 +- .../mailreaders/thunderbird/packages.nix | 2 +- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 779cfb92d88b..14a5ba2e05a6 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -1,8 +1,15 @@ { pname, version, meta, updateScript ? null , binaryName ? "firefox", application ? "browser" -, src, unpackPhase ? null, patches ? [] -, extraNativeBuildInputs ? [], extraConfigureFlags ? [], extraMakeFlags ? [], tests ? [] -, extraPostPatch ? "", extraPassthru ? {} }: +, src, unpackPhase ? null +, extraPatches ? [] +, extraPostPatch ? "" +, extraNativeBuildInputs ? [] +, extraConfigureFlags ? [] +, extraMakeFlags ? [] +, extraPassthru ? {} +, tests ? [] +}: + { lib, stdenv, pkg-config, pango, perl, python3, zip , libjpeg, zlib, dbus, dbus-glib, bzip2, xorg @@ -141,12 +148,19 @@ buildStdenv.mkDerivation ({ inherit src unpackPhase meta; patches = [ - ] ++ - lib.optional (lib.versionAtLeast version "86") ./env_var_for_system_dir-ff86.patch ++ - lib.optional (lib.versionAtLeast version "90" && lib.versionOlder version "95") ./no-buildconfig-ffx90.patch ++ - lib.optional (lib.versionAtLeast version "96") ./no-buildconfig-ffx96.patch ++ + ] + ++ lib.optional (lib.versionAtLeast version "86") ./env_var_for_system_dir-ff86.patch + ++ lib.optional (lib.versionAtLeast version "90" && lib.versionOlder version "95") ./no-buildconfig-ffx90.patch + ++ lib.optional (lib.versionAtLeast version "96") ./no-buildconfig-ffx96.patch + ++ extraPatches; - patches; + postPatch = '' + rm -rf obj-x86_64-pc-linux-gnu + substituteInPlace toolkit/xre/glxtest.cpp \ + --replace 'dlopen("libpci.so' 'dlopen("${pciutils}/lib/libpci.so' + + patchShebangs mach + '' + extraPostPatch; # Ignore trivial whitespace changes in patches, this fixes compatibility of # ./env_var_for_system_dir.patch with Firefox >=65 without having to track @@ -179,14 +193,6 @@ buildStdenv.mkDerivation ({ MACH_USE_SYSTEM_PYTHON = "1"; - postPatch = '' - rm -rf obj-x86_64-pc-linux-gnu - substituteInPlace toolkit/xre/glxtest.cpp \ - --replace 'dlopen("libpci.so' 'dlopen("${pciutils}/lib/libpci.so' - - patchShebangs mach - '' + extraPostPatch; - nativeBuildInputs = [ autoconf diff --git a/pkgs/applications/networking/browsers/firefox/librewolf/default.nix b/pkgs/applications/networking/browsers/firefox/librewolf/default.nix index 4d8fe708e75a..10b65e8825c2 100644 --- a/pkgs/applications/networking/browsers/firefox/librewolf/default.nix +++ b/pkgs/applications/networking/browsers/firefox/librewolf/default.nix @@ -6,7 +6,7 @@ rec { inherit (src) packageVersion firefox source; - patches = [ ./verify-telemetry-macros.patch ]; + extraPatches = [ ./verify-telemetry-macros.patch ]; extraConfigureFlags = [ "--with-app-name=librewolf" @@ -34,7 +34,7 @@ rec { extraPoliciesFiles = [ "${source}/submodules/settings/distribution/policies.json" ]; extraPassthru = { - librewolf = { inherit src patches; }; + librewolf = { inherit src extraPatches; }; inherit extraPrefsFiles extraPoliciesFiles; }; } diff --git a/pkgs/applications/networking/mailreaders/thunderbird/packages.nix b/pkgs/applications/networking/mailreaders/thunderbird/packages.nix index 3ab0c58ecc5e..d559976d8003 100644 --- a/pkgs/applications/networking/mailreaders/thunderbird/packages.nix +++ b/pkgs/applications/networking/mailreaders/thunderbird/packages.nix @@ -17,7 +17,7 @@ rec { url = "mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz"; sha512 = "2afaee16f155edcb0bdb46ebe282a733cf041ec6f562aebd06f8b675e46917f6f500fcc532fc54d74f3f4b0b489a88934a2c6c304f849873de4bc2690b9056a0"; }; - patches = [ + extraPatches = [ # The file to be patched is different from firefox's `no-buildconfig-ffx90.patch`. ./no-buildconfig.patch ]; From cfcc611cb493641d52c39647a3068f4337e238dd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 03:45:46 +0100 Subject: [PATCH 03/12] firefox: use our own libwebp --- pkgs/applications/networking/browsers/firefox/common.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 14a5ba2e05a6..4a3172b6f594 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -17,6 +17,7 @@ , libGLU, libGL, sqlite, unzip, makeWrapper , hunspell, libevent, libstartup_notification , libvpx +, libwebp , icu, libpng, glib, pciutils , autoconf, which, gnused, rustPackages, rustPlatform , rust-cbindgen, nodejs, nasm, fetchpatch @@ -179,6 +180,7 @@ buildStdenv.mkDerivation ({ libevent libstartup_notification libpng glib nasm icu libvpx + libwebp nspr nss ] ++ lib.optional alsaSupport alsa-lib @@ -267,6 +269,7 @@ buildStdenv.mkDerivation ({ "--with-libclang-path=${llvmPackages.libclang.lib}/lib" "--with-system-nspr" "--with-system-nss" + "--with-system-webp" ] ++ lib.optional (buildStdenv.isDarwin) "--disable-xcode-checks" ++ lib.optional (!ltoSupport) "--with-clang-path=${llvmPackages.clang}/bin/clang" From e921e84e9d8447ce5fa814a265edf91876b09630 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 03:49:44 +0100 Subject: [PATCH 04/12] firefox: don't set BUILD_OFFICIAL It was removed in 2009 in favor of MOZILLA_OFFICIAL mozbz#435923 --- pkgs/applications/networking/browsers/firefox/common.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 4a3172b6f594..1147e22241e5 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -248,7 +248,6 @@ buildStdenv.mkDerivation ({ unset AS '' + (lib.optionalString enableOfficialBranding '' export MOZILLA_OFFICIAL=1 - export BUILD_OFFICIAL=1 ''); configureFlags = [ From 25e22d96bad5333a023088c4377bcbf444f47dd6 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 05:20:01 +0100 Subject: [PATCH 05/12] firefox: enable necko wifi scanner Tied to the geolocation support flag. On Linux this uses the DBus interface of NetworkManager to query visible accesspoints and relay them to Mozilla location service in return for position approximation. --- pkgs/applications/networking/browsers/firefox/common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 1147e22241e5..75646389badf 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -262,7 +262,6 @@ buildStdenv.mkDerivation ({ "--enable-system-pixman" #"--enable-system-cairo" "--disable-tests" - "--disable-necko-wifi" # maybe we want to enable this at some point "--disable-updater" "--enable-default-toolkit=${default-toolkit}" "--with-libclang-path=${llvmPackages.libclang.lib}/lib" @@ -286,6 +285,7 @@ buildStdenv.mkDerivation ({ ++ flag pulseaudioSupport "pulseaudio" ++ flag ffmpegSupport "ffmpeg" ++ flag jemallocSupport "jemalloc" + ++ flag geolocationSupport "necko-wifi" ++ flag gssSupport "negotiateauth" ++ flag webrtcSupport "webrtc" ++ flag crashreporterSupport "crashreporter" From 48eabf68385bc0619c2621fc604fc89221f957dd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 05:27:19 +0100 Subject: [PATCH 06/12] firefox: drop hint regarding system cairo Building with system cairo has been unsupported since Firefox 60 (mozbz#1432751) and the flag was removed in 2021 with Firefox 92 (mozbz#1722653). --- pkgs/applications/networking/browsers/firefox/common.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 75646389badf..c49d2f2a3177 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -260,7 +260,6 @@ buildStdenv.mkDerivation ({ "--with-system-icu" "--enable-system-ffi" "--enable-system-pixman" - #"--enable-system-cairo" "--disable-tests" "--disable-updater" "--enable-default-toolkit=${default-toolkit}" From 71d879b16b5c7b21a1233896eab7ecb9fef5eefc Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 14:28:16 +0100 Subject: [PATCH 07/12] firefox: drop pipewire from build inputs Firefox does not support passing pipewire as a system library and instead relies on a vendored copy it ships. We keep the flag because it is tied into the wrapper, because we still need to have access to its libraries at runtime. --- pkgs/applications/networking/browsers/firefox/common.nix | 3 +-- pkgs/applications/networking/browsers/firefox/wrapper.nix | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index c49d2f2a3177..0500f6e8d4b9 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -37,7 +37,7 @@ , waylandSupport ? true, libxkbcommon, libdrm , ltoSupport ? (stdenv.isLinux && stdenv.is64bit), overrideCC, buildPackages , gssSupport ? true, libkrb5 -, pipewireSupport ? waylandSupport && webrtcSupport, pipewire +, pipewireSupport ? waylandSupport && webrtcSupport # Jemalloc could reduce memory consumption. , jemallocSupport ? true, jemalloc @@ -187,7 +187,6 @@ buildStdenv.mkDerivation ({ ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed ++ lib.optional gssSupport libkrb5 ++ lib.optionals waylandSupport [ libxkbcommon libdrm ] - ++ lib.optional pipewireSupport pipewire ++ lib.optional jemallocSupport jemalloc ++ lib.optionals buildStdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos AVFoundation MediaToolbox CoreLocation diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 4713320e0685..7cc570eb0fb6 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -67,7 +67,7 @@ let ++ extraNativeMessagingHosts ); libs = lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups ] - ++ lib.optional (pipewireSupport && lib.versionAtLeast version "83") pipewire + ++ lib.optional pipewireSupport pipewire ++ lib.optional ffmpegSupport ffmpeg ++ lib.optional gssSupport libkrb5 ++ lib.optional useGlvnd libglvnd From 08ea534e674a0e29f96647e7759fae6dc9a668c2 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 16:03:59 +0100 Subject: [PATCH 08/12] firefox: drop darwin support Darwin support was marked broken in 2019 with Firefox 69 and has missed therefore missed out and not been tested on the following 29 major releases since. It cannot be supported again without a darwin user stepping up to take care and work on and test every major release, which hasn't happened since I took over maintainership. The recommendation of the people that tend to the firefox source build is for darwin users to use firefox-bin instead. --- .../browsers/firefox-bin/default.nix | 2 +- .../networking/browsers/firefox/common.nix | 49 +++---------------- .../networking/browsers/firefox/wrapper.nix | 26 +++++----- pkgs/top-level/all-packages.nix | 8 --- 4 files changed, 18 insertions(+), 67 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox-bin/default.nix b/pkgs/applications/networking/browsers/firefox-bin/default.nix index 50cc57182903..a71cb84a05c3 100644 --- a/pkgs/applications/networking/browsers/firefox-bin/default.nix +++ b/pkgs/applications/networking/browsers/firefox-bin/default.nix @@ -188,7 +188,7 @@ stdenv.mkDerivation { ln -s ${policiesJson} "$out/lib/firefox-bin-${version}/distribution/policies.json"; ''; - passthru.applicationName = "firefox"; + passthru.binaryName = "firefox"; passthru.libName = "firefox-bin-${version}"; passthru.execdir = "/bin"; passthru.ffmpegSupport = true; diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 0500f6e8d4b9..6b853d44a918 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -58,10 +58,6 @@ , safeBrowsingSupport ? false , drmSupport ? false -# macOS dependencies -, xcbuild, CoreMedia, ExceptionHandling, Kerberos, AVFoundation, MediaToolbox -, CoreLocation, Foundation, AddressBook, libobjc, cups, rsync - ## other # As stated by Sylvestre Ledru (@sylvestre) on Nov 22, 2017 at @@ -90,31 +86,14 @@ assert stdenv.cc.libc or null != null; assert pipewireSupport -> !waylandSupport || !webrtcSupport -> throw "pipewireSupport requires both wayland and webrtc support."; -assert ltoSupport -> stdenv.isDarwin -> throw "LTO is broken on Darwin (see PR#19312)."; let flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")]; - default-toolkit = if stdenv.isDarwin then "cairo-cocoa" - else "cairo-gtk3${lib.optionalString waylandSupport "-wayland"}"; - - binaryNameCapitalized = lib.toUpper (lib.substring 0 1 binaryName) + lib.substring 1 (-1) binaryName; - - applicationName = if stdenv.isDarwin then binaryNameCapitalized else binaryName; - - execdir = if stdenv.isDarwin - then "/Applications/${binaryNameCapitalized}.app/Contents/MacOS" - else "/bin"; - inherit (rustPackages) rustc cargo; - # Darwin's stdenv provides the default llvmPackages version, match that since - # clang LTO on Darwin is broken so the stdenv is not being changed. # Target the LLVM version that rustc -Vv reports it is built with for LTO. - llvmPackages0 = - if stdenv.isDarwin - then buildPackages.llvmPackages - else rustc.llvmPackages; + llvmPackages0 = rustc.llvmPackages; # Force the use of lld and other llvm tools for LTO llvmPackages = llvmPackages0.override { @@ -122,8 +101,6 @@ let bootBintools = null; }; - # When LTO for Darwin is fixed, the following will need updating as lld - # doesn't work on it. For now it is fine since ltoSupport implies no Darwin. buildStdenv = if ltoSupport # LTO requires LLVM bintools including ld.lld and llvm-ar. then overrideCC llvmPackages.stdenv (llvmPackages.stdenv.cc.override { @@ -187,10 +164,7 @@ buildStdenv.mkDerivation ({ ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed ++ lib.optional gssSupport libkrb5 ++ lib.optionals waylandSupport [ libxkbcommon libdrm ] - ++ lib.optional jemallocSupport jemalloc - ++ lib.optionals buildStdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos - AVFoundation MediaToolbox CoreLocation - Foundation libobjc AddressBook cups ]; + ++ lib.optional jemallocSupport jemalloc; MACH_USE_SYSTEM_PYTHON = "1"; @@ -212,7 +186,6 @@ buildStdenv.mkDerivation ({ wrapGAppsHook rustPlatform.bindgenHook ] - ++ lib.optionals buildStdenv.isDarwin [ xcbuild rsync ] ++ extraNativeBuildInputs; separateDebugInfo = enableDebugSymbols; @@ -261,22 +234,18 @@ buildStdenv.mkDerivation ({ "--enable-system-pixman" "--disable-tests" "--disable-updater" - "--enable-default-toolkit=${default-toolkit}" + "--enable-default-toolkit=cairo-gtk3${lib.optionalString waylandSupport "-wayland"}" "--with-libclang-path=${llvmPackages.libclang.lib}/lib" "--with-system-nspr" "--with-system-nss" "--with-system-webp" ] - ++ lib.optional (buildStdenv.isDarwin) "--disable-xcode-checks" ++ lib.optional (!ltoSupport) "--with-clang-path=${llvmPackages.clang}/bin/clang" # LTO is done using clang and lld on Linux. - # Darwin needs to use the default linker as lld is not supported (yet?): - # https://bugzilla.mozilla.org/show_bug.cgi?id=1538724 # elf-hack is broken when using clang+lld: # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204 - ++ lib.optional ltoSupport "--enable-lto=cross" # Cross-language LTO. + ++ lib.optionals ltoSupport [ "--enable-lto=cross" "--enable-linker=lld" ] ++ lib.optional (ltoSupport && (buildStdenv.isAarch32 || buildStdenv.isi686 || buildStdenv.isx86_64)) "--disable-elf-hack" - ++ lib.optional (ltoSupport && !buildStdenv.isDarwin) "--enable-linker=lld" ++ lib.optional (lib.versionAtLeast version "95") "--with-wasi-sysroot=${wasiSysRoot}" ++ flag alsaSupport "alsa" @@ -309,11 +278,6 @@ buildStdenv.mkDerivation ({ enableParallelBuilding = true; doCheck = false; # "--disable-tests" above - installPhase = if buildStdenv.isDarwin then '' - mkdir -p $out/Applications - cp -LR dist/${binaryNameCapitalized}.app $out/Applications - '' else null; - postInstall = lib.optionalString buildStdenv.isLinux '' # Remove SDK cruft. FIXME: move to a separate output? rm -rf $out/share/idl $out/include $out/lib/${binaryName}-devel-* @@ -361,19 +325,18 @@ buildStdenv.mkDerivation ({ doInstallCheck = true; installCheckPhase = '' # Some basic testing - "$out${execdir}/${applicationName}" --version + "$out/bin/${binaryName}" --version ''; passthru = { inherit updateScript; inherit version; inherit alsaSupport; + inherit binaryName; inherit pipewireSupport; inherit nspr; inherit ffmpegSupport; inherit gssSupport; - inherit execdir; - inherit applicationName; inherit tests; inherit gtk3; inherit wasiSysRoot; diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 7cc570eb0fb6..e87eb4b94df6 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -20,7 +20,7 @@ browser: let wrapper = - { applicationName ? browser.applicationName or (lib.getName browser) + { applicationName ? browser.binaryName or (lib.getName browser) , pname ? applicationName , version ? lib.getVersion browser , desktopName ? # applicationName with first letter capitalized @@ -179,14 +179,10 @@ let buildInputs = [ browser.gtk3 ]; - buildCommand = lib.optionalString stdenv.isDarwin '' - mkdir -p $out/Applications - cp -R --no-preserve=mode,ownership ${browser}/Applications/${applicationName}.app $out/Applications - rm -f $out${browser.execdir or "/bin"}/${applicationName} - '' + '' - if [ ! -x "${browser}${browser.execdir or "/bin"}/${applicationName}" ] + buildCommand = '' + if [ ! -x "${browser}/bin/${applicationName}" ] then - echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${applicationName}'" + echo "cannot find executable file \`${browser}/bin/${applicationName}'" exit 1 fi @@ -223,12 +219,12 @@ let # create the wrapper - executablePrefix="$out${browser.execdir or "/bin"}" + executablePrefix="$out/bin" executablePath="$executablePrefix/${applicationName}" if [ ! -x "$executablePath" ] then - echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${applicationName}'" + echo "cannot find executable file \`${browser}/bin/${applicationName}'" exit 1 fi @@ -243,18 +239,18 @@ let oldExe="$(readlink -v --canonicalize-existing "$executablePath")" fi - if [ ! -x "${browser}${browser.execdir or "/bin"}/${applicationName}" ] + if [ ! -x "${browser}/bin/${applicationName}" ] then - echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${applicationName}'" + echo "cannot find executable file \`${browser}/bin/${applicationName}'" exit 1 fi makeWrapper "$oldExe" \ - "$out${browser.execdir or "/bin"}/${applicationName}${nameSuffix}" \ + "$out/bin/${applicationName}${nameSuffix}" \ --prefix LD_LIBRARY_PATH ':' "$libs" \ --suffix-each GTK_PATH ':' "$gtk_modules" \ --prefix PATH ':' "${xdg-utils}/bin" \ - --suffix PATH ':' "$out${browser.execdir or "/bin"}" \ + --suffix PATH ':' "$out/bin" \ --set MOZ_APP_LAUNCHER "${applicationName}${nameSuffix}" \ --set MOZ_SYSTEM_DIR "$out/lib/mozilla" \ --set MOZ_LEGACY_PROFILES 1 \ @@ -278,7 +274,7 @@ let mkdir -p "$out/share/icons/hicolor/''${res}x''${res}/apps" icon=$( find "${browser}/lib/" -name "default''${res}.png" ) if [ -e "$icon" ]; then ln -s "$icon" \ - "$out/share/icons/hicolor/''${res}x''${res}/apps/${applicationName}.png" + "$out/share/icons/hicolor/''${res}x''${res}/apps/${icon}.png" fi done fi diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a5ee3327e03c..7b5d1181d950 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25972,10 +25972,6 @@ with pkgs; callPackage = newScope { inherit (rustPackages) cargo rustc; gnused = gnused_422; - inherit (darwin.apple_sdk.frameworks) CoreMedia ExceptionHandling - Kerberos AVFoundation MediaToolbox - CoreLocation Foundation AddressBook; - inherit (darwin) libobjc; }; }); @@ -29461,10 +29457,6 @@ with pkgs; callPackage = newScope { inherit (rustPackages) cargo rustc; gnused = gnused_422; - inherit (darwin.apple_sdk.frameworks) CoreMedia ExceptionHandling - Kerberos AVFoundation MediaToolbox - CoreLocation Foundation AddressBook; - inherit (darwin) libobjc; }; }); From 51e5f33899ce9d404051fd6404b0f28e5291d2cf Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 18:16:55 +0100 Subject: [PATCH 09/12] firefox: fix system libffi usage Since Firefox 51 the --enable-system-ffi flag was renamed to --with-systemd-ffi when it moved to the javascript toolkit parts. Rename the flag accordingly and reintroduce the dependency. mozbz#1294803 --- pkgs/applications/networking/browsers/firefox/common.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 6b853d44a918..f8a2215ebe78 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -16,6 +16,7 @@ , freetype, fontconfig, file, nspr, nss , libGLU, libGL, sqlite, unzip, makeWrapper , hunspell, libevent, libstartup_notification +, libffi , libvpx , libwebp , icu, libpng, glib, pciutils @@ -157,6 +158,7 @@ buildStdenv.mkDerivation ({ libevent libstartup_notification libpng glib nasm icu libvpx + libffi libwebp nspr nss ] @@ -224,13 +226,13 @@ buildStdenv.mkDerivation ({ configureFlags = [ "--enable-application=${application}" + "--with-system-ffi" "--with-system-jpeg" "--with-system-zlib" "--with-system-libevent" "--with-system-libvpx" "--with-system-png" # needs APNG support "--with-system-icu" - "--enable-system-ffi" "--enable-system-pixman" "--disable-tests" "--disable-updater" From 178d447610648c0efcd9b547b7d41c2ecdf3357c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 21:58:03 +0100 Subject: [PATCH 10/12] firefox: pass pciutils via wrapper instead of patching it --- pkgs/applications/networking/browsers/firefox/common.nix | 5 +---- pkgs/applications/networking/browsers/firefox/wrapper.nix | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index f8a2215ebe78..be5eb550a94c 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -19,7 +19,7 @@ , libffi , libvpx , libwebp -, icu, libpng, glib, pciutils +, icu, libpng, glib , autoconf, which, gnused, rustPackages, rustPlatform , rust-cbindgen, nodejs, nasm, fetchpatch , gnum4 @@ -135,9 +135,6 @@ buildStdenv.mkDerivation ({ postPatch = '' rm -rf obj-x86_64-pc-linux-gnu - substituteInPlace toolkit/xre/glxtest.cpp \ - --replace 'dlopen("libpci.so' 'dlopen("${pciutils}/lib/libpci.so' - patchShebangs mach '' + extraPostPatch; diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index e87eb4b94df6..d5055f04ed82 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -12,6 +12,7 @@ , libva , mesa # firefox wants gbm for drm+dmabuf , cups +, pciutils }: ## configurability of the wrapper itself @@ -66,7 +67,7 @@ let ++ lib.optional (cfg.enableFXCastBridge or false) fx_cast_bridge ++ extraNativeMessagingHosts ); - libs = lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups ] + libs = lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups pciutils ] ++ lib.optional pipewireSupport pipewire ++ lib.optional ffmpegSupport ffmpeg ++ lib.optional gssSupport libkrb5 From b3529accfb22342799ceb02abe1e8256eb169aff Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 21 Mar 2022 20:09:59 +0100 Subject: [PATCH 11/12] firefox: reformat, sort, cleanup It is normal for such a large derivation to accumulate mixed codestyles over all those years making it harder to maintain. By splitting up dependencies to one per line I noticed two unused dependencies (hunspell, sqlite) that were removed in this change. Also most lists are now sorted alphabetically, so reasoning about them has become much easier. Lists now use the same style for indentation and concat, and environment variables are all defined in preConfigure as opposed to bare in the derivation. The object dir, firefox build directory, is now in a predictable directory at ${pwd}/mozobj as opposed to ${pwd}/obj-@CONFIG_GUESS@, saving us one wildcard expansion. This is also a good prepration for the PGO build where we need to reference bits inside this directory. Added a few comments and clarified others from what I've learned how the firefox build works. --- .../networking/browsers/firefox/common.nix | 292 +++++++++++------- pkgs/top-level/all-packages.nix | 1 - 2 files changed, 181 insertions(+), 112 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index be5eb550a94c..64cba1b52a60 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -1,46 +1,91 @@ -{ pname, version, meta, updateScript ? null -, binaryName ? "firefox", application ? "browser" -, src, unpackPhase ? null +{ pname +, version +, meta +, updateScript ? null +, binaryName ? "firefox" +, application ? "browser" +, src +, unpackPhase ? null , extraPatches ? [] , extraPostPatch ? "" , extraNativeBuildInputs ? [] , extraConfigureFlags ? [] +, extraBuildInputs ? [] , extraMakeFlags ? [] , extraPassthru ? {} , tests ? [] }: -{ lib, stdenv, pkg-config, pango, perl, python3, zip -, libjpeg, zlib, dbus, dbus-glib, bzip2, xorg -, freetype, fontconfig, file, nspr, nss -, libGLU, libGL, sqlite, unzip, makeWrapper -, hunspell, libevent, libstartup_notification +{ lib +, stdenv +, fetchpatch + +# build time +, autoconf +, cargo +, gnused +, makeWrapper +, nodejs +, perl +, pkg-config +, pkgsCross # wasm32 rlbox +, python3 +, runCommand +, rustc +, rust-cbindgen +, rustPlatform +, unzip +, which +, wrapGAppsHook + +# runtime +, bzip2 +, dbus +, dbus-glib +, file +, fontconfig +, freetype +, glib +, gnum4 +, gtk3 +, icu +, libGL +, libGLU +, libevent , libffi +, libjpeg +, libpng +, libstartup_notification , libvpx , libwebp -, icu, libpng, glib -, autoconf, which, gnused, rustPackages, rustPlatform -, rust-cbindgen, nodejs, nasm, fetchpatch -, gnum4 -, gtk3, wrapGAppsHook -, pkgsCross -, debugBuild ? false -, runCommand +, nasm +, nspr +, nss +, pango +, xorg +, zip +, zlib -### optionals +# optionals + +## debugging + +, debugBuild ? false + +# On 32bit platforms, we disable adding "-g" for easier linking. +, enableDebugSymbols ? !stdenv.is32bit ## optional libraries , alsaSupport ? stdenv.isLinux, alsa-lib -, pulseaudioSupport ? stdenv.isLinux, libpulseaudio , ffmpegSupport ? true -, waylandSupport ? true, libxkbcommon, libdrm -, ltoSupport ? (stdenv.isLinux && stdenv.is64bit), overrideCC, buildPackages , gssSupport ? true, libkrb5 -, pipewireSupport ? waylandSupport && webrtcSupport -# Jemalloc could reduce memory consumption. , jemallocSupport ? true, jemalloc +, ltoSupport ? (stdenv.isLinux && stdenv.is64bit), overrideCC, buildPackages +, pipewireSupport ? waylandSupport && webrtcSupport +, pulseaudioSupport ? stdenv.isLinux, libpulseaudio +, waylandSupport ? true, libxkbcommon, libdrm ## privacy-related options @@ -49,18 +94,16 @@ # WARNING: NEVER set any of the options below to `true` by default. # Set to `!privacySupport` or `false`. -# webrtcSupport breaks the aarch64 build on version >= 60, fixed in 63. -# https://bugzilla.mozilla.org/show_bug.cgi?id=1434589 -, webrtcSupport ? !privacySupport , geolocationSupport ? !privacySupport , googleAPISupport ? geolocationSupport -, crashreporterSupport ? false - -, safeBrowsingSupport ? false -, drmSupport ? false +, webrtcSupport ? !privacySupport ## other +, crashreporterSupport ? false +, drmSupport ? false +, safeBrowsingSupport ? false + # As stated by Sylvestre Ledru (@sylvestre) on Nov 22, 2017 at # https://github.com/NixOS/nixpkgs/issues/31843#issuecomment-346372756 we # have permission to use the official firefox branding. @@ -80,9 +123,6 @@ # > the experience of Firefox users, you won't have any issues using the # > official branding. , enableOfficialBranding ? true - -# On 32bit platforms, we disable adding "-g" for easier linking. -, enableDebugSymbols ? !stdenv.is32bit }: assert stdenv.cc.libc or null != null; @@ -91,9 +131,7 @@ assert pipewireSupport -> !waylandSupport || !webrtcSupport -> throw "pipewireSu let flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")]; - inherit (rustPackages) rustc cargo; - - # Target the LLVM version that rustc -Vv reports it is built with for LTO. + # Target the LLVM version that rustc is built with for LTO. llvmPackages0 = rustc.llvmPackages; # Force the use of lld and other llvm tools for LTO @@ -103,11 +141,11 @@ let }; buildStdenv = if ltoSupport - # LTO requires LLVM bintools including ld.lld and llvm-ar. - then overrideCC llvmPackages.stdenv (llvmPackages.stdenv.cc.override { - inherit (llvmPackages) bintools; - }) - else stdenv; + # LTO requires LLVM bintools including ld.lld and llvm-ar. + then overrideCC llvmPackages.stdenv (llvmPackages.stdenv.cc.override { + inherit (llvmPackages) bintools; + }) + else stdenv; # Compile the wasm32 sysroot to build the RLBox Sandbox # https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/ @@ -136,77 +174,61 @@ buildStdenv.mkDerivation ({ postPatch = '' rm -rf obj-x86_64-pc-linux-gnu patchShebangs mach - '' + extraPostPatch; + '' + + extraPostPatch; # Ignore trivial whitespace changes in patches, this fixes compatibility of # ./env_var_for_system_dir.patch with Firefox >=65 without having to track # two patches. patchFlags = [ "-p1" "-l" ]; - buildInputs = [ - gnum4 gtk3 perl zip libjpeg zlib bzip2 - dbus dbus-glib pango freetype fontconfig xorg.libXi xorg.libXcursor - xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file - xorg.pixman libGLU libGL - xorg.xorgproto - xorg.libXdamage - xorg.libXext - xorg.libXtst - libevent libstartup_notification - libpng glib - nasm icu libvpx - libffi - libwebp - nspr nss + nativeBuildInputs = [ + autoconf + cargo + gnused + llvmPackages.llvm # llvm-objdump + makeWrapper + nodejs + perl + pkg-config + python3 + rust-cbindgen + rustPlatform.bindgenHook + rustc + unzip + which + wrapGAppsHook ] - ++ lib.optional alsaSupport alsa-lib - ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed - ++ lib.optional gssSupport libkrb5 - ++ lib.optionals waylandSupport [ libxkbcommon libdrm ] - ++ lib.optional jemallocSupport jemalloc; + ++ extraNativeBuildInputs; - MACH_USE_SYSTEM_PYTHON = "1"; - - nativeBuildInputs = - [ - autoconf - cargo - gnused - llvmPackages.llvm # llvm-objdump - makeWrapper - nodejs - perl - pkg-config - python3 - rust-cbindgen - rustc - which - unzip - wrapGAppsHook - rustPlatform.bindgenHook - ] - ++ extraNativeBuildInputs; - - separateDebugInfo = enableDebugSymbols; setOutputFlags = false; # `./mach configure` doesn't understand `--*dir=` flags. preConfigure = '' # remove distributed configuration files - rm -f configure - rm -f js/src/configure - rm -f .mozconfig* - # this will run autoconf + rm -f configure js/src/configure .mozconfig* + + # Runs autoconf through ./mach configure in configurePhase configureScript="$(realpath ./mach) configure" + + # Set predictable directories for build and state + export MOZ_OBJDIR=$(pwd)/mozobj export MOZBUILD_STATE_PATH=$(pwd)/mozbuild # Set consistent remoting name to ensure wmclass matches with desktop file export MOZ_APP_REMOTINGNAME="${binaryName}" - '' + (lib.optionalString (lib.versionAtLeast version "95.0") '' + # Use our own python + export MACH_USE_SYSTEM_PYTHON=1 + + # AS=as in the environment causes build failure + # https://bugzilla.mozilla.org/show_bug.cgi?id=1497286 + unset AS + + '' + lib.optionalString (lib.versionAtLeast version "95.0") '' # RBox WASM Sandboxing export WASM_CC=${pkgsCross.wasi32.stdenv.cc}/bin/${pkgsCross.wasi32.stdenv.cc.targetPrefix}cc export WASM_CXX=${pkgsCross.wasi32.stdenv.cc}/bin/${pkgsCross.wasi32.stdenv.cc.targetPrefix}c++ - '') + (lib.optionalString googleAPISupport '' + '' + lib.optionalString googleAPISupport '' # Google API key used by Chromium and Firefox. # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution, # please get your own set of keys. @@ -214,36 +236,36 @@ buildStdenv.mkDerivation ({ # 60.5+ & 66+ did split the google API key arguments: https://bugzilla.mozilla.org/show_bug.cgi?id=1531176 configureFlagsArray+=("--with-google-location-service-api-keyfile=$TMPDIR/ga") configureFlagsArray+=("--with-google-safebrowsing-api-keyfile=$TMPDIR/ga") - '') + '' - # AS=as in the environment causes build failure https://bugzilla.mozilla.org/show_bug.cgi?id=1497286 - unset AS - '' + (lib.optionalString enableOfficialBranding '' + '' + lib.optionalString enableOfficialBranding '' export MOZILLA_OFFICIAL=1 - ''); + ''; configureFlags = [ - "--enable-application=${application}" - "--with-system-ffi" - "--with-system-jpeg" - "--with-system-zlib" - "--with-system-libevent" - "--with-system-libvpx" - "--with-system-png" # needs APNG support - "--with-system-icu" - "--enable-system-pixman" "--disable-tests" "--disable-updater" + "--enable-application=${application}" "--enable-default-toolkit=cairo-gtk3${lib.optionalString waylandSupport "-wayland"}" + "--enable-system-pixman" "--with-libclang-path=${llvmPackages.libclang.lib}/lib" + "--with-system-ffi" + "--with-system-icu" + "--with-system-jpeg" + "--with-system-libevent" + "--with-system-libvpx" "--with-system-nspr" "--with-system-nss" + "--with-system-png" # needs APNG support "--with-system-webp" + "--with-system-zlib" ] ++ lib.optional (!ltoSupport) "--with-clang-path=${llvmPackages.clang}/bin/clang" # LTO is done using clang and lld on Linux. + ++ lib.optionals ltoSupport [ + "--enable-lto=cross" # Cross-Language LTO + "--enable-linker=lld" + ] # elf-hack is broken when using clang+lld: - # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204 - ++ lib.optionals ltoSupport [ "--enable-lto=cross" "--enable-linker=lld" ] + # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204 ++ lib.optional (ltoSupport && (buildStdenv.isAarch32 || buildStdenv.isi686 || buildStdenv.isx86_64)) "--disable-elf-hack" ++ lib.optional (lib.versionAtLeast version "95") "--with-wasi-sysroot=${wasiSysRoot}" @@ -268,14 +290,62 @@ buildStdenv.mkDerivation ({ ++ lib.optional enableOfficialBranding "--enable-official-branding" ++ extraConfigureFlags; - postConfigure = '' - cd obj-* + buildInputs = [ + bzip2 + dbus + dbus-glib + file + fontconfig + freetype + glib + gnum4 + gtk3 + icu + libffi + libGL + libGLU + libevent + libjpeg + libpng + libstartup_notification + libvpx + libwebp + nasm + nspr + nss + pango + perl + xorg.libX11 + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXft + xorg.libXi + xorg.libXrender + xorg.libXt + xorg.libXtst + xorg.pixman + xorg.xorgproto + zip + zlib + ] + ++ lib.optional alsaSupport alsa-lib + ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed + ++ lib.optional gssSupport libkrb5 + ++ lib.optionals waylandSupport [ libxkbcommon libdrm ] + ++ lib.optional jemallocSupport jemalloc + ++ extraBuildInputs; + + preBuild = '' + cd mozobj ''; makeFlags = extraMakeFlags; - + separateDebugInfo = enableDebugSymbols; enableParallelBuilding = true; - doCheck = false; # "--disable-tests" above + + # tests were disabled in configureFlags + doCheck = false; postInstall = lib.optionalString buildStdenv.isLinux '' # Remove SDK cruft. FIXME: move to a separate output? @@ -287,7 +357,7 @@ buildStdenv.mkDerivation ({ # Workaround: The separateDebugInfo hook skips artifacts whose build ID's length is not 40. # But we got 16-length build ID here. The function body is mainly copied from pkgs/build-support/setup-hooks/separate-debug-info.sh - # Remove it when PR #146275 is merged. + # Remove it when https://github.com/NixOS/nixpkgs/pull/146275 is merged. preFixup = lib.optionalString enableDebugSymbols '' _separateDebugInfo() { [ -e "$prefix" ] || return 0 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7b5d1181d950..fff8986f109a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25971,7 +25971,6 @@ with pkgs; firefoxPackages = recurseIntoAttrs (callPackage ../applications/networking/browsers/firefox/packages.nix { callPackage = newScope { inherit (rustPackages) cargo rustc; - gnused = gnused_422; }; }); From df83570b8e034d8f3e71f2ffb18862705caf4980 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 23 Mar 2022 05:14:09 +0100 Subject: [PATCH 12/12] thunderbirdPackages: stop passing in gnused_422 --- pkgs/top-level/all-packages.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fff8986f109a..6f291cdd88f7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -29455,7 +29455,6 @@ with pkgs; thunderbirdPackages = recurseIntoAttrs (callPackage ../applications/networking/mailreaders/thunderbird/packages.nix { callPackage = newScope { inherit (rustPackages) cargo rustc; - gnused = gnused_422; }; });