1 { pkgs, config, lib, ... }:
6 cfg = config.programs.firefox;
8 policyFormat = pkgs.formats.json { };
11 When this option is in use, Firefox will inform you that "your browser
12 is managed by your organisation". That message appears because NixOS
13 installs what you have declared here such that it cannot be overridden
14 through the user interface. It does not mean that someone else has been
15 given control of your browser, unless of course they also control your
19 # deprecated per-native-messaging-host options
23 package = pkgs.browserpass;
27 package = pkgs.bukubrow;
31 package = pkgs.web-eid-app;
35 package = pkgs.ff2mpv;
39 package = pkgs.fx-cast-bridge;
43 package = pkgs.gnomeExtensions.gsconnect;
47 package = pkgs.jabref;
51 package = pkgs.passff-host;
55 package = pkgs.tridactyl-native;
58 name = "Uget Integrator";
59 package = pkgs.uget-integrator;
64 options.programs.firefox = {
65 enable = mkEnableOption (mdDoc "the Firefox web browser");
69 default = pkgs.firefox;
70 description = mdDoc "Firefox package to use.";
71 defaultText = literalExpression "pkgs.firefox";
76 "firefox-devedition-bin"
81 wrapperConfig = mkOption {
84 description = mdDoc "Arguments to pass to Firefox wrapper";
88 type = policyFormat.type;
90 description = mdDoc ''
91 Group policies to install.
93 See [Mozilla's documentation](https://mozilla.github.io/policy-templates/)
94 for a list of available options.
96 This can be used to install extensions declaratively! Check out the
97 documentation of the `ExtensionSettings` policy for details.
103 preferences = mkOption {
104 type = with types; attrsOf (oneOf [ bool int str ]);
106 description = mdDoc ''
107 Preferences to set from `about:config`.
109 Some of these might be able to be configured more ergonomically
116 preferencesStatus = mkOption {
117 type = types.enum [ "default" "locked" "user" "clear" ];
119 description = mdDoc ''
120 The status of `firefox.preferences`.
122 `status` can assume the following values:
123 - `"default"`: Preferences appear as default.
124 - `"locked"`: Preferences appear as default and can't be changed.
125 - `"user"`: Preferences appear as changed.
126 - `"clear"`: Value has no effect. Resets to factory defaults on each startup.
130 languagePacks = mkOption {
131 # Available languages can be found in https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/
132 type = types.listOf (types.enum ([
233 description = mdDoc ''
234 The language packs to install.
238 autoConfig = mkOption {
241 description = mdDoc ''
242 AutoConfig files can be used to set and lock preferences that are not covered
243 by the policies.json for Mac and Linux. This method can be used to automatically
244 change user preferences or prevent the end user from modifiying specific
245 preferences by locking them. More info can be found in https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig.
249 nativeMessagingHosts = ({
250 packages = mkOption {
251 type = types.listOf types.package;
253 description = mdDoc ''
254 Additional packages containing native messaging hosts that should be made available to Firefox extensions.
257 }) // (mapAttrs (k: v: mkEnableOption (mdDoc "${v.name} support")) nmhOptions);
261 forEachEnabledNmh = fn: flatten (mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions);
263 warnings = forEachEnabledNmh (k: v:
264 "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " +
265 "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead."
267 programs.firefox.nativeMessagingHosts.packages = forEachEnabledNmh (_: v: v.package);
269 environment.systemPackages = [
270 (cfg.package.override (old: {
271 extraPrefsFiles = old.extraPrefsFiles or [] ++ [(pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig)];
272 nativeMessagingHosts = old.nativeMessagingHosts or [] ++ cfg.nativeMessagingHosts.packages;
273 cfg = (old.cfg or {}) // cfg.wrapperConfig;
279 policiesJSON = policyFormat.generate "firefox-policies.json" { inherit (cfg) policies; };
281 mkIf (cfg.policies != { }) {
282 "firefox/policies/policies.json".source = "${policiesJSON}";
285 # Preferences are converted into a policy
286 programs.firefox.policies = {
287 Preferences = (mapAttrs
288 (_: value: { Value = value; Status = cfg.preferencesStatus; })
290 ExtensionSettings = listToAttrs (map
292 "langpack-${lang}@firefox.mozilla.org"
294 installation_mode = "normal_installed";
295 install_url = "https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/${lang}.xpi";
302 meta.maintainers = with maintainers; [ danth ];