firefox: rename some attributes in packaging

This should not change the derivation, but the new attribute names make
more sense once we package something that is not Firefox using this
expression.
launchpad/nixpkgs/master
Yureka 3 years ago
parent 5e1559de12
commit 711d674e13
  1. 44
      pkgs/applications/networking/browsers/firefox/common.nix
  2. 15
      pkgs/applications/networking/browsers/firefox/packages.nix
  3. 64
      pkgs/applications/networking/browsers/firefox/wrapper.nix
  4. 6
      pkgs/top-level/all-packages.nix

@ -1,4 +1,5 @@
{ pname, ffversion, meta, updateScript ? null
{ pname, version, meta, updateScript ? null
, binaryName ? "firefox", application ? "browser"
, src, unpackPhase ? null, patches ? []
, extraNativeBuildInputs ? [], extraConfigureFlags ? [], extraMakeFlags ? [], tests ? [] }:
@ -81,17 +82,16 @@ let
default-toolkit = if stdenv.isDarwin then "cairo-cocoa"
else "cairo-gtk3${lib.optionalString waylandSupport "-wayland"}";
binaryName = "firefox";
binaryNameCapitalized = lib.toUpper (lib.substring 0 1 binaryName) + lib.substring 1 (-1) binaryName;
browserName = if stdenv.isDarwin then binaryNameCapitalized else binaryName;
applicationName = if stdenv.isDarwin then binaryNameCapitalized else binaryName;
execdir = if stdenv.isDarwin
then "/Applications/${binaryNameCapitalized}.app/Contents/MacOS"
else "/bin";
# 78 ESR won't build with rustc 1.47
inherit (if lib.versionAtLeast ffversion "82" then rustPackages else rustPackages_1_45)
inherit (if lib.versionAtLeast version "82" then rustPackages else rustPackages_1_45)
rustc cargo;
# Darwin's stdenv provides the default llvmPackages version, match that since
@ -118,7 +118,7 @@ let
# Disable p11-kit support in nss until our cacert packages has caught up exposing CKA_NSS_MOZILLA_CA_POLICY
# https://github.com/NixOS/nixpkgs/issues/126065
nss_pkg = if lib.versionOlder ffversion "83" then nss_3_53 else nss.override { useP11kit = false; };
nss_pkg = if lib.versionOlder version "83" then nss_3_53 else nss.override { useP11kit = false; };
# --enable-release adds -ffunction-sections & LTO that require a big amount of
# RAM and the 32-bit memory space cannot handle that linking
@ -129,26 +129,26 @@ let
in
buildStdenv.mkDerivation ({
name = "${pname}-unwrapped-${ffversion}";
version = ffversion;
name = "${pname}-unwrapped-${version}";
inherit version;
inherit src unpackPhase meta;
patches = [
] ++
lib.optional (lib.versionOlder ffversion "86") ./env_var_for_system_dir-ff85.patch ++
lib.optional (lib.versionAtLeast ffversion "86") ./env_var_for_system_dir-ff86.patch ++
lib.optional (lib.versionOlder ffversion "83") ./no-buildconfig-ffx76.patch ++
lib.optional (lib.versionAtLeast ffversion "90") ./no-buildconfig-ffx90.patch ++
lib.optional (ltoSupport && lib.versionOlder ffversion "84") ./lto-dependentlibs-generation-ffx83.patch ++
lib.optional (ltoSupport && lib.versionAtLeast ffversion "84" && lib.versionOlder ffversion "86")
lib.optional (lib.versionOlder version "86") ./env_var_for_system_dir-ff85.patch ++
lib.optional (lib.versionAtLeast version "86") ./env_var_for_system_dir-ff86.patch ++
lib.optional (lib.versionOlder version "83") ./no-buildconfig-ffx76.patch ++
lib.optional (lib.versionAtLeast version "90") ./no-buildconfig-ffx90.patch ++
lib.optional (ltoSupport && lib.versionOlder version "84") ./lto-dependentlibs-generation-ffx83.patch ++
lib.optional (ltoSupport && lib.versionAtLeast version "84" && lib.versionOlder version "86")
(fetchpatch {
url = "https://hg.mozilla.org/mozilla-central/raw-rev/fdff20c37be3";
sha256 = "135n9brliqy42lj3nqgb9d9if7x6x9nvvn0z4anbyf89bikixw48";
})
# This patch adds pipewire support for the ESR release
++ lib.optional (pipewireSupport && lib.versionOlder ffversion "83")
++ lib.optional (pipewireSupport && lib.versionOlder version "83")
(fetchpatch {
# https://src.fedoraproject.org/rpms/firefox/blob/master/f/firefox-pipewire-0-3.patch
url = "https://src.fedoraproject.org/rpms/firefox/raw/e99b683a352cf5b2c9ff198756859bae408b5d9d/f/firefox-pipewire-0-3.patch";
@ -185,11 +185,11 @@ buildStdenv.mkDerivation ({
++ lib.optional gssSupport libkrb5
++ lib.optionals waylandSupport [ libxkbcommon libdrm ]
++ lib.optional pipewireSupport pipewire
++ lib.optional (lib.versionAtLeast ffversion "82") gnum4
++ lib.optional (lib.versionAtLeast version "82") gnum4
++ lib.optionals buildStdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
AVFoundation MediaToolbox CoreLocation
Foundation libobjc AddressBook cups ]
++ lib.optional (lib.versionOlder ffversion "90") gtk2;
++ lib.optional (lib.versionOlder version "90") gtk2;
NIX_LDFLAGS = lib.optionalString ltoSupport ''
-rpath ${llvmPackages.libunwind.out}/lib
@ -201,14 +201,14 @@ buildStdenv.mkDerivation ({
rm -rf obj-x86_64-pc-linux-gnu
substituteInPlace toolkit/xre/glxtest.cpp \
--replace 'dlopen("libpci.so' 'dlopen("${pciutils}/lib/libpci.so'
'' + lib.optionalString (pipewireSupport && lib.versionOlder ffversion "83") ''
'' + lib.optionalString (pipewireSupport && lib.versionOlder version "83") ''
# substitute the /usr/include/ lines for the libraries that pipewire provides.
# The patch we pick from fedora only contains the generated moz.build files
# which hardcode the dependency paths instead of running pkg_config.
substituteInPlace \
media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build \
--replace /usr/include ${pipewire.dev}/include
'' + lib.optionalString (lib.versionAtLeast ffversion "80" && lib.versionOlder ffversion "81") ''
'' + lib.optionalString (lib.versionAtLeast version "80" && lib.versionOlder version "81") ''
substituteInPlace dom/system/IOUtils.h \
--replace '#include "nspr/prio.h"' '#include "prio.h"'
@ -276,7 +276,7 @@ buildStdenv.mkDerivation ({
'';
configureFlags = [
"--enable-application=browser"
"--enable-application=${application}"
"--with-system-jpeg"
"--with-system-zlib"
"--with-system-libevent"
@ -357,19 +357,19 @@ buildStdenv.mkDerivation ({
doInstallCheck = true;
installCheckPhase = ''
# Some basic testing
"$out${execdir}/${browserName}" --version
"$out${execdir}/${applicationName}" --version
'';
passthru = {
inherit updateScript;
version = ffversion;
inherit version;
inherit alsaSupport;
inherit pipewireSupport;
inherit nspr;
inherit ffmpegSupport;
inherit gssSupport;
inherit execdir;
inherit browserName;
inherit applicationName;
inherit tests;
inherit gtk3;
};

@ -7,9 +7,9 @@ in
rec {
firefox = common rec {
pname = "firefox";
ffversion = "91.0";
version = "91.0";
src = fetchurl {
url = "mirror://mozilla/firefox/releases/${ffversion}/source/firefox-${ffversion}.source.tar.xz";
url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
sha512 = "a02486a3996570e0cc815e92c98890bca1d27ce0018c2ee3d4bff9a6e54dbc8f5926fea8b5864f208e15389d631685b2add1e4e9e51146e40224d16d5c02f730";
};
@ -27,15 +27,14 @@ rec {
tests = [ nixosTests.firefox ];
updateScript = callPackage ./update.nix {
attrPath = "firefox-unwrapped";
versionKey = "ffversion";
};
};
firefox-esr-91 = common rec {
pname = "firefox-esr";
ffversion = "91.0esr";
version = "91.0esr";
src = fetchurl {
url = "mirror://mozilla/firefox/releases/${ffversion}/source/firefox-${ffversion}.source.tar.xz";
url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
sha512 = "e518e1536094a1da44eb45b3b0f3adc1b5532f17da2dbcc994715419ec4fcec40574fdf633349a8e5de6382942f5706757a35f1b96b11de4754855b9cf7946ae";
};
@ -53,15 +52,14 @@ rec {
updateScript = callPackage ./update.nix {
attrPath = "firefox-esr-91-unwrapped";
versionSuffix = "esr";
versionKey = "ffversion";
};
};
firefox-esr-78 = common rec {
pname = "firefox-esr";
ffversion = "78.12.0esr";
version = "78.12.0esr";
src = fetchurl {
url = "mirror://mozilla/firefox/releases/${ffversion}/source/firefox-${ffversion}.source.tar.xz";
url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
sha512 = "646eb803e0d0e541773e3111708c7eaa85e784e4bae6e4a77dcecdc617ee29e2e349c9ef16ae7e663311734dd7491aebd904359124dda62672dbc18bfb608f0a";
};
@ -79,7 +77,6 @@ rec {
updateScript = callPackage ./update.nix {
attrPath = "firefox-esr-78-unwrapped";
versionSuffix = "esr";
versionKey = "ffversion";
};
};
}

@ -20,18 +20,18 @@ browser:
let
wrapper =
{ browserName ? browser.browserName or (lib.getName browser)
, pname ? browserName
{ applicationName ? browser.applicationName or (lib.getName browser)
, pname ? applicationName
, version ? lib.getVersion browser
, desktopName ? # browserName with first letter capitalized
(lib.toUpper (lib.substring 0 1 browserName) + lib.substring 1 (-1) browserName)
, desktopName ? # applicationName with first letter capitalized
(lib.toUpper (lib.substring 0 1 applicationName) + lib.substring 1 (-1) applicationName)
, nameSuffix ? ""
, icon ? browserName
, icon ? applicationName
, extraNativeMessagingHosts ? []
, pkcs11Modules ? []
, forceWayland ? false
, useGlvnd ? true
, cfg ? config.${browserName} or {}
, cfg ? config.${applicationName} or {}
## Following options are needed for extra prefs & policies
# For more information about anti tracking (german website)
@ -40,7 +40,7 @@ let
# For more information about policies visit
# https://github.com/mozilla/policy-templates#enterprisepoliciesenabled
, extraPolicies ? {}
, firefoxLibName ? "firefox" # Important for tor package or the like
, libName ? "firefox" # Important for tor package or the like
, nixExtensions ? null
}:
@ -162,15 +162,15 @@ let
"jre"
];
pluginsError =
"Your configuration mentions ${lib.concatMapStringsSep ", " (p: browserName + "." + p) configPlugins}. All plugin related options have been removed, since Firefox from version 52 onwards no longer supports npapi plugins (see https://support.mozilla.org/en-US/kb/npapi-plugins).";
"Your configuration mentions ${lib.concatMapStringsSep ", " (p: applicationName + "." + p) configPlugins}. All plugin related options have been removed, since Firefox from version 52 onwards no longer supports npapi plugins (see https://support.mozilla.org/en-US/kb/npapi-plugins).";
in if configPlugins != [] then throw pluginsError else
(stdenv.mkDerivation {
inherit pname version;
desktopItem = makeDesktopItem {
name = browserName;
exec = "${browserName}${nameSuffix} %U";
name = applicationName;
exec = "${applicationName}${nameSuffix} %U";
inherit icon;
comment = "";
desktopName = "${desktopName}${nameSuffix}${lib.optionalString forceWayland " (Wayland)"}";
@ -193,12 +193,12 @@ let
buildCommand = lib.optionalString stdenv.isDarwin ''
mkdir -p $out/Applications
cp -R --no-preserve=mode,ownership ${browser}/Applications/${browserName}.app $out/Applications
rm -f $out${browser.execdir or "/bin"}/${browserName}
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"}/${browserName}" ]
if [ ! -x "${browser}${browser.execdir or "/bin"}/${applicationName}" ]
then
echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${browserName}'"
echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${applicationName}'"
exit 1
fi
@ -213,9 +213,9 @@ let
cd "${browser}"
find . -type d -exec mkdir -p "$out"/{} \;
find . -type f \( -not -name "${browserName}" \) -exec ln -sT "${browser}"/{} "$out"/{} \;
find . -type f \( -not -name "${applicationName}" \) -exec ln -sT "${browser}"/{} "$out"/{} \;
find . -type f -name "${browserName}" -print0 | while read -d $'\0' f; do
find . -type f -name "${applicationName}" -print0 | while read -d $'\0' f; do
cp -P --no-preserve=mode,ownership "${browser}/$f" "$out/$f"
chmod a+rwx "$out/$f"
done
@ -236,11 +236,11 @@ let
# create the wrapper
executablePrefix="$out${browser.execdir or "/bin"}"
executablePath="$executablePrefix/${browserName}"
executablePath="$executablePrefix/${applicationName}"
if [ ! -x "$executablePath" ]
then
echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${browserName}'"
echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${applicationName}'"
exit 1
fi
@ -249,25 +249,25 @@ let
# Careful here, the file at executablePath may already be
# a wrapper. That is why we postfix it with -old instead
# of -wrapped.
oldExe="$executablePrefix"/".${browserName}"-old
oldExe="$executablePrefix"/".${applicationName}"-old
mv "$executablePath" "$oldExe"
else
oldExe="$(readlink -v --canonicalize-existing "$executablePath")"
fi
if [ ! -x "${browser}${browser.execdir or "/bin"}/${browserName}" ]
if [ ! -x "${browser}${browser.execdir or "/bin"}/${applicationName}" ]
then
echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${browserName}'"
echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${applicationName}'"
exit 1
fi
makeWrapper "$oldExe" \
"$out${browser.execdir or "/bin"}/${browserName}${nameSuffix}" \
"$out${browser.execdir or "/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"}" \
--set MOZ_APP_LAUNCHER "${browserName}${nameSuffix}" \
--set MOZ_APP_LAUNCHER "${applicationName}${nameSuffix}" \
--set MOZ_SYSTEM_DIR "$out/lib/mozilla" \
--set MOZ_LEGACY_PROFILES 1 \
--set MOZ_ALLOW_DOWNGRADE 1 \
@ -290,7 +290,7 @@ let
mkdir -p "$out/share/icons/hicolor/''${res}x''${res}/apps"
icon=( "${browser}/lib/"*"/browser/chrome/icons/default/default''${res}.png" )
if [ -e "$icon" ]; then ln -s "$icon" \
"$out/share/icons/hicolor/''${res}x''${res}/apps/${browserName}.png"
"$out/share/icons/hicolor/''${res}x''${res}/apps/${applicationName}.png"
fi
done
fi
@ -314,24 +314,24 @@ let
# #
#########################
# user customization
mkdir -p $out/lib/${firefoxLibName}
mkdir -p $out/lib/${libName}
# creating policies.json
mkdir -p "$out/lib/${firefoxLibName}/distribution"
mkdir -p "$out/lib/${libName}/distribution"
POL_PATH="$out/lib/${firefoxLibName}/distribution/policies.json"
POL_PATH="$out/lib/${libName}/distribution/policies.json"
rm -f "$POL_PATH"
cat ${policiesJson} >> "$POL_PATH"
# preparing for autoconfig
mkdir -p "$out/lib/${firefoxLibName}/defaults/pref"
mkdir -p "$out/lib/${libName}/defaults/pref"
echo 'pref("general.config.filename", "mozilla.cfg");' > "$out/lib/${firefoxLibName}/defaults/pref/autoconfig.js"
echo 'pref("general.config.obscure_value", 0);' >> "$out/lib/${firefoxLibName}/defaults/pref/autoconfig.js"
echo 'pref("general.config.filename", "mozilla.cfg");' > "$out/lib/${libName}/defaults/pref/autoconfig.js"
echo 'pref("general.config.obscure_value", 0);' >> "$out/lib/${libName}/defaults/pref/autoconfig.js"
cat > "$out/lib/${firefoxLibName}/mozilla.cfg" < ${mozillaCfg}
cat > "$out/lib/${libName}/mozilla.cfg" < ${mozillaCfg}
mkdir -p $out/lib/${firefoxLibName}/distribution/extensions
mkdir -p $out/lib/${libName}/distribution/extensions
#############################
# #

@ -24486,7 +24486,7 @@ with pkgs;
};
firefox-bin = wrapFirefox firefox-bin-unwrapped {
browserName = "firefox";
applicationName = "firefox";
pname = "firefox-bin";
desktopName = "Firefox";
};
@ -24497,7 +24497,7 @@ with pkgs;
};
firefox-beta-bin = res.wrapFirefox firefox-beta-bin-unwrapped {
browserName = "firefox";
applicationName = "firefox";
pname = "firefox-beta-bin";
desktopName = "Firefox Beta";
};
@ -24508,7 +24508,7 @@ with pkgs;
};
firefox-devedition-bin = res.wrapFirefox firefox-devedition-bin-unwrapped {
browserName = "firefox";
applicationName = "firefox";
nameSuffix = "-devedition";
pname = "firefox-devedition-bin";
desktopName = "Firefox DevEdition";

Loading…
Cancel
Save