Loading nixos/modules/programs/firefox.nix +196 −149 Original line number Diff line number Diff line { pkgs, config, lib, ... }: { pkgs, config, lib, ... }: let cfg = config.programs.firefox; Loading Loading @@ -99,7 +104,13 @@ in }; preferences = lib.mkOption { type = with lib.types; attrsOf (oneOf [ bool int str ]); type = with lib.types; attrsOf (oneOf [ bool int str ]); default = { }; description = '' Preferences to set from `about:config`. Loading @@ -112,7 +123,12 @@ in }; preferencesStatus = lib.mkOption { type = lib.types.enum [ "default" "locked" "user" "clear" ]; type = lib.types.enum [ "default" "locked" "user" "clear" ]; default = "locked"; description = '' The status of `firefox.preferences`. Loading @@ -127,7 +143,8 @@ in languagePacks = lib.mkOption { # Available languages can be found in https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/ type = lib.types.listOf (lib.types.enum ([ type = lib.types.listOf ( lib.types.enum ([ "ach" "af" "an" Loading Loading @@ -231,7 +248,8 @@ in "xh" "zh-CN" "zh-TW" ])); ]) ); default = [ ]; description = '' The language packs to install. Loading @@ -249,6 +267,19 @@ in ''; }; autoConfigFiles = lib.mkOption { type = with lib.types; listOf path; default = [ ]; description = '' AutoConfig files can be used to set and lock preferences that are not covered by the policies.json for Mac and Linux. This method can be used to automatically change user preferences or prevent the end user from modifiying specific preferences by locking them. More info can be found in https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig. Files are concated and autoConfig is appended. ''; }; nativeMessagingHosts = ({ packages = lib.mkOption { type = lib.types.listOf lib.types.package; Loading @@ -260,18 +291,28 @@ in }) // (builtins.mapAttrs (k: v: lib.mkEnableOption "${v.name} support") nmhOptions); }; config = let forEachEnabledNmh = fn: lib.flatten (lib.mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions); in lib.mkIf cfg.enable { warnings = forEachEnabledNmh (k: v: "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " + "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead." config = let forEachEnabledNmh = fn: lib.flatten ( lib.mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions ); in lib.mkIf cfg.enable { warnings = forEachEnabledNmh ( k: v: "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " + "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead." ); programs.firefox.nativeMessagingHosts.packages = forEachEnabledNmh (_: v: v.package); environment.systemPackages = [ (cfg.package.override (old: { extraPrefsFiles = old.extraPrefsFiles or [] ++ [(pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig)]; extraPrefsFiles = old.extraPrefsFiles or [ ] ++ cfg.autoConfigFiles ++ [ (pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig) ]; nativeMessagingHosts = old.nativeMessagingHosts or [ ] ++ cfg.nativeMessagingHosts.packages; cfg = (old.cfg or { }) // cfg.wrapperConfig; })) Loading @@ -288,20 +329,26 @@ in # Preferences are converted into a policy programs.firefox.policies = { DisableAppUpdate = true; Preferences = (builtins.mapAttrs (_: value: { Value = value; Status = cfg.preferencesStatus; }) cfg.preferences); ExtensionSettings = builtins.listToAttrs (builtins.map (lang: lib.attrsets.nameValuePair "langpack-${lang}@firefox.mozilla.org" { Preferences = ( builtins.mapAttrs (_: value: { Value = value; Status = cfg.preferencesStatus; }) cfg.preferences ); ExtensionSettings = builtins.listToAttrs ( builtins.map ( lang: lib.attrsets.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); ) cfg.languagePacks ); }; }; meta.maintainers = with lib.maintainers; [ danth ]; meta.maintainers = with lib.maintainers; [ danth linsui ]; } Loading
nixos/modules/programs/firefox.nix +196 −149 Original line number Diff line number Diff line { pkgs, config, lib, ... }: { pkgs, config, lib, ... }: let cfg = config.programs.firefox; Loading Loading @@ -99,7 +104,13 @@ in }; preferences = lib.mkOption { type = with lib.types; attrsOf (oneOf [ bool int str ]); type = with lib.types; attrsOf (oneOf [ bool int str ]); default = { }; description = '' Preferences to set from `about:config`. Loading @@ -112,7 +123,12 @@ in }; preferencesStatus = lib.mkOption { type = lib.types.enum [ "default" "locked" "user" "clear" ]; type = lib.types.enum [ "default" "locked" "user" "clear" ]; default = "locked"; description = '' The status of `firefox.preferences`. Loading @@ -127,7 +143,8 @@ in languagePacks = lib.mkOption { # Available languages can be found in https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/ type = lib.types.listOf (lib.types.enum ([ type = lib.types.listOf ( lib.types.enum ([ "ach" "af" "an" Loading Loading @@ -231,7 +248,8 @@ in "xh" "zh-CN" "zh-TW" ])); ]) ); default = [ ]; description = '' The language packs to install. Loading @@ -249,6 +267,19 @@ in ''; }; autoConfigFiles = lib.mkOption { type = with lib.types; listOf path; default = [ ]; description = '' AutoConfig files can be used to set and lock preferences that are not covered by the policies.json for Mac and Linux. This method can be used to automatically change user preferences or prevent the end user from modifiying specific preferences by locking them. More info can be found in https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig. Files are concated and autoConfig is appended. ''; }; nativeMessagingHosts = ({ packages = lib.mkOption { type = lib.types.listOf lib.types.package; Loading @@ -260,18 +291,28 @@ in }) // (builtins.mapAttrs (k: v: lib.mkEnableOption "${v.name} support") nmhOptions); }; config = let forEachEnabledNmh = fn: lib.flatten (lib.mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions); in lib.mkIf cfg.enable { warnings = forEachEnabledNmh (k: v: "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " + "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead." config = let forEachEnabledNmh = fn: lib.flatten ( lib.mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions ); in lib.mkIf cfg.enable { warnings = forEachEnabledNmh ( k: v: "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " + "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead." ); programs.firefox.nativeMessagingHosts.packages = forEachEnabledNmh (_: v: v.package); environment.systemPackages = [ (cfg.package.override (old: { extraPrefsFiles = old.extraPrefsFiles or [] ++ [(pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig)]; extraPrefsFiles = old.extraPrefsFiles or [ ] ++ cfg.autoConfigFiles ++ [ (pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig) ]; nativeMessagingHosts = old.nativeMessagingHosts or [ ] ++ cfg.nativeMessagingHosts.packages; cfg = (old.cfg or { }) // cfg.wrapperConfig; })) Loading @@ -288,20 +329,26 @@ in # Preferences are converted into a policy programs.firefox.policies = { DisableAppUpdate = true; Preferences = (builtins.mapAttrs (_: value: { Value = value; Status = cfg.preferencesStatus; }) cfg.preferences); ExtensionSettings = builtins.listToAttrs (builtins.map (lang: lib.attrsets.nameValuePair "langpack-${lang}@firefox.mozilla.org" { Preferences = ( builtins.mapAttrs (_: value: { Value = value; Status = cfg.preferencesStatus; }) cfg.preferences ); ExtensionSettings = builtins.listToAttrs ( builtins.map ( lang: lib.attrsets.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); ) cfg.languagePacks ); }; }; meta.maintainers = with lib.maintainers; [ danth ]; meta.maintainers = with lib.maintainers; [ danth linsui ]; }