1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-16 22:11:07 +01:00

mkFirefox: add policy to accept added extensions

This commit adds extensions added via
profiles.<name>.extensions.packages to the policy.
In consequence the extensions are added without complaint and don't need
to be enabled manually.
This commit is contained in:
Mikilio 2025-10-17 13:49:57 +02:00
parent 722792af09
commit 0349c42688
No known key found for this signature in database
GPG key ID: 0C159FAB320FEB35

View file

@ -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
)
)
);
};