firefox: add languagePacks option

Port the programs.firefox.languagePacks option from NixOS
This commit is contained in:
Cezary Drożak 2024-03-27 19:18:49 +01:00 committed by Robert Helgesson
parent af70fc502a
commit 304a011325
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -262,6 +262,18 @@ in {
''; '';
}; };
languagePacks = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
The language packs to install. Available language codes can be found
on the releases page:
`https://releases.mozilla.org/pub/firefox/releases/''${version}/linux-x86_64/xpi/`,
replacing `''${version}` with the version of Firefox you have.
'';
example = [ "en-GB" "de" ];
};
nativeMessagingHosts = mkOption { nativeMessagingHosts = mkOption {
type = types.listOf types.package; type = types.listOf types.package;
default = [ ]; default = [ ];
@ -736,6 +748,14 @@ in {
message = "Container id must be smaller than 4294967294 (2^32 - 2)"; message = "Container id must be smaller than 4294967294 (2^32 - 2)";
}) })
{
assertion = cfg.languagePacks == [ ] || cfg.package != null;
message = ''
'programs.firefox.languagePacks' requires 'programs.firefox.package'
to be set to a non-null value.
'';
}
(mkNoDuplicateAssertion cfg.profiles "profile") (mkNoDuplicateAssertion cfg.profiles "profile")
] ++ (mapAttrsToList ] ++ (mapAttrsToList
(_: profile: mkNoDuplicateAssertion profile.containers "container") (_: profile: mkNoDuplicateAssertion profile.containers "container")
@ -750,6 +770,15 @@ in {
programs.firefox.finalPackage = wrapPackage cfg.package; programs.firefox.finalPackage = wrapPackage cfg.package;
programs.firefox.policies = {
ExtensionSettings = listToAttrs (map (lang:
nameValuePair "langpack-${lang}@firefox.mozilla.org" {
installation_mode = "normal_installed";
install_url =
"https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/${lang}.xpi";
}) cfg.languagePacks);
};
home.packages = lib.optional (cfg.finalPackage != null) cfg.finalPackage; home.packages = lib.optional (cfg.finalPackage != null) cfg.finalPackage;
home.file = mkMerge ([{ home.file = mkMerge ([{