firefox, thunderbird: enable wrapped derivations for darwin (#377863)

This commit is contained in:
Yueh-Shun Li
2025-02-25 14:39:14 +08:00
committed by GitHub
13 changed files with 89 additions and 51 deletions
@@ -20,6 +20,7 @@
, runtimeShell
, systemLocale ? config.i18n.defaultLocale or "en_US"
, patchelfUnstable # have to use patchelfUnstable to support --no-clobber-old-sections
, applicationName? "Firefox"
}:
let
@@ -97,7 +98,7 @@ stdenv.mkDerivation {
'';
passthru = {
inherit binaryName;
inherit applicationName binaryName;
libName = "firefox-bin-${version}";
ffmpegSupport = true;
gssSupport = true;
@@ -5,7 +5,7 @@
, updateScript ? null
, binaryName ? "firefox"
, application ? "browser"
, applicationName ? "Mozilla Firefox"
, applicationName ? "Firefox"
, branding ? null
, requireSigning ? true
, allowAddonSideload ? false
@@ -119,7 +119,7 @@ in
, pipewireSupport ? waylandSupport && webrtcSupport
, pulseaudioSupport ? stdenv.hostPlatform.isLinux, libpulseaudio
, sndioSupport ? stdenv.hostPlatform.isLinux, sndio
, waylandSupport ? true, libxkbcommon, libdrm
, waylandSupport ? !stdenv.hostPlatform.isDarwin, libxkbcommon, libdrm
## privacy-related options
@@ -200,12 +200,15 @@ let
done
'';
distributionIni = pkgs.writeText "distribution.ini" (lib.generators.toINI {} {
distributionIni = let
platform = if stdenv.hostPlatform.isDarwin then "Nix on MacOS" else "NixOS";
in
pkgs.writeText "distribution.ini" (lib.generators.toINI {} {
# Some light branding indicating this build uses our distro preferences
Global = {
id = "nixos";
version = "1.0";
about = "${applicationName} for NixOS";
about = "${applicationName} for ${platform}";
};
Preferences = {
# These values are exposed through telemetry
@@ -593,11 +596,9 @@ buildStdenv.mkDerivation {
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications
cp -r dist/${binaryName}/*.app $out/Applications
cp -r dist/${binaryName}/*.app "$out/Applications/${applicationName}.app"
appBundlePath=(dist/${binaryName}/*.app)
appBundle=''${appBundlePath[0]#dist/${binaryName}}
resourceDir=$out/Applications/$appBundle/Contents/Resources
resourceDir="$out/Applications/${applicationName}.app/Contents/Resources"
'' + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
# Remove SDK cruft. FIXME: move to a separate output?
@@ -622,7 +623,7 @@ buildStdenv.mkDerivation {
# Some basic testing
doInstallCheck = true;
installCheckPhase = lib.optionalString buildStdenv.hostPlatform.isDarwin ''
bindir=$out/Applications/$appBundle/Contents/MacOS
bindir="$out/Applications/${applicationName}.app/Contents/MacOS"
'' + lib.optionalString (!buildStdenv.hostPlatform.isDarwin) ''
bindir=$out/bin
'' + ''
@@ -630,6 +631,7 @@ buildStdenv.mkDerivation {
'';
passthru = {
inherit applicationName;
inherit application extraPatches;
inherit updateScript;
inherit alsaSupport;
@@ -11,7 +11,7 @@ buildMozillaMach rec {
pname = "firefox-beta";
binaryName = pname;
version = "135.0b9";
applicationName = "Mozilla Firefox Beta";
applicationName = "Firefox Beta";
src = fetchurl {
url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
sha512 = "3007c2a8743e4444226e66f0c11f53f01255c09702deda7de83bbe134a19c324b8b49de78d3211b20bb82c7b2040127145d2e39ed8aa81c653ac4397c46476f6";
@@ -11,7 +11,7 @@ buildMozillaMach rec {
pname = "firefox-devedition";
binaryName = pname;
version = "135.0b9";
applicationName = "Mozilla Firefox Developer Edition";
applicationName = "Firefox Developer Edition";
requireSigning = false;
branding = "browser/branding/aurora";
src = fetchurl {
@@ -10,6 +10,7 @@
buildMozillaMach rec {
pname = "firefox";
version = "128.7.0esr";
applicationName = "Firefox ESR";
src = fetchurl {
url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
sha512 = "26f9661b395b85a44b42bd72ef1ad976c614216c68f6c2dd834d0ac8b84b9c9f398b8ac550a47396995d96e6bb5fa9a50064d7f2f526bddd45aed5039ef131b8";
@@ -1,4 +1,4 @@
{ stdenv, lib, makeDesktopItem, makeWrapper, lndir, config
{ stdenv, lib, makeDesktopItem, makeBinaryWrapper, lndir, config
, buildPackages
, jq, xdg-utils, writeText
@@ -23,12 +23,11 @@
browser:
let
isDarwin = stdenv.hostPlatform.isDarwin;
wrapper =
{ applicationName ? browser.binaryName or (lib.getName browser)
{ applicationName ? browser.binaryName or (lib.getName browser) # Note: this is actually *binary* name and is different from browser.applicationName, which is *app* name!
, pname ? applicationName
, version ? lib.getVersion browser
, desktopName ? # applicationName with first letter capitalized
(lib.toUpper (lib.substring 0 1 applicationName) + lib.substring 1 (-1) applicationName)
, nameSuffix ? ""
, icon ? applicationName
, wmClass ? applicationName
@@ -82,7 +81,8 @@ let
++ gtk_modules;
gtk_modules = [ libcanberra-gtk3 ];
launcherName = "${applicationName}${nameSuffix}";
# Darwin does not rename bundled binaries
launcherName = "${applicationName}${lib.optionalString (!isDarwin) nameSuffix}";
#########################
# #
@@ -164,7 +164,7 @@ let
name = launcherName;
exec = "${launcherName} --name ${wmClass} %U";
inherit icon;
inherit desktopName;
desktopName = browser.applicationName;
startupNotify = true;
startupWMClass = wmClass;
terminal = false;
@@ -219,7 +219,7 @@ let
};
}));
nativeBuildInputs = [ makeWrapper lndir jq ];
nativeBuildInputs = [ makeBinaryWrapper lndir jq ];
buildInputs = [ browser.gtk3 ];
makeWrapperArgs = [
@@ -279,10 +279,18 @@ let
''ln -sfLt ''${MOZ_HOME:-~/.mozilla}/native-messaging-hosts ${ext}/lib/mozilla/native-messaging-hosts/*''
]) allNativeMessagingHosts);
buildCommand = ''
if [ ! -x "${browser}/bin/${applicationName}" ]
buildCommand = let
appPath = "Applications/${browser.applicationName}.app";
executablePrefix = if isDarwin then "${appPath}/Contents/MacOS" else "bin";
executablePath="${executablePrefix}/${applicationName}";
finalBinaryPath = "${executablePath}" + lib.optionalString (!isDarwin) "${nameSuffix}";
sourceBinary="${browser}/${executablePath}";
libDir = if isDarwin then "${appPath}/Contents/Resources" else "lib/${libName}";
prefsDir = if isDarwin then "${libDir}/browser/defaults/preferences" else "${libDir}/defaults/pref";
in ''
if [ ! -x "${sourceBinary}" ]
then
echo "cannot find executable file \`${browser}/bin/${applicationName}'"
echo "cannot find executable file \`${sourceBinary}'"
exit 1
fi
@@ -314,10 +322,31 @@ let
cd "$out"
'' + lib.optionalString isDarwin ''
cd "${appPath}"
# These files have to be copied and not symlinked, otherwise tabs crash.
# Maybe related to how omni.ja file is mmapped into memory. See:
# https://github.com/mozilla/gecko-dev/blob/b1662b447f306e6554647914090d4b73ac8e1664/modules/libjar/nsZipArchive.cpp#L204
for file in $(find . -type l -name "omni.ja"); do
rm "$file"
cp "${browser}/${appPath}/$file" "$file"
done
# Copy any embedded .app directories; plugin-container fails to start otherwise.
for dir in $(find . -type d -name '*.app'); do
rm -r "$dir"
cp -r "${browser}/${appPath}/$dir" "$dir"
done
cd ..
'' + ''
# create the wrapper
executablePrefix="$out/bin"
executablePath="$executablePrefix/${applicationName}"
executablePrefix="$out/${executablePrefix}"
executablePath="$out/${executablePath}"
oldWrapperArgs=()
if [[ -L $executablePath ]]; then
@@ -348,13 +377,15 @@ let
appendToVar makeWrapperArgs --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
concatTo makeWrapperArgs oldWrapperArgs
makeWrapper "$oldExe" "''${executablePath}${nameSuffix}" "''${makeWrapperArgs[@]}"
makeWrapper "$oldExe" "$out/${finalBinaryPath}" "''${makeWrapperArgs[@]}"
#############################
# #
# END EXTRA PREF CHANGES #
# #
#############################
'' + lib.optionalString (!isDarwin) ''
if [ -e "${browser}/share/icons" ]; then
mkdir -p "$out/share"
ln -s "${browser}/share/icons" "$out/share/icons"
@@ -389,12 +420,12 @@ let
# #
#########################
# user customization
mkdir -p $out/lib/${libName}
libDir="$out/${libDir}"
# creating policies.json
mkdir -p "$out/lib/${libName}/distribution"
mkdir -p "$libDir/distribution"
POL_PATH="$out/lib/${libName}/distribution/policies.json"
POL_PATH="$libDir/distribution/policies.json"
rm -f "$POL_PATH"
cat ${policiesJson} >> "$POL_PATH"
@@ -405,25 +436,26 @@ let
done
# preparing for autoconfig
mkdir -p "$out/lib/${libName}/defaults/pref"
prefsDir="$out/${prefsDir}"
mkdir -p "$prefsDir"
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"
echo 'pref("general.config.filename", "mozilla.cfg");' > "$prefsDir/autoconfig.js"
echo 'pref("general.config.obscure_value", 0);' >> "$prefsDir/autoconfig.js"
cat > "$out/lib/${libName}/mozilla.cfg" << EOF
cat > "$libDir/mozilla.cfg" << EOF
${mozillaCfg}
EOF
extraPrefsFiles=(${builtins.toString extraPrefsFiles})
for extraPrefsFile in "''${extraPrefsFiles[@]}"; do
cat "$extraPrefsFile" >> "$out/lib/${libName}/mozilla.cfg"
cat "$extraPrefsFile" >> "$libDir/mozilla.cfg"
done
cat >> "$out/lib/${libName}/mozilla.cfg" << EOF
cat >> "$libDir/mozilla.cfg" << EOF
${extraPrefs}
EOF
mkdir -p $out/lib/${libName}/distribution/extensions
mkdir -p "$libDir/distribution/extensions"
#############################
# #
@@ -24,6 +24,7 @@
systemLocale ? config.i18n.defaultLocale or "en_US",
patchelfUnstable, # have to use patchelfUnstable to support --no-clobber-old-sections
generated,
applicationName ? "Thunderbird",
}:
let
@@ -120,6 +121,7 @@ stdenv.mkDerivation {
};
passthru = {
inherit applicationName;
binaryName = "thunderbird";
gssSupport = true;
gtk3 = gtk3;
@@ -28,12 +28,12 @@ let
version,
sha512,
updateScript,
applicationName ? "Thunderbird",
}:
(buildMozillaMach rec {
pname = "thunderbird";
inherit version updateScript;
inherit version updateScript applicationName;
application = "comm/mail";
applicationName = "Mozilla Thunderbird";
binaryName = pname;
src = fetchurl {
url = "mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz";
@@ -98,6 +98,8 @@ rec {
thunderbird-esr = thunderbird-128;
thunderbird-128 = common {
applicationName = "Thunderbird ESR";
version = "128.7.1esr";
sha512 = "3f84e1f1a83379da1f154b66dbb5f941d04548ad017aab32aa9520f4315edb524e3754ac1fe9a7ae27f7aa33e2881c6783f11ccc53cda713f107760b7d880667";
@@ -26,7 +26,7 @@ browser: args:
buildCommand =
old.buildCommand
+ ''
wrapProgram $out/bin/${browser.binaryName} \
wrapProgram "$executablePath" \
--prefix LD_LIBRARY_PATH ':' "${lib.makeLibraryPath [ gpgme ]}" \
--prefix PATH ':' "${lib.makeBinPath [ gnupg ]}"
'';
+1 -1
View File
@@ -151,7 +151,7 @@ rustPlatform.buildRustPackage rec {
homepage = "https://pwasforfirefox.filips.si/";
changelog = "https://github.com/filips123/PWAsForFirefox/releases/tag/v${version}";
license = lib.licenses.mpl20;
platforms = lib.platforms.unix;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [
camillemndn
pasqui23
@@ -53,6 +53,7 @@ stdenv.mkDerivation rec {
passthru = {
inherit gtk3;
applicationName = "Midori";
};
meta = with lib; {
@@ -65,5 +66,7 @@ stdenv.mkDerivation rec {
raskin
ramkromberg
];
# https://github.com/NixOS/nixpkgs/issues/374354
broken = true;
};
}
@@ -36,6 +36,7 @@ stdenv.mkDerivation rec {
passthru = {
inherit gtk3;
applicationName = "Vimb";
};
makeFlags = [ "PREFIX=${placeholder "out"}" ];
+5 -11
View File
@@ -13391,24 +13391,20 @@ with pkgs;
firefox-esr-unwrapped = firefox-esr-128-unwrapped;
firefox = wrapFirefox firefox-unwrapped { };
firefox-beta = wrapFirefox firefox-beta-unwrapped {
desktopName = "Firefox Beta";
};
firefox-devedition = wrapFirefox firefox-devedition-unwrapped {
desktopName = "Firefox Developer Edition";
};
firefox-beta = wrapFirefox firefox-beta-unwrapped { };
firefox-devedition = wrapFirefox firefox-devedition-unwrapped { };
firefox-mobile = callPackage ../applications/networking/browsers/firefox/mobile-config.nix { };
firefox-esr-128 = wrapFirefox firefox-esr-128-unwrapped {
nameSuffix = "-esr";
desktopName = "Firefox ESR";
wmClass = "firefox-esr";
icon = "firefox-esr";
};
firefox-esr = firefox-esr-128;
firefox-bin-unwrapped = callPackage ../applications/networking/browsers/firefox-bin {
inherit (firefox-unwrapped.passthru) applicationName;
channel = "release";
generated = import ../applications/networking/browsers/firefox-bin/release_sources.nix;
};
@@ -13418,23 +13414,23 @@ with pkgs;
};
firefox-beta-bin-unwrapped = firefox-bin-unwrapped.override {
inherit (firefox-beta-unwrapped.passthru) applicationName;
channel = "beta";
generated = import ../applications/networking/browsers/firefox-bin/beta_sources.nix;
};
firefox-beta-bin = res.wrapFirefox firefox-beta-bin-unwrapped {
pname = "firefox-beta-bin";
desktopName = "Firefox Beta";
};
firefox-devedition-bin-unwrapped = callPackage ../applications/networking/browsers/firefox-bin {
inherit (firefox-devedition-unwrapped.passthru) applicationName;
channel = "developer-edition";
generated = import ../applications/networking/browsers/firefox-bin/developer-edition_sources.nix;
};
firefox-devedition-bin = res.wrapFirefox firefox-devedition-bin-unwrapped {
pname = "firefox-devedition-bin";
desktopName = "Firefox DevEdition";
wmClass = "firefox-aurora";
};
@@ -15233,9 +15229,7 @@ with pkgs;
thunderbird-128 = wrapThunderbird thunderbirdPackages.thunderbird-128 { };
thunderbird-bin = wrapThunderbird thunderbird-bin-unwrapped {
applicationName = "thunderbird";
pname = "thunderbird-bin";
desktopName = "Thunderbird";
};
thunderbird-bin-unwrapped = callPackage ../applications/networking/mailreaders/thunderbird-bin {
generated = import ../applications/networking/mailreaders/thunderbird-bin/release_sources.nix;