Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thunderbird: add native host support #6292

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion modules/programs/thunderbird.nix
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ let
'') prefs)}
${extraPrefs}
'';

nativeMessagingHostsPath = if isDarwin then
"${cfg.vendorPath}/NativeMessagingHosts"
else
"${cfg.vendorPath}/native-messaging-hosts";

nativeMessagingHostsJoined = pkgs.symlinkJoin {
name = "th_native-messaging-hosts";
paths = [
# Link a .keep file to keep the directory around
(pkgs.writeTextDir "lib/mozilla/native-messaging-hosts/.keep" "")
# Link package configured native messaging hosts (entire mail app actually)
cfg.package
]
# Link user configured native messaging hosts
++ cfg.nativeMessagingHosts;
};

in {
meta.maintainers = with hm.maintainers; [ d-dervishi jkarlson ];

Expand All @@ -158,6 +176,29 @@ in {
description = "profile version, set null for nix-darwin";
};

vendorPath = mkOption {
internal = true;
type = with types; nullOr str;
# Thunderbird doesn't look in `Application Support` on macOS for user
# config (in contrast to global settings that are the same for Firefox
# and Thunderbird):
# https://developer.thunderbird.net/add-ons/mailextensions/supported-webextension-api
default = if isDarwin then "Library/Mozilla" else ".mozilla";
example = ".mozilla";
description =
"Directory containing the native messaging hosts directory.";
};

nativeMessagingHosts = optionalAttrs (cfg.vendorPath != null) (mkOption {
visible = true;
type = types.listOf types.package;
default = [ ];
description = ''
Additional packages containing native messaging hosts that should be
made available to Thunderbird extensions.
'';
});

profiles = mkOption {
type = with types;
attrsOf (submodule ({ config, name, ... }: {
Expand Down Expand Up @@ -403,7 +444,13 @@ in {
home.file = mkMerge ([{
"${thunderbirdConfigPath}/profiles.ini" =
mkIf (cfg.profiles != { }) { text = generators.toINI { } profilesIni; };
}] ++ flip mapAttrsToList cfg.profiles (name: profile: {
}] ++ optional (cfg.vendorPath != null) {
"${nativeMessagingHostsPath}" = {
source =
"${nativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts";
recursive = true;
};
} ++ flip mapAttrsToList cfg.profiles (name: profile: {
"${thunderbirdProfilesPath}/${name}/chrome/userChrome.css" =
mkIf (profile.userChrome != "") { text = profile.userChrome; };

Expand Down
Loading