From 0349c426880192d98f79a61a3e3bf2fdc81e952c Mon Sep 17 00:00:00 2001 From: Mikilio Date: Fri, 17 Oct 2025 13:49:57 +0200 Subject: [PATCH] mkFirefox: add policy to accept added extensions This commit adds extensions added via profiles..extensions.packages to the policy. In consequence the extensions are added without complaint and don't need to be enabled manually. --- modules/programs/firefox/mkFirefoxModule.nix | 62 ++++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/modules/programs/firefox/mkFirefoxModule.nix b/modules/programs/firefox/mkFirefoxModule.nix index f7ebb6ab5..aea8b88bf 100644 --- a/modules/programs/firefox/mkFirefoxModule.nix +++ b/modules/programs/firefox/mkFirefoxModule.nix @@ -363,7 +363,11 @@ in inherit visible; type = types.attrsOf ( types.submodule ( - { config, name, ... }: + { + config, + name, + ... + }: let profilePath = modulePath ++ [ "profiles" @@ -889,7 +893,10 @@ in ] ) config.extensions.packages) ++ (builtins.concatMap ( - { name, value }: + { + name, + value, + }: let packages = builtins.filter (pkg: (pkg.addonId or pkg.name) == name) config.extensions.packages; in @@ -990,7 +997,6 @@ in ''; targets.darwin.defaults = ( mkIf (cfg.darwinDefaultsId != null && isDarwin) { - ${cfg.darwinDefaultsId} = { EnterprisePoliciesEnabled = true; } @@ -1055,19 +1061,6 @@ in force = profile.search.force; source = profile.search.file; }; - - "${cfg.profilesPath}/${profile.path}/extensions" = mkIf (profile.extensions.packages != [ ]) { - source = - let - extensionsEnvPkg = pkgs.buildEnv { - name = "hm-firefox-extensions"; - paths = profile.extensions.packages; - }; - in - "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; - recursive = true; - force = true; - }; } (mkMerge ( @@ -1093,15 +1086,34 @@ in NoDefaultBookmarks = lib.mkIf (builtins.any (profile: profile.bookmarks.enable) ( builtins.attrValues cfg.profiles )) false; - ExtensionSettings = lib.mkIf (cfg.languagePacks != [ ]) ( - lib.listToAttrs ( - map ( - lang: - lib.nameValuePair "langpack-${lang}@firefox.mozilla.org" { - installation_mode = "normal_installed"; - install_url = "https://releases.mozilla.org/pub/firefox/releases/${cfg.release}/linux-x86_64/xpi/${lang}.xpi"; - } - ) cfg.languagePacks + ExtensionSettings = mkMerge ( + [ + (lib.mkIf (cfg.languagePacks != [ ]) ( + lib.listToAttrs ( + map ( + lang: + lib.nameValuePair "langpack-${lang}@firefox.mozilla.org" { + installation_mode = "normal_installed"; + install_url = "https://releases.mozilla.org/pub/firefox/releases/${cfg.release}/linux-x86_64/xpi/${lang}.xpi"; + } + ) cfg.languagePacks + ) + )) + ] + ++ lib.flip mapAttrsToList cfg.profiles ( + _: profile: + lib.listToAttrs ( + map ( + pkg: + if pkg ? addonId then + lib.nameValuePair pkg.addonId { + installation_mode = "force_installed"; + install_url = "file://${pkg.outPath}/share/mozilla/${extensionPath}/${pkg.addonId}.xpi"; + } + else + { } + ) profile.extensions.packages + ) ) ); };