···77```nix
88{
99 myFirefox = wrapFirefox firefox-unwrapped {
1010- extraExtensions = [
1010+ nixExtensions = [
1111 (fetchFirefoxAddon {
1212 name = "ublock";
1313 url = "https://addons.mozilla.org/firefox/downloads/file/3679754/ublock_origin-1.31.0-an+fx.xpi";
···3838 };
3939}
4040```
4141+4242+If `nixExtensions != null` then all manually installed addons will be uninstalled from your browser profile.
4343+To view available enterprise policies visit [enterprise policies](https://github.com/mozilla/policy-templates#enterprisepoliciesenabled)
4444+or type into the Firefox url bar: `about:policies#documentation`.
4545+Nix installed addons do not have a valid signature, which is why signature verification is disabled. This does not compromise security because downloaded addons are checksumed and manual addons can't be installed.
4646+4747+# Troubleshooting
4848+If addons do not appear installed although they have been defined in your nix configuration file reset the local addon state of your Firefox profile by clicking `help -> restart with addons disabled -> restart -> refresh firefox`. This can happen if you switch from manual addon mode to nix addon mode and then back to manual mode and then again to nix addon mode.
4949+
···4141 # https://github.com/mozilla/policy-templates#enterprisepoliciesenabled
4242 , extraPolicies ? {}
4343 , firefoxLibName ? "firefox" # Important for tor package or the like
4444- , extraExtensions ? [ ]
4444+ , nixExtensions ? null
4545 }:
46464747 assert forceWayland -> (browser ? gtk3); # Can only use the wayland backend if gtk3 is being used
···100100 policiesJson = builtins.toFile "policies.json"
101101 (builtins.toJSON enterprisePolicies);
102102103103+ usesNixExtensions = nixExtensions != null;
104104+103105 extensions = builtins.map (a:
104106 if ! (builtins.hasAttr "extid" a) then
105105- throw "extraExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
107107+ throw "nixExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
106108 else
107109 a
108108- ) extraExtensions;
110110+ ) (if usesNixExtensions then nixExtensions else []);
109111110112 enterprisePolicies =
111113 {
112112- policies = {
114114+ policies = lib.optionalAttrs usesNixExtensions {
113115 DisableAppUpdate = true;
114116 } //
115115- {
117117+ lib.optionalAttrs usesNixExtensions {
116118 ExtensionSettings = {
117119 "*" = {
118120 blocked_install_message = "You can't have manual extension mixed with nix extensions";
···137139 // to be able to install addons that do not have an extid
138140 // Security is maintained because only user whitelisted addons
139141 // with a checksum can be installed
140140- lockPref("xpinstall.signatures.required", false);
142142+ ${ lib.optionalString usesNixExtensions ''lockPref("xpinstall.signatures.required", false)'' };
141143 ${extraPrefs}
142144 '';
143145