9 cfg = config.programs.firefox;
11 policyFormat = pkgs.formats.json { };
14 When this option is in use, Firefox will inform you that "your browser
15 is managed by your organisation". That message appears because NixOS
16 installs what you have declared here such that it cannot be overridden
17 through the user interface. It does not mean that someone else has been
18 given control of your browser, unless of course they also control your
22 # deprecated per-native-messaging-host options
26 package = pkgs.browserpass;
30 package = pkgs.bukubrow;
34 package = pkgs.web-eid-app;
38 package = pkgs.ff2mpv;
42 package = pkgs.fx-cast-bridge;
46 package = pkgs.gnomeExtensions.gsconnect;
50 package = pkgs.jabref;
54 package = pkgs.passff-host;
58 package = pkgs.tridactyl-native;
61 name = "Uget Integrator";
62 package = pkgs.uget-integrator;
67 options.programs.firefox = {
68 enable = lib.mkEnableOption "the Firefox web browser";
70 package = lib.mkOption {
71 type = lib.types.package;
72 default = pkgs.firefox;
73 description = "Firefox package to use.";
74 defaultText = lib.literalExpression "pkgs.firefox";
79 "firefox-devedition-bin"
84 wrapperConfig = lib.mkOption {
85 type = lib.types.attrs;
87 description = "Arguments to pass to Firefox wrapper";
90 policies = lib.mkOption {
91 type = policyFormat.type;
94 Group policies to install.
96 See [Mozilla's documentation](https://mozilla.github.io/policy-templates/)
97 for a list of available options.
99 This can be used to install extensions declaratively! Check out the
100 documentation of the `ExtensionSettings` policy for details.
106 preferences = lib.mkOption {
116 Preferences to set from `about:config`.
118 Some of these might be able to be configured more ergonomically
125 preferencesStatus = lib.mkOption {
126 type = lib.types.enum [
134 The status of `firefox.preferences`.
136 `status` can assume the following values:
137 - `"default"`: Preferences appear as default.
138 - `"locked"`: Preferences appear as default and can't be changed.
139 - `"user"`: Preferences appear as changed.
140 - `"clear"`: Value has no effect. Resets to factory defaults on each startup.
144 languagePacks = lib.mkOption {
145 # Available languages can be found in https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/
146 type = lib.types.listOf (
255 The language packs to install.
259 autoConfig = lib.mkOption {
260 type = lib.types.lines;
263 AutoConfig files can be used to set and lock preferences that are not covered
264 by the policies.json for Mac and Linux. This method can be used to automatically
265 change user preferences or prevent the end user from modifiying specific
266 preferences by locking them. More info can be found in https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig.
270 autoConfigFiles = lib.mkOption {
271 type = with lib.types; listOf path;
274 AutoConfig files can be used to set and lock preferences that are not covered
275 by the policies.json for Mac and Linux. This method can be used to automatically
276 change user preferences or prevent the end user from modifiying specific
277 preferences by locking them. More info can be found in https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig.
279 Files are concated and autoConfig is appended.
283 nativeMessagingHosts = ({
284 packages = lib.mkOption {
285 type = lib.types.listOf lib.types.package;
288 Additional packages containing native messaging hosts that should be made available to Firefox extensions.
291 }) // (builtins.mapAttrs (k: v: lib.mkEnableOption "${v.name} support") nmhOptions);
299 lib.mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions
302 lib.mkIf cfg.enable {
303 warnings = forEachEnabledNmh (
305 "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, "
306 + "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead."
308 programs.firefox.nativeMessagingHosts.packages = forEachEnabledNmh (_: v: v.package);
310 environment.systemPackages = [
311 (cfg.package.override (old: {
313 old.extraPrefsFiles or [ ]
314 ++ cfg.autoConfigFiles
315 ++ [ (pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig) ];
316 nativeMessagingHosts = old.nativeMessagingHosts or [ ] ++ cfg.nativeMessagingHosts.packages;
317 cfg = (old.cfg or { }) // cfg.wrapperConfig;
323 policiesJSON = policyFormat.generate "firefox-policies.json" { inherit (cfg) policies; };
325 lib.mkIf (cfg.policies != { }) {
326 "firefox/policies/policies.json".source = "${policiesJSON}";
329 # Preferences are converted into a policy
330 programs.firefox.policies = {
331 DisableAppUpdate = true;
333 builtins.mapAttrs (_: value: {
335 Status = cfg.preferencesStatus;
338 ExtensionSettings = builtins.listToAttrs (
341 lib.attrsets.nameValuePair "langpack-${lang}@firefox.mozilla.org" {
342 installation_mode = "normal_installed";
343 install_url = "https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/${lang}.xpi";
350 meta.maintainers = with lib.maintainers; [