browser: make more easily swappable between firefox and librewolf

This commit is contained in:
colin 2022-11-01 16:23:50 -07:00
parent 5ff47b3719
commit 3ecfea158a
3 changed files with 48 additions and 38 deletions

View File

@ -25,7 +25,7 @@
# usability compromises # usability compromises
sane.impermanence.home-dirs = [ sane.impermanence.home-dirs = [
".librewolf" config.sane.web-browser.dotDir
]; ];
# sane.home-packages.enableGuiPkgs = false; # XXX faster builds/imaging for debugging # sane.home-packages.enableGuiPkgs = false; # XXX faster builds/imaging for debugging

View File

@ -20,9 +20,9 @@ in
imports = [ imports = [
./aerc.nix ./aerc.nix
./discord.nix ./discord.nix
./firefox.nix
./git.nix ./git.nix
./kitty.nix ./kitty.nix
./librewolf.nix
./mpv.nix ./mpv.nix
./nb.nix ./nb.nix
./neovim.nix ./neovim.nix
@ -134,7 +134,7 @@ in
# - `xdg-mime query filetype path/to/thing.ext` # - `xdg-mime query filetype path/to/thing.ext`
xdg.mimeApps.enable = true; xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = let xdg.mimeApps.defaultApplications = let
www = "librewolf.desktop"; www = sysconfig.sane.web-browser.desktop;
pdf = "org.gnome.Evince.desktop"; pdf = "org.gnome.Evince.desktop";
md = "obsidian.desktop"; md = "obsidian.desktop";
thumb = "org.gnome.gThumb.desktop"; thumb = "org.gnome.gThumb.desktop";

View File

@ -7,27 +7,29 @@
# see: https://gitlab.com/librewolf-community/settings/-/blob/master/distribution/policies.json # see: https://gitlab.com/librewolf-community/settings/-/blob/master/distribution/policies.json
{ config, lib, pkgs, ...}: { config, lib, pkgs, ...}:
with lib;
let let
# allow easy switching between firefox and librewolf with `active`, below cfg = config.sane.web-browser;
# allow easy switching between firefox and librewolf with `defaultSettings`, below
librewolfSettings = { librewolfSettings = {
browser = pkgs.librewolf-unwrapped; browser = pkgs.librewolf-unwrapped;
libName = "librewolf"; libName = "librewolf";
dotDir = ".librewolf"; dotDir = ".librewolf";
desktop = "librewolf.desktop";
}; };
firefoxSettings = { firefoxSettings = {
browser = pkgs.firefox-esr-unwrapped; browser = pkgs.firefox-esr-unwrapped;
libName = "firefox"; libName = "firefox";
dotDir = ".mozilla/firefox"; dotDir = ".mozilla/firefox";
desktop = "firefox.desktop";
}; };
defaultSettings = firefoxSettings;
# active = librewolfSettings; package = pkgs.wrapFirefox cfg.browser {
active = firefoxSettings;
package = pkgs.wrapFirefox active.browser {
# inherit the default librewolf.cfg # inherit the default librewolf.cfg
# it can be further customized via ~/.librewolf/librewolf.overrides.cfg # it can be further customized via ~/.librewolf/librewolf.overrides.cfg
inherit (pkgs.librewolf-unwrapped) extraPrefsFiles; inherit (pkgs.librewolf-unwrapped) extraPrefsFiles;
inherit (active) libName; inherit (cfg) libName;
extraNativeMessagingHosts = [ pkgs.browserpass ]; extraNativeMessagingHosts = [ pkgs.browserpass ];
# extraNativeMessagingHosts = [ pkgs.gopass-native-messaging-host ]; # extraNativeMessagingHosts = [ pkgs.gopass-native-messaging-host ];
@ -90,36 +92,44 @@ let
}; };
in in
{ {
# XXX: although home-manager calls this option `firefox`, we can use other browsers and it still mostly works. options = {
home-manager.users.colin = lib.mkIf (config.sane.gui.enable) { sane.web-browser = mkOption {
programs.firefox = { default = defaultSettings;
enable = true; type = types.attrs;
inherit package;
}; };
};
config = {
# XXX: although home-manager calls this option `firefox`, we can use other browsers and it still mostly works.
home-manager.users.colin = lib.mkIf (config.sane.gui.enable) {
programs.firefox = {
enable = true;
inherit package;
};
# uBlock filter list configuration. # uBlock filter list configuration.
# specifically, enable the GDPR cookie prompt blocker. # specifically, enable the GDPR cookie prompt blocker.
# data.toOverwrite.filterLists is additive (i.e. it supplements the default filters) # data.toOverwrite.filterLists is additive (i.e. it supplements the default filters)
# this configuration method is documented here: # this configuration method is documented here:
# - <https://github.com/gorhill/uBlock/issues/2986#issuecomment-364035002> # - <https://github.com/gorhill/uBlock/issues/2986#issuecomment-364035002>
# the specific attribute path is found via scraping ublock code here: # the specific attribute path is found via scraping ublock code here:
# - <https://github.com/gorhill/uBlock/blob/master/src/js/storage.js> # - <https://github.com/gorhill/uBlock/blob/master/src/js/storage.js>
# - <https://github.com/gorhill/uBlock/blob/master/assets/assets.json> # - <https://github.com/gorhill/uBlock/blob/master/assets/assets.json>
home.file."${active.dotDir}/managed-storage/uBlock0@raymondhill.net.json".text = '' home.file."${cfg.dotDir}/managed-storage/uBlock0@raymondhill.net.json".text = ''
{ {
"name": "uBlock0@raymondhill.net", "name": "uBlock0@raymondhill.net",
"description": "ignored", "description": "ignored",
"type": "storage", "type": "storage",
"data": { "data": {
"toOverwrite": "{\"filterLists\": [\"fanboy-cookiemonster\"]}" "toOverwrite": "{\"filterLists\": [\"fanboy-cookiemonster\"]}"
} }
} }
''; '';
home.file."${active.dotDir}/${active.libName}.overrides.cfg".text = '' home.file."${cfg.dotDir}/${cfg.libName}.overrides.cfg".text = ''
// if we can't query the revocation status of a SSL cert because the issuer is offline, // if we can't query the revocation status of a SSL cert because the issuer is offline,
// treat it as unrevoked. // treat it as unrevoked.
// see: <https://librewolf.net/docs/faq/#im-getting-sec_error_ocsp_server_error-what-can-i-do> // see: <https://librewolf.net/docs/faq/#im-getting-sec_error_ocsp_server_error-what-can-i-do>
defaultPref("security.OCSP.require", false); defaultPref("security.OCSP.require", false);
''; '';
};
}; };
} }