From c43d4a3d6d9ef8ddbe2438362f5c775b4186000b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 5 Feb 2023 23:53:25 +0100 Subject: [PATCH] firefox: manage add-ons per-profile Internally we already managed them per-profile but exposed a global option to maintain backwards compatibility. The benefit to having per-profile extensions is quite large though, so it is time to switch. Users of the global extensions option will get an error message that indicates how to edit their configuration to work again. --- docs/release-notes/rl-2305.adoc | 11 +++- modules/programs/firefox.nix | 91 ++++++++++++++++----------------- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/docs/release-notes/rl-2305.adoc b/docs/release-notes/rl-2305.adoc index 6d16e784..befd1b64 100644 --- a/docs/release-notes/rl-2305.adoc +++ b/docs/release-notes/rl-2305.adoc @@ -8,7 +8,16 @@ This is the current unstable branch and the information in this section is there This release has the following notable changes: -* No highlights. +* Firefox add-ons are now managed per-profile. +That is, if you are currently having ++ +[source,nix] +programs.firefox.extensions = [ foo bar ]; ++ +in your configuration then you must change it to ++ +[source,nix] +programs.firefox.profiles.myprofile.extensions = [ foo bar ]; [[sec-release-23.05-state-version-changes]] === State Version Changes diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 4b3f288c..7eb06465 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -25,11 +25,6 @@ let # by future Firefox versions. extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; - extensionsEnvPkg = pkgs.buildEnv { - name = "hm-firefox-extensions"; - paths = cfg.extensions; - }; - profiles = flip mapAttrs' cfg.profiles (_: profile: nameValuePair "Profile${toString profile.id}" { Name = profile.name; @@ -117,6 +112,15 @@ in { meta.maintainers = [ maintainers.rycee maintainers.kira-bruneau ]; imports = [ + (mkRemovedOptionModule [ "programs" "firefox" "extensions" ] '' + + Extensions are now managed per-profile. That is, change from + + programs.firefox.extensions = [ foo bar ]; + + to + + programs.firefox.profiles.myprofile.extensions = [ foo bar ];'') (mkRemovedOptionModule [ "programs" "firefox" "enableAdobeFlash" ] "Support for this option has been removed.") (mkRemovedOptionModule [ "programs" "firefox" "enableGoogleTalk" ] @@ -154,41 +158,6 @@ in { ''; }; - extensions = mkOption { - type = types.listOf types.package; - default = [ ]; - example = literalExpression '' - with pkgs.nur.repos.rycee.firefox-addons; [ - privacy-badger - ] - ''; - description = '' - List of Firefox add-on packages to install. Some - pre-packaged add-ons are accessible from NUR, - . - Once you have NUR installed run - - - $ nix-env -f '<nixpkgs>' -qaP -A nur.repos.rycee.firefox-addons - - - to list the available Firefox add-ons. - - - - Note that it is necessary to manually enable these - extensions inside Firefox after the first installation. - - - - Extensions listed here will only be available in Firefox - profiles managed through the - - option. This is due to recent changes in the way Firefox - handles extension side-loading. - ''; - }; - profiles = mkOption { type = types.attrsOf (types.submodule ({ config, name, ... }: { options = { @@ -452,6 +421,34 @@ in { ''; }; }; + + extensions = mkOption { + type = types.listOf types.package; + default = [ ]; + example = literalExpression '' + with pkgs.nur.repos.rycee.firefox-addons; [ + privacy-badger + ] + ''; + description = '' + List of Firefox add-on packages to install for this profile. + Some pre-packaged add-ons are accessible from NUR, + . + Once you have NUR installed run + + + $ nix-env -f '<nixpkgs>' -qaP -A nur.repos.rycee.firefox-addons + + + to list the available Firefox add-ons. + + + + Note that it is necessary to manually enable these extensions + inside Firefox after the first installation. + ''; + }; + }; })); default = { }; @@ -523,11 +520,6 @@ in { in [ package ]; home.file = mkMerge ([{ - "${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != [ ]) { - source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; - recursive = true; - }; - "${firefoxConfigPath}/profiles.ini" = mkIf (cfg.profiles != { }) { text = profilesIni; }; }] ++ flip mapAttrsToList cfg.profiles (_: profile: { @@ -674,8 +666,13 @@ in { }; "${profilesPath}/${profile.path}/extensions" = - mkIf (cfg.extensions != [ ]) { - source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; + mkIf (profile.extensions != [ ]) { + source = let + extensionsEnvPkg = pkgs.buildEnv { + name = "hm-firefox-extensions"; + paths = profile.extensions; + }; + in "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; recursive = true; force = true; };