Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firefox: wrapper updating an addon perserves addon settings #106000

Merged
merged 1 commit into from Dec 15, 2020

Conversation

Qubasa
Copy link
Contributor

@Qubasa Qubasa commented Dec 5, 2020

Motivation for this change

In the current firefox wrapper every addon update discards the addon settings, like mentioned here #105783 (comment)

Things done

This change makes the extid static and user defined. The wrapper makes sure that every addon name is unique.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@beardhatcode beardhatcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to would be nice to add an fixedExtid option (or something like it)

pkgs/build-support/fetchfirefoxaddon/default.nix Outdated Show resolved Hide resolved
@wiltaylor
Copy link
Contributor

Please make sure this pull request is tested properly before merging.

@Qubasa Qubasa force-pushed the firefoxWrapperAddonSettings branch from be19dba to 0efbd42 Compare December 6, 2020 13:57
@Qubasa Qubasa requested a review from Mic92 December 9, 2020 11:31
@taku0
Copy link
Contributor

taku0 commented Dec 13, 2020

Does the wrapper work with firefox-bin?

@Mic92 Mic92 requested review from taku0 and removed request for Mic92 December 13, 2020 03:45
@taku0
Copy link
Contributor

taku0 commented Dec 13, 2020

Please rebase on the master rather than merging it.

@taku0
Copy link
Contributor

taku0 commented Dec 13, 2020

If add-ons are removed and reinstalled, the settings are cleared. Is this an expected behavior?

  1. Change directory to nixpkgs.

  2. nix-build -I nixpkgs=. -o myfirefox myfirefox.nix
    where myfirefox.nix is the following file.

    let
      pkgs = import <nixpkgs> {};
    in
    pkgs.wrapFirefox pkgs.firefox-unwrapped {
      nixExtensions = [
        (pkgs.fetchFirefoxAddon {
          name = "ublock";
          url = "https://addons.mozilla.org/firefox/downloads/file/3679754/ublock_origin-1.31.0-an+fx.xpi";
          sha256 = "1h768ljlh3pi23l27qp961v1hd0nbj2vasgy11bmcrlqp40zgvnr";
        })
      ];
    }
  3. ./myfirefox/bin/firefox -P test
    where test is the test profile.

  4. Open uBlock settings and check Color-blind friendly.

  5. Close the browser.

  6. Reopen the browser to see the settings are saved.

  7. Close the browser.

  8. Rebuild the browser with empty nixExtensions (not null).

  9. Open the browser, ensure the uBlock is uninstalled, and then close the browser.

  10. Rebuild the browser with the uBlock in nixExtensions.

  11. Open the browser and uBlock settings.

Expected: Color-blind friendly is checked.
Actual: Color-blind friendly is not checked.

@taku0
Copy link
Contributor

taku0 commented Dec 13, 2020

Doesn't work with firefox-bin. Please make a separate PR for that.

let
  pkgs = import <nixpkgs> {};
in
pkgs.wrapFirefox pkgs.firefox-bin-unwrapped {
  browserName = "firefox";
  pname = "firefox-bin";
  desktopName = "Firefox";
  nixExtensions = [
    (pkgs.fetchFirefoxAddon {
      name = "ublock";
      url = "https://addons.mozilla.org/firefox/downloads/file/3679754/ublock_origin-1.31.0-an+fx.xpi";
      sha256 = "1h768ljlh3pi23l27qp961v1hd0nbj2vasgy11bmcrlqp40zgvnr";
    })
  ];

  extraPolicies = {
    CaptivePortal = false;
    DisableFirefoxStudies = true;
    DisablePocket = true;
    DisableTelemetry = true;
    DisableFirefoxAccounts = true;
    FirefoxHome = {
      Pocket = false;
      Snippets = false;
    };
    UserMessaging = {
      ExtensionRecommendations = false;
      SkipOnboarding = true;
    };
  };

  extraPrefs = ''
      // Show more ssl cert infos
      lockPref("security.identityblock.show_extended_validation", true);

      // Enable userchrome css
      lockPref("toolkit.legacyUserProfileCustomizations.stylesheets", true);

      // Enable dark dev tools
      lockPref("devtools.theme","dark");
    '';
}

@Qubasa
Copy link
Contributor Author

Qubasa commented Dec 13, 2020

If add-ons are removed and reinstalled, the settings are cleared. Is this an expected behavior?

Thanks for testing it! I can't change that behavior because this is up to the Firefox developers to decide how to handle the case when an extension gets removed through not being on the whitelist anymore. Upgrading addons works fine though

@Qubasa
Copy link
Contributor Author

Qubasa commented Dec 13, 2020

Doesn't work with firefox-bin. Please make a separate PR for that.

firefox-bin is incompatible with the wrapper. The binary does not load configuration from the /nix/store/*-firefox-*/lib folder. If you want to check it out yourself comment out these lines in the wrapper and then it builds:

        # For manpages, in case the program supplies them
        mkdir -p $out/nix-support
        echo ${browser} > $out/nix-support/propagated-user-env-packages

@xaverdh
Copy link
Contributor

xaverdh commented Dec 14, 2020

while at it can you also replace builtins.toFile by writeTextFile here ?
(currently this pr fixes one occurrence but not the other).

@xaverdh
Copy link
Contributor

xaverdh commented Dec 14, 2020

If add-ons are removed and reinstalled, the settings are cleared. Is this an expected behavior?

Thanks for testing it! I can't change that behavior because this is up to the Firefox developers to decide how to handle the case when an extension gets removed through not being on the whitelist anymore. Upgrading addons works fine though

Would be nice to document it though, so ppl can make backups of their settings.

@Qubasa Qubasa force-pushed the firefoxWrapperAddonSettings branch 2 times, most recently from ad9bc39 to b00bc2f Compare December 15, 2020 14:23
@Qubasa
Copy link
Contributor Author

Qubasa commented Dec 15, 2020

while at it can you also replace builtins.toFile by writeTextFile here ?
(currently this pr fixes one occurrence but not the other).

Done

@Qubasa
Copy link
Contributor Author

Qubasa commented Dec 15, 2020

If add-ons are removed and reinstalled, the settings are cleared. Is this an expected behavior?

Thanks for testing it! I can't change that behavior because this is up to the Firefox developers to decide how to handle the case when an extension gets removed through not being on the whitelist anymore. Upgrading addons works fine though

Would be nice to document it though, so ppl can make backups of their settings.

Done

@xaverdh
Copy link
Contributor

xaverdh commented Dec 15, 2020

otherwise looks good; thanks for working on this by the way!
Even if it caused some confusion / fallout I very much appreciate that you manged to get this over the finish line :)

@Lassulus Lassulus merged commit 00b8fa7 into NixOS:master Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants