nixos-config/home/browsers/firefox.nix

107 lines
2.9 KiB
Nix
Raw Normal View History

{ config, nixosConfig, pkgs, lib, ... }:
2020-08-15 02:30:01 +02:00
with lib;
let
firefox-addons = pkgs.nur.repos.rycee.firefox-addons
// (import ./firefoxAddons.nix { inherit pkgs lib; });
2020-08-15 02:30:01 +02:00
inherit (import ../modules/firefox/common.nix { inherit config lib pkgs; })
mkConfig;
2020-08-15 02:30:01 +02:00
arkenfoxConfig = builtins.readFile pkgs.nur.repos.slaier.arkenfox-userjs;
2021-05-11 20:58:03 +02:00
# Relax some arkenfox settings, to get a less strict
# alternative to Mullvad Browser to fallback on.
sharedSettings = {
# Enable restoring sessions
"browser.startup.page" = 3;
2020-10-03 16:48:01 +02:00
# Don't delete data on shutdown (cookies, sessions, windows, ...)
"privacy.sanitize.sanitizeOnShutdown" = false;
2020-08-25 21:34:43 +02:00
# Don't do default browser check
"browser.shell.checkDefaultBrowser" = false;
2020-12-25 12:01:55 +01:00
# Disable Pocket
"extensions.pocket.enabled" = false;
# Enable search in location bar
"keyword.enabled" = true;
# Enable IPv6 again
"network.dns.disableIPv6" = false;
# Disable extension auto updates
"extensions.update.enabled" = false;
"extensions.update.autoUpdateDefault" = false;
2020-08-15 02:30:01 +02:00
};
2023-04-09 21:31:13 +02:00
# use extraConfig to load arkenfox user.js before settings
sharedExtraConfig = ''
${arkenfoxConfig}
${mkConfig sharedSettings}
'';
2023-04-12 20:55:57 +02:00
commonExtensions = with firefox-addons; [
german-dictionary
2023-04-12 20:55:57 +02:00
ublock-origin
bitwarden
libredirect
zotero-connector
];
2020-10-03 16:48:01 +02:00
in {
programs.firefox = {
enable = true;
profiles = {
private = {
id = 0;
extraConfig = sharedExtraConfig;
2023-05-31 17:25:46 +02:00
extensions = commonExtensions ++ (with firefox-addons; [ metamask ]);
};
work = {
id = 1;
extraConfig = sharedExtraConfig;
2023-05-31 17:25:46 +02:00
extensions = commonExtensions
++ (with firefox-addons; [ react-devtools reduxdevtools ]);
};
};
};
2020-08-15 02:32:23 +02:00
2020-08-25 21:34:43 +02:00
home.packages = let
makeFirefoxProfileBin = args@{ profile, ... }:
2020-08-25 21:34:43 +02:00
let
name = "firefox-${profile}";
scriptBin = pkgs.writeScriptBin name ''
firefox -P "${profile}" --name="${name}" $@
2020-10-03 16:48:01 +02:00
'';
desktopFile = pkgs.makeDesktopItem ((removeAttrs args [ "profile" ])
// {
inherit name;
exec = "${scriptBin}/bin/${name} %U";
2022-03-05 11:38:53 +01:00
extraConfig.StartupWMClass = name;
genericName = "Web Browser";
2022-03-05 11:38:53 +01:00
mimeTypes = [
"text/html"
"text/xml"
"application/xhtml+xml"
"application/vnd.mozilla.xul+xml"
"x-scheme-handler/http"
"x-scheme-handler/https"
];
2022-03-05 11:38:53 +01:00
categories = [ "Network" "WebBrowser" ];
});
in pkgs.runCommand name { } ''
mkdir -p $out/{bin,share}
cp -r ${scriptBin}/bin/${name} $out/bin/${name}
cp -r ${desktopFile}/share/applications $out/share/applications
'';
in [
2022-01-01 02:13:02 +01:00
(makeFirefoxProfileBin {
profile = "work";
desktopName = "Firefox (Work)";
icon = "firefox";
})
];
}