Skip to content

Commit

Permalink
Merge pull request #105796 from Luis-Hebendanz/fix_firefox_wrapper
Browse files Browse the repository at this point in the history
Fix firefox wrapper
  • Loading branch information
Mic92 authored Dec 4, 2020
2 parents 3a2fe56 + d3a6a12 commit 29566ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 10 additions & 1 deletion doc/builders/packages/firefox.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The `wrapFirefox` function allows to pass policies, preferences and extension th
```nix
{
myFirefox = wrapFirefox firefox-unwrapped {
extraExtensions = [
nixExtensions = [
(fetchFirefoxAddon {
name = "ublock";
url = "https://addons.mozilla.org/firefox/downloads/file/3679754/ublock_origin-1.31.0-an+fx.xpi";
Expand Down Expand Up @@ -38,3 +38,12 @@ The `wrapFirefox` function allows to pass policies, preferences and extension th
};
}
```

If `nixExtensions != null` then all manually installed addons will be uninstalled from your browser profile.
To view available enterprise policies visit [enterprise policies](https://github.com/mozilla/policy-templates#enterprisepoliciesenabled)
or type into the Firefox url bar: `about:policies#documentation`.
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.

# Troubleshooting
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.

14 changes: 8 additions & 6 deletions pkgs/applications/networking/browsers/firefox/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let
# https://github.com/mozilla/policy-templates#enterprisepoliciesenabled
, extraPolicies ? {}
, firefoxLibName ? "firefox" # Important for tor package or the like
, extraExtensions ? [ ]
, nixExtensions ? null
}:

assert forceWayland -> (browser ? gtk3); # Can only use the wayland backend if gtk3 is being used
Expand Down Expand Up @@ -100,19 +100,21 @@ let
policiesJson = builtins.toFile "policies.json"
(builtins.toJSON enterprisePolicies);

usesNixExtensions = nixExtensions != null;

extensions = builtins.map (a:
if ! (builtins.hasAttr "extid" a) then
throw "extraExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
throw "nixExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
else
a
) extraExtensions;
) (if usesNixExtensions then nixExtensions else []);

enterprisePolicies =
{
policies = {
policies = lib.optionalAttrs usesNixExtensions {
DisableAppUpdate = true;
} //
{
lib.optionalAttrs usesNixExtensions {
ExtensionSettings = {
"*" = {
blocked_install_message = "You can't have manual extension mixed with nix extensions";
Expand All @@ -137,7 +139,7 @@ let
// to be able to install addons that do not have an extid
// Security is maintained because only user whitelisted addons
// with a checksum can be installed
lockPref("xpinstall.signatures.required", false);
${ lib.optionalString usesNixExtensions ''lockPref("xpinstall.signatures.required", false)'' };
${extraPrefs}
'';

Expand Down

0 comments on commit 29566ca

Please sign in to comment.