git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #105796 from Luis-Hebendanz/fix_firefox_wrapper

Fix firefox wrapper

commit29566ca0219041547322cefac408435a18a023b1 authorJörg Thalheim <Mic92@users.noreply.github.com> dateFri 4 Dec 2020, 17:01 (6 years ago) parent3a2fe56d3a6a12
2 files changed+18−7
doc/builders/packages/firefox.section.md+10−1 pkgs/applications/networking/browsers/firefox/wrapper.nix+8−6
doc/builders/packages/firefox.section.md+10−1
@@ -7,7 +7,7 @@ The `wrapFirefox` function allows to pass policies, preferences and extension th
77```nix
88{
99 myFirefox = wrapFirefox firefox-unwrapped {
10− extraExtensions = [
10+ nixExtensions = [
1111 (fetchFirefoxAddon {
1212 name = "ublock";
1313 url = "https://addons.mozilla.org/firefox/downloads/file/3679754/ublock_origin-1.31.0-an+fx.xpi";
@@ -38,3 +38,12 @@ The `wrapFirefox` function allows to pass policies, preferences and extension th
3838 };
3939}
4040```
41+
42+If `nixExtensions != null` then all manually installed addons will be uninstalled from your browser profile.
43+To view available enterprise policies visit [enterprise policies](https://github.com/mozilla/policy-templates#enterprisepoliciesenabled)
44+or type into the Firefox url bar: `about:policies#documentation`.
45+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.
46+
47+# Troubleshooting
48+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.
49+
pkgs/applications/networking/browsers/firefox/wrapper.nix+8−6
@@ -41,7 +41,7 @@ let
4141 # https://github.com/mozilla/policy-templates#enterprisepoliciesenabled
4242 , extraPolicies ? {}
4343 , firefoxLibName ? "firefox" # Important for tor package or the like
44− , extraExtensions ? [ ]
44+ , nixExtensions ? null
4545 }:
4646
4747 assert forceWayland -> (browser ? gtk3); # Can only use the wayland backend if gtk3 is being used
@@ -100,19 +100,21 @@ let
100100 policiesJson = builtins.toFile "policies.json"
101101 (builtins.toJSON enterprisePolicies);
102102
103+ usesNixExtensions = nixExtensions != null;
104+
103105 extensions = builtins.map (a:
104106 if ! (builtins.hasAttr "extid" a) then
105− throw "extraExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
107+ throw "nixExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
106108 else
107109 a
108− ) extraExtensions;
110+ ) (if usesNixExtensions then nixExtensions else []);
109111
110112 enterprisePolicies =
111113 {
112− policies = {
114+ policies = lib.optionalAttrs usesNixExtensions {
113115 DisableAppUpdate = true;
114116 } //
115− {
117+ lib.optionalAttrs usesNixExtensions {
116118 ExtensionSettings = {
117119 "*" = {
118120 blocked_install_message = "You can't have manual extension mixed with nix extensions";
@@ -137,7 +139,7 @@ let
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
140− lockPref("xpinstall.signatures.required", false);
142+ ${ lib.optionalString usesNixExtensions ''lockPref("xpinstall.signatures.required", false)'' };
141143 ${extraPrefs}
142144 '';
143145