From fe4e676f53b7f0d7dd63026a904a4c5c624e96e4 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 14 Feb 2025 20:24:07 -0500 Subject: [PATCH 1/7] midori-unwrapped: mark as broken Related-Bug: #374354 Signed-off-by: Ihar Hrachyshka --- pkgs/by-name/mi/midori-unwrapped/package.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/by-name/mi/midori-unwrapped/package.nix b/pkgs/by-name/mi/midori-unwrapped/package.nix index 855f54c87aa4..2362c4c072c4 100644 --- a/pkgs/by-name/mi/midori-unwrapped/package.nix +++ b/pkgs/by-name/mi/midori-unwrapped/package.nix @@ -65,5 +65,7 @@ stdenv.mkDerivation rec { raskin ramkromberg ]; + # https://github.com/NixOS/nixpkgs/issues/374354 + broken = true; }; } From 21105d474082be72ebd620082df34732d38408eb Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 14 Feb 2025 20:26:30 -0500 Subject: [PATCH 2/7] firefoxpwa: mark it linux only It's not implemented for Darwin. Signed-off-by: Ihar Hrachyshka --- pkgs/by-name/fi/firefoxpwa/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/fi/firefoxpwa/package.nix b/pkgs/by-name/fi/firefoxpwa/package.nix index f6471f3ceaf3..5e1818a36630 100644 --- a/pkgs/by-name/fi/firefoxpwa/package.nix +++ b/pkgs/by-name/fi/firefoxpwa/package.nix @@ -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 From b856437376fd346ed9054a671ec602eff16f496f Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Wed, 29 Jan 2025 20:35:46 -0500 Subject: [PATCH 3/7] firefox, thunderbird: enable wrapped derivations for darwin It also aligns application names for wrapped and unwrapped flavors of the same derivations; and uses unique application names for each flavor, so it's now possible to install multiple versions on the same Darwin machine. One visible change now is that `About Firefox` window now shows: `Firefox for NixOS` instead of `Mozilla Firefox for NixOS` ...in the `distribution` field. I think it's fine and doesn't infringe on any trademarks because this field is not required to mention Mozilla at all, as per: https://wiki.mozilla.org/Distribution_INI_File While at it, also changed the branding for Darwin builds to list: `Firefox for Nix on MacOS` instead of `Firefox for NixOS` The telemetry and distribution ids (`nixos`) are left intact. Note: it's still not possible to install both source-based and -bin Darwin derivations in the same profile. It would require renaming applicationNames for these two different types to use unique names (e.g. `Firefox (Official)` or `Firefox (Binary)`, which doesn't seem optimal. Closes: #378433 Closes: #366581 Signed-off-by: Ihar Hrachyshka --- .../browsers/firefox-bin/default.nix | 3 +- .../networking/browsers/firefox/common.nix | 20 ++--- .../firefox/packages/firefox-beta.nix | 2 +- .../firefox/packages/firefox-devedition.nix | 2 +- .../firefox/packages/firefox-esr-128.nix | 1 + .../networking/browsers/firefox/wrapper.nix | 81 +++++++++++++------ .../mailreaders/thunderbird-bin/default.nix | 2 + .../mailreaders/thunderbird/packages.nix | 6 +- .../mailreaders/thunderbird/wrapper.nix | 2 +- pkgs/by-name/mi/midori-unwrapped/package.nix | 1 + pkgs/by-name/vi/vimb-unwrapped/package.nix | 1 + pkgs/top-level/all-packages.nix | 16 ++-- 12 files changed, 87 insertions(+), 50 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox-bin/default.nix b/pkgs/applications/networking/browsers/firefox-bin/default.nix index 81abbb268397..b0cfe44bf131 100644 --- a/pkgs/applications/networking/browsers/firefox-bin/default.nix +++ b/pkgs/applications/networking/browsers/firefox-bin/default.nix @@ -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; diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index bd853b8fd10b..26810ac91359 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -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; diff --git a/pkgs/applications/networking/browsers/firefox/packages/firefox-beta.nix b/pkgs/applications/networking/browsers/firefox/packages/firefox-beta.nix index 131820b3164b..d6324dca529e 100644 --- a/pkgs/applications/networking/browsers/firefox/packages/firefox-beta.nix +++ b/pkgs/applications/networking/browsers/firefox/packages/firefox-beta.nix @@ -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"; diff --git a/pkgs/applications/networking/browsers/firefox/packages/firefox-devedition.nix b/pkgs/applications/networking/browsers/firefox/packages/firefox-devedition.nix index e44a8c40e6d1..58a79bc0fc17 100644 --- a/pkgs/applications/networking/browsers/firefox/packages/firefox-devedition.nix +++ b/pkgs/applications/networking/browsers/firefox/packages/firefox-devedition.nix @@ -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 { diff --git a/pkgs/applications/networking/browsers/firefox/packages/firefox-esr-128.nix b/pkgs/applications/networking/browsers/firefox/packages/firefox-esr-128.nix index bd3e7991ae86..9d066ed8bbc0 100644 --- a/pkgs/applications/networking/browsers/firefox/packages/firefox-esr-128.nix +++ b/pkgs/applications/networking/browsers/firefox/packages/firefox-esr-128.nix @@ -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"; diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index ebccb73c85c5..195558808f26 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, makeDesktopItem, makeWrapper, lndir, config +{ stdenv, lib, makeDesktopItem, makeBinaryWrapper, lndir, config , buildPackages , jq, xdg-utils, writeText @@ -24,11 +24,9 @@ browser: let 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.passthru.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 +80,8 @@ let ++ gtk_modules; gtk_modules = [ libcanberra-gtk3 ]; - launcherName = "${applicationName}${nameSuffix}"; + # Darwin does not rename bundled binaries + launcherName = "${applicationName}${lib.optionalString (!stdenv.hostPlatform.isDarwin) nameSuffix}"; ######################### # # @@ -164,7 +163,7 @@ let name = launcherName; exec = "${launcherName} --name ${wmClass} %U"; inherit icon; - inherit desktopName; + desktopName = browser.passthru.applicationName; startupNotify = true; startupWMClass = wmClass; terminal = false; @@ -219,7 +218,7 @@ let }; })); - nativeBuildInputs = [ makeWrapper lndir jq ]; + nativeBuildInputs = [ makeBinaryWrapper lndir jq ]; buildInputs = [ browser.gtk3 ]; makeWrapperArgs = [ @@ -279,10 +278,18 @@ let ''ln -sfLt ''${MOZ_HOME:-~/.mozilla}/native-messaging-hosts ${ext}/lib/mozilla/native-messaging-hosts/*'' ]) allNativeMessagingHosts); - buildCommand = '' - if [ ! -x "${browser}/bin/${applicationName}" ] + buildCommand = lib.optionalString stdenv.hostPlatform.isDarwin '' + appPath="Applications/${browser.passthru.applicationName}.app" + executablePrefix="$appPath/Contents/MacOS" + '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + executablePrefix=bin + '' + '' + executablePath="$executablePrefix/${applicationName}" + + sourceBinary="${browser}/$executablePath" + if [ ! -x "$sourceBinary" ] then - echo "cannot find executable file \`${browser}/bin/${applicationName}'" + echo "cannot find executable file \`$sourceBinary'" exit 1 fi @@ -312,12 +319,22 @@ let ln -sfT "$target" "$out/$l" done + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + # 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 path in "" "browser"; do + omniPath="$appPath/Contents/Resources/$path/" + rm "$out/$omniPath/omni.ja" + cp "${browser}/$omniPath/omni.ja" "$out/$omniPath/" + done + '' + '' cd "$out" # create the wrapper - executablePrefix="$out/bin" - executablePath="$executablePrefix/${applicationName}" + executablePrefix="$out/$executablePrefix" + executablePath="$out/$executablePath" oldWrapperArgs=() if [[ -L $executablePath ]]; then @@ -348,13 +365,20 @@ let appendToVar makeWrapperArgs --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" concatTo makeWrapperArgs oldWrapperArgs - makeWrapper "$oldExe" "''${executablePath}${nameSuffix}" "''${makeWrapperArgs[@]}" + + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + finalBinaryPath="$executablePath" + '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + finalBinaryPath="''${executablePath}${nameSuffix}" + '' + '' + makeWrapper "$oldExe" "$finalBinaryPath" "''${makeWrapperArgs[@]}" + ############################# # # # END EXTRA PREF CHANGES # # # ############################# - + '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' if [ -e "${browser}/share/icons" ]; then mkdir -p "$out/share" ln -s "${browser}/share/icons" "$out/share/icons" @@ -389,12 +413,16 @@ let # # ######################### # user customization - mkdir -p $out/lib/${libName} + '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + libDir="$out/lib/${libName}" + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + libDir="$out/$appPath/Contents/Resources" + '' + '' # 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 +433,30 @@ let done # preparing for autoconfig - mkdir -p "$out/lib/${libName}/defaults/pref" + '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + prefsDir="$libDir/defaults/pref" + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + prefsDir="$libDir/browser/defaults/preferences" + '' + '' + 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" ############################# # # diff --git a/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix b/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix index e7c901d5cbd6..e4528737697d 100644 --- a/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix +++ b/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix @@ -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; diff --git a/pkgs/applications/networking/mailreaders/thunderbird/packages.nix b/pkgs/applications/networking/mailreaders/thunderbird/packages.nix index 90e6e9cde7b8..47fa89ee9c88 100644 --- a/pkgs/applications/networking/mailreaders/thunderbird/packages.nix +++ b/pkgs/applications/networking/mailreaders/thunderbird/packages.nix @@ -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"; diff --git a/pkgs/applications/networking/mailreaders/thunderbird/wrapper.nix b/pkgs/applications/networking/mailreaders/thunderbird/wrapper.nix index e623d3ac6141..88499068e953 100644 --- a/pkgs/applications/networking/mailreaders/thunderbird/wrapper.nix +++ b/pkgs/applications/networking/mailreaders/thunderbird/wrapper.nix @@ -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 ]}" ''; diff --git a/pkgs/by-name/mi/midori-unwrapped/package.nix b/pkgs/by-name/mi/midori-unwrapped/package.nix index 2362c4c072c4..906354905354 100644 --- a/pkgs/by-name/mi/midori-unwrapped/package.nix +++ b/pkgs/by-name/mi/midori-unwrapped/package.nix @@ -53,6 +53,7 @@ stdenv.mkDerivation rec { passthru = { inherit gtk3; + applicationName = "Midori"; }; meta = with lib; { diff --git a/pkgs/by-name/vi/vimb-unwrapped/package.nix b/pkgs/by-name/vi/vimb-unwrapped/package.nix index 21436d224e98..6e3b56ef58ba 100644 --- a/pkgs/by-name/vi/vimb-unwrapped/package.nix +++ b/pkgs/by-name/vi/vimb-unwrapped/package.nix @@ -36,6 +36,7 @@ stdenv.mkDerivation rec { passthru = { inherit gtk3; + applicationName = "Vimb"; }; makeFlags = [ "PREFIX=${placeholder "out"}" ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index af6e28b872d3..8b951f90dc81 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13406,24 +13406,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; }; @@ -13433,23 +13429,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"; }; @@ -15241,9 +15237,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; From 123b8874a78666bb30990411049f1c7405c26b89 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 16 Feb 2025 21:24:33 -0500 Subject: [PATCH 4/7] firefox: transform shell variables into nix expressions Signed-off-by: Ihar Hrachyshka --- .../networking/browsers/firefox/wrapper.nix | 55 ++++++++----------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 195558808f26..2d704cdddaa0 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -23,6 +23,7 @@ browser: let + isDarwin = stdenv.hostPlatform.isDarwin; wrapper = { applicationName ? browser.binaryName or (lib.getName browser) # Note: this is actually *binary* name and is different from browser.passthru.applicationName, which is *app* name! , pname ? applicationName @@ -81,7 +82,7 @@ let gtk_modules = [ libcanberra-gtk3 ]; # Darwin does not rename bundled binaries - launcherName = "${applicationName}${lib.optionalString (!stdenv.hostPlatform.isDarwin) nameSuffix}"; + launcherName = "${applicationName}${lib.optionalString (!isDarwin) nameSuffix}"; ######################### # # @@ -278,18 +279,18 @@ let ''ln -sfLt ''${MOZ_HOME:-~/.mozilla}/native-messaging-hosts ${ext}/lib/mozilla/native-messaging-hosts/*'' ]) allNativeMessagingHosts); - buildCommand = lib.optionalString stdenv.hostPlatform.isDarwin '' - appPath="Applications/${browser.passthru.applicationName}.app" - executablePrefix="$appPath/Contents/MacOS" - '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - executablePrefix=bin - '' + '' - executablePath="$executablePrefix/${applicationName}" - - sourceBinary="${browser}/$executablePath" - if [ ! -x "$sourceBinary" ] + buildCommand = let + appPath = "Applications/${browser.passthru.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 \`$sourceBinary'" + echo "cannot find executable file \`${sourceBinary}'" exit 1 fi @@ -319,22 +320,23 @@ let ln -sfT "$target" "$out/$l" done - '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + '' + lib.optionalString isDarwin '' # 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 path in "" "browser"; do - omniPath="$appPath/Contents/Resources/$path/" + omniPath="${appPath}/Contents/Resources/$path/" rm "$out/$omniPath/omni.ja" cp "${browser}/$omniPath/omni.ja" "$out/$omniPath/" done + '' + '' cd "$out" # create the wrapper - executablePrefix="$out/$executablePrefix" - executablePath="$out/$executablePath" + executablePrefix="$out/${executablePrefix}" + executablePath="$out/${executablePath}" oldWrapperArgs=() if [[ -L $executablePath ]]; then @@ -366,19 +368,14 @@ let appendToVar makeWrapperArgs --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" concatTo makeWrapperArgs oldWrapperArgs - '' + lib.optionalString stdenv.hostPlatform.isDarwin '' - finalBinaryPath="$executablePath" - '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - finalBinaryPath="''${executablePath}${nameSuffix}" - '' + '' - makeWrapper "$oldExe" "$finalBinaryPath" "''${makeWrapperArgs[@]}" + makeWrapper "$oldExe" "$out/${finalBinaryPath}" "''${makeWrapperArgs[@]}" ############################# # # # END EXTRA PREF CHANGES # # # ############################# - '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + '' + lib.optionalString (!isDarwin) '' if [ -e "${browser}/share/icons" ]; then mkdir -p "$out/share" ln -s "${browser}/share/icons" "$out/share/icons" @@ -413,12 +410,8 @@ let # # ######################### # user customization + libDir="$out/${libDir}" - '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - libDir="$out/lib/${libName}" - '' + lib.optionalString stdenv.hostPlatform.isDarwin '' - libDir="$out/$appPath/Contents/Resources" - '' + '' # creating policies.json mkdir -p "$libDir/distribution" @@ -433,11 +426,7 @@ let done # preparing for autoconfig - '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - prefsDir="$libDir/defaults/pref" - '' + lib.optionalString stdenv.hostPlatform.isDarwin '' - prefsDir="$libDir/browser/defaults/preferences" - '' + '' + prefsDir="$out/${prefsDir}" mkdir -p "$prefsDir" echo 'pref("general.config.filename", "mozilla.cfg");' > "$prefsDir/autoconfig.js" From 705cea1e5238eab3875b63cf916253c83a7e8bf8 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 16 Feb 2025 22:07:41 -0500 Subject: [PATCH 5/7] thunderbird: fix build failure due to different path to omni.ja Signed-off-by: Ihar Hrachyshka --- .../networking/browsers/firefox/wrapper.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 2d704cdddaa0..5aebff66b1f4 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -320,18 +320,20 @@ let ln -sfT "$target" "$out/$l" done + cd "$out" + '' + lib.optionalString isDarwin '' # 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 path in "" "browser"; do - omniPath="${appPath}/Contents/Resources/$path/" - rm "$out/$omniPath/omni.ja" - cp "${browser}/$omniPath/omni.ja" "$out/$omniPath/" + cd "${appPath}" + for file in $(find . -type l -name "omni.ja"); do + rm "$file" + cp "${browser}/${appPath}/$file" "$file" done + cd .. '' + '' - cd "$out" # create the wrapper From 2c5b25312aca35125bf7ebe6fcafb6988351e92b Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 16 Feb 2025 22:39:19 -0500 Subject: [PATCH 6/7] firefox: also copy any embedded *.app bundles on Darwin Without this, plugin-container fails to start. Signed-off-by: Ihar Hrachyshka --- .../networking/browsers/firefox/wrapper.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 5aebff66b1f4..bd28a3abdd12 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -323,14 +323,22 @@ 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 - cd "${appPath}" 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 .. '' + '' From e04cba723699d9090b436d84d35d0983b0b01565 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 23 Feb 2025 20:48:49 -0500 Subject: [PATCH 7/7] firefox: remove use of passthru.applicationName in wrapper code Signed-off-by: Ihar Hrachyshka --- pkgs/applications/networking/browsers/firefox/wrapper.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index bd28a3abdd12..0485329544a5 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -25,7 +25,7 @@ browser: let isDarwin = stdenv.hostPlatform.isDarwin; wrapper = - { applicationName ? browser.binaryName or (lib.getName browser) # Note: this is actually *binary* name and is different from browser.passthru.applicationName, which is *app* name! + { 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 , nameSuffix ? "" @@ -164,7 +164,7 @@ let name = launcherName; exec = "${launcherName} --name ${wmClass} %U"; inherit icon; - desktopName = browser.passthru.applicationName; + desktopName = browser.applicationName; startupNotify = true; startupWMClass = wmClass; terminal = false; @@ -280,7 +280,7 @@ let ]) allNativeMessagingHosts); buildCommand = let - appPath = "Applications/${browser.passthru.applicationName}.app"; + appPath = "Applications/${browser.applicationName}.app"; executablePrefix = if isDarwin then "${appPath}/Contents/MacOS" else "bin"; executablePath="${executablePrefix}/${applicationName}"; finalBinaryPath = "${executablePath}" + lib.optionalString (!isDarwin) "${nameSuffix}";