From c8fc22bc2aca1ec9690a9c087ff62d69c3c0cc94 Mon Sep 17 00:00:00 2001 From: Vinicius Deolindo Date: Tue, 7 Oct 2025 21:27:07 -0300 Subject: [PATCH] thunderbird-bin: support darwin platforms --- .../mailreaders/thunderbird-bin/darwin.nix | 36 +++++ .../mailreaders/thunderbird-bin/default.nix | 127 +++++++++--------- .../mailreaders/thunderbird-bin/linux.nix | 70 ++++++++++ 3 files changed, 170 insertions(+), 63 deletions(-) create mode 100644 pkgs/applications/networking/mailreaders/thunderbird-bin/darwin.nix create mode 100644 pkgs/applications/networking/mailreaders/thunderbird-bin/linux.nix diff --git a/pkgs/applications/networking/mailreaders/thunderbird-bin/darwin.nix b/pkgs/applications/networking/mailreaders/thunderbird-bin/darwin.nix new file mode 100644 index 000000000000..3e2197c84b48 --- /dev/null +++ b/pkgs/applications/networking/mailreaders/thunderbird-bin/darwin.nix @@ -0,0 +1,36 @@ +{ + pname, + version, + src, + nativeBuildInputs, + passthru, + meta, + stdenv, + undmg, +}: + +stdenv.mkDerivation { + inherit + pname + version + src + ; + + sourceRoot = "."; + + nativeBuildInputs = nativeBuildInputs ++ [ undmg ]; + + # don't break code signing + dontFixup = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/Applications + mv Thunderbird*.app "$out/Applications/${passthru.applicationName}.app" + + runHook postInstall + ''; + + inherit passthru meta; +} diff --git a/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix b/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix index 06377f89c6fe..16602868fda4 100644 --- a/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix +++ b/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix @@ -10,12 +10,9 @@ fetchurl, config, wrapGAppsHook3, - autoPatchelfHook, - alsa-lib, curl, gtk3, writeScript, - writeText, xidel, coreutils, gnused, @@ -23,18 +20,29 @@ gnupg, runtimeShell, systemLocale ? config.i18n.defaultLocale or "en_US", - patchelfUnstable, # have to use patchelfUnstable to support --no-clobber-old-sections generated, versionSuffix ? "", applicationName ? "Thunderbird", + # linux dependencies + writeText, + autoPatchelfHook, + patchelfUnstable, + alsa-lib, + # darwin dependencies + undmg, }: let inherit (generated) version sources; + pname = "thunderbird-bin"; + mozillaPlatforms = { i686-linux = "linux-i686"; x86_64-linux = "linux-x86_64"; + # bundles are universal and can be re-used for both darwin architectures + aarch64-darwin = "mac"; + x86_64-darwin = "mac"; }; arch = mozillaPlatforms.${stdenv.hostPlatform.system}; @@ -43,12 +51,6 @@ let sourceMatches = locale: source: (isPrefixOf source.locale locale) && source.arch == arch; - policies = { - DisableAppUpdate = true; - } - // config.thunderbird.policies or { }; - policiesJson = writeText "thunderbird-policies.json" (builtins.toJSON { inherit policies; }); - defaultSource = lib.findFirst (sourceMatches "en-US") { } sources; mozLocale = @@ -59,50 +61,23 @@ let source = lib.findFirst (sourceMatches mozLocale) defaultSource sources; - pname = "thunderbird-bin"; -in - -stdenv.mkDerivation { - inherit pname version; - src = fetchurl { inherit (source) url sha256; }; - nativeBuildInputs = [ - wrapGAppsHook3 - autoPatchelfHook - patchelfUnstable - ]; - buildInputs = [ - alsa-lib - ]; - # Thunderbird uses "relrhack" to manually process relocations from a fixed offset - patchelfFlags = [ "--no-clobber-old-sections" ]; + meta = { + changelog = "https://www.thunderbird.net/en-US/thunderbird/${version}/releasenotes/"; + description = "Mozilla Thunderbird, a full-featured email client (binary package)"; + homepage = "http://www.mozilla.org/thunderbird/"; + mainProgram = "thunderbird"; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + license = lib.licenses.mpl20; + maintainers = with lib.maintainers; [ lovesegfault ]; + platforms = builtins.attrNames mozillaPlatforms; + hydraPlatforms = [ ]; + }; - patchPhase = '' - # Don't download updates from Mozilla directly - echo 'pref("app.update.auto", "false");' >> defaults/pref/channel-prefs.js - ''; - - installPhase = '' - mkdir -p "$prefix/usr/lib/thunderbird-bin-${version}" - cp -r * "$prefix/usr/lib/thunderbird-bin-${version}" - - mkdir -p "$out/bin" - ln -s "$prefix/usr/lib/thunderbird-bin-${version}/thunderbird" "$out/bin/" - - # wrapThunderbird expects "$out/lib" instead of "$out/usr/lib" - ln -s "$out/usr/lib" "$out/lib" - - gappsWrapperArgs+=(--argv0 "$out/bin/.thunderbird-wrapped") - - # See: https://github.com/mozilla/policy-templates/blob/master/README.md - mkdir -p "$out/lib/thunderbird-bin-${version}/distribution"; - ln -s ${policiesJson} "$out/lib/thunderbird-bin-${version}/distribution/policies.json"; - ''; - - passthru.updateScript = import ./../../browsers/firefox-bin/update.nix { + updateScript = import ./../../browsers/firefox-bin/update.nix { inherit pname writeScript @@ -120,22 +95,48 @@ stdenv.mkDerivation { baseUrl = "http://archive.mozilla.org/pub/thunderbird/releases/"; }; + nativeBuildInputs = [ + wrapGAppsHook3 + ]; + passthru = { - inherit applicationName; + inherit + applicationName + updateScript + gtk3 + ; binaryName = "thunderbird"; gssSupport = true; - gtk3 = gtk3; }; - meta = { - changelog = "https://www.thunderbird.net/en-US/thunderbird/${version}/releasenotes/"; - description = "Mozilla Thunderbird, a full-featured email client (binary package)"; - homepage = "http://www.mozilla.org/thunderbird/"; - mainProgram = "thunderbird"; - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - license = lib.licenses.mpl20; - maintainers = with lib.maintainers; [ lovesegfault ]; - platforms = builtins.attrNames mozillaPlatforms; - hydraPlatforms = [ ]; - }; -} +in +if stdenv.hostPlatform.isDarwin then + import ./darwin.nix { + inherit + pname + version + src + nativeBuildInputs + passthru + meta + stdenv + undmg + ; + } +else + import ./linux.nix { + inherit + pname + version + src + nativeBuildInputs + passthru + meta + stdenv + config + writeText + autoPatchelfHook + patchelfUnstable + alsa-lib + ; + } diff --git a/pkgs/applications/networking/mailreaders/thunderbird-bin/linux.nix b/pkgs/applications/networking/mailreaders/thunderbird-bin/linux.nix new file mode 100644 index 000000000000..d94874055d43 --- /dev/null +++ b/pkgs/applications/networking/mailreaders/thunderbird-bin/linux.nix @@ -0,0 +1,70 @@ +{ + pname, + version, + src, + nativeBuildInputs, + passthru, + meta, + stdenv, + config, + writeText, + autoPatchelfHook, + patchelfUnstable, + alsa-lib, +}: + +let + policies = { + DisableAppUpdate = true; + } + // config.thunderbird.policies or { }; + + policiesJson = writeText "thunderbird-policies.json" (builtins.toJSON { inherit policies; }); +in +stdenv.mkDerivation { + inherit + pname + version + src + ; + + nativeBuildInputs = nativeBuildInputs ++ [ + autoPatchelfHook + patchelfUnstable + ]; + + buildInputs = [ + alsa-lib + ]; + + # Thunderbird uses "relrhack" to manually process relocations from a fixed offset + patchelfFlags = [ "--no-clobber-old-sections" ]; + + postPatch = '' + # Don't download updates from Mozilla directly + echo 'pref("app.update.auto", "false");' >> defaults/pref/channel-prefs.js + ''; + + installPhase = '' + runHook preInstall + + mkdir -p "$prefix/usr/lib/thunderbird-bin-${version}" + cp -r * "$prefix/usr/lib/thunderbird-bin-${version}" + + mkdir -p "$out/bin" + ln -s "$prefix/usr/lib/thunderbird-bin-${version}/thunderbird" "$out/bin/" + + # wrapThunderbird expects "$out/lib" instead of "$out/usr/lib" + ln -s "$out/usr/lib" "$out/lib" + + gappsWrapperArgs+=(--argv0 "$out/bin/.thunderbird-wrapped") + + # See: https://github.com/mozilla/policy-templates/blob/master/README.md + mkdir -p "$out/lib/thunderbird-bin-${version}/distribution"; + ln -s ${policiesJson} "$out/lib/thunderbird-bin-${version}/distribution/policies.json"; + + runHook postInstall + ''; + + inherit passthru meta; +}