Skip to content

Commit

Permalink
firefox: add languagePacks option
Browse files Browse the repository at this point in the history
Port the programs.firefox.languagePacks option from NixOS
  • Loading branch information
cezdro authored and rycee committed Jul 24, 2024
1 parent af70fc5 commit 304a011
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/programs/firefox.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
type = types.listOf types.package;
default = [ ];
Expand Down Expand Up @@ -736,6 +748,14 @@ in {
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")
] ++ (mapAttrsToList
(_: profile: mkNoDuplicateAssertion profile.containers "container")
Expand All @@ -750,6 +770,15 @@ in {

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.file = mkMerge ([{
Expand Down

0 comments on commit 304a011

Please sign in to comment.