From 4d680ee96fe1b698e75804cf655c365ea4ec5433 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sat, 2 Nov 2024 13:56:43 -0400 Subject: [PATCH] thunderbird: Implement `extensions` for profiles Closes: #5654 --- modules/programs/thunderbird.nix | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/programs/thunderbird.nix b/modules/programs/thunderbird.nix index ad7a1360f..3d3e85de1 100644 --- a/modules/programs/thunderbird.nix +++ b/modules/programs/thunderbird.nix @@ -12,6 +12,11 @@ let "Thunderbird preference (int, bool, string, and also attrs, list, float as a JSON string)"; }; + # The extensions path shared by all profiles. + extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; + + moduleName = "programs.thunderbird"; + enabledAccounts = attrValues (filterAttrs (_: a: a.thunderbird.enable) config.accounts.email.accounts); @@ -239,6 +244,27 @@ in { default = { }; description = "Declarative search engine configuration."; }; + + extensions = mkOption { + type = types.listOf types.package; + default = [ ]; + example = literalExpression '' + [ + pkgs.some-thunderbird-extension + ] + ''; + description = '' + List of ${name} add-on packages to install for this profile. + + Note that it is necessary to manually enable extensions + inside ${name} after the first installation. + + To automatically enable extensions add + `"extensions.autoDisableScopes" = 0;` + to + [{option}`${moduleName}.profiles..settings`](#opt-${moduleName}.profiles._name_.settings) + ''; + }; }; })); description = "Attribute set of Thunderbird profiles."; @@ -414,6 +440,18 @@ in { force = profile.search.force; source = profile.search.file; }; + + "${thunderbirdProfilesPath}/${name}/extensions" = + mkIf (profile.extensions != [ ]) { + source = let + extensionsEnvPkg = pkgs.buildEnv { + name = "hm-thunderbird-extensions"; + paths = profile.extensions; + }; + in "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; + recursive = true; + force = true; + }; })); }; }