thunderbird-bin: support darwin platforms

This commit is contained in:
Vinicius Deolindo
2025-10-16 11:57:50 -03:00
parent 1ebe182057
commit c8fc22bc2a
3 changed files with 170 additions and 63 deletions
@@ -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;
}
@@ -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
;
}
@@ -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;
}