Seperate firefox profiles for trusted / work / general

This commit is contained in:
outfoxxed 2024-02-18 04:23:42 -08:00
parent d94fe01659
commit cbb3278b8f
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 264 additions and 48 deletions

View file

@ -3,50 +3,166 @@ let
inherit (import ./prefgroups.nix inputs) modules prefgroups;
extra-addons = let
buildFirefoxXpiAddon = lib.makeOverridable ({
stdenv ? pkgs.stdenv,
fetchurl ? pkgs.fetchurl,
pname,
version,
addonId,
url,
sha256,
...
}: stdenv.mkDerivation {
name = "${pname}-${version}";
buildFirefoxXpiAddon = {
src,
pname,
version,
addonId
}: pkgs.stdenv.mkDerivation {
name = "${pname}-${version}";
src = fetchurl { inherit url sha256; };
inherit src;
preferLocalBuild = true;
allowSubstitutes = true;
preferLocalBuild = true;
allowSubstitutes = true;
buildCommand = ''
dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
mkdir -p "$dst"
install -v -m644 "$src" "$dst/${addonId}.xpi"
'';
});
buildCommand = ''
dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
mkdir -p "$dst"
install -v -m644 "$src" "$dst/${addonId}.xpi"
'';
};
remoteXpiAddon = { pname, version, addonId, url, sha256 }: buildFirefoxXpiAddon {
inherit pname version addonId;
src = pkgs.fetchurl { inherit url sha256; };
};
theme = { name, theme }: buildFirefoxXpiAddon {
pname = "firefox-theme-xpi-${name}";
version = "1.0";
addonId = "theme-${name}@outfoxxed.me";
src = import ./theme.nix { inherit pkgs name theme; };
};
in {
github-reposize = buildFirefoxXpiAddon {
github-reposize = remoteXpiAddon {
pname = "github-reposize";
version = "1.7.0";
addonId = "github-repo-size@mattelrah.com";
url = "https://addons.mozilla.org/firefox/downloads/file/3854469/github_repo_size-1.7.0.xpi";
sha256 = "2zGY12esYusaw2IzXM+1kP0B/0Urxu0yj7xXlDlutto=";
};
vencord = buildFirefoxXpiAddon {
vencord = remoteXpiAddon {
pname = "vencord";
version = "1.2.7";
addonId = "vencord-firefox@vendicated.dev";
url = "https://addons.mozilla.org/firefox/downloads/file/4123132/vencord_web-1.2.7.xpi";
sha256 = "A/XKdT0EuDHsQ7mcK9hsXAoAJYUt4Uvp/rtCf/9dAS0=";
};
theme-gray = theme {
name = "theme-gray";
theme.colors = {
toolbar = "rgb(42, 46, 50)";
toolbar_text = "rgb(255, 255, 255)";
frame = "rgb(27, 30, 32)";
tab_background_text = "rgb(215, 226, 239)";
toolbar_field = "rgb(27, 30, 32)";
toolbar_field_text = "rgb(255, 255, 255)";
tab_line = "rgb(0, 0, 0)";
popup = "rgb(42, 46, 50)";
popup_text = "rgb(252, 252, 252)";
tab_loading = "rgb(0, 0, 0)";
};
};
theme-green = theme {
name = "theme-green";
theme.colors = {
toolbar = "rgb(26, 53, 40)";
toolbar_text = "rgb(255, 255, 255)";
frame = "rgb(26, 43, 35)";
tab_background_text = "rgb(215, 226, 239)";
toolbar_field = "rgb(26, 43, 35)";
toolbar_field_text = "rgb(255, 255, 255)";
tab_line = "rgb(0, 0, 0)";
popup = "rgb(42, 46, 50)";
popup_text = "rgb(252, 252, 252)";
tab_loading = "rgb(0, 0, 0)";
};
};
theme-orange = theme {
name = "theme-orange";
theme.colors = {
toolbar = "rgb(66, 44, 28)";
toolbar_text = "rgb(255, 255, 255)";
frame = "rgb(43, 34, 26)";
tab_background_text = "rgb(215, 226, 239)";
toolbar_field = "rgb(43, 34, 26)";
toolbar_field_text = "rgb(255, 255, 255)";
tab_line = "rgb(0, 0, 0)";
popup = "rgb(42, 46, 50)";
popup_text = "rgb(252, 252, 252)";
tab_loading = "rgb(0, 0, 0)";
};
};
theme-purple = theme {
name = "theme-purple";
theme.colors = {
toolbar = "rgb(42, 28, 66)";
toolbar_text = "rgb(255, 255, 255)";
frame = "rgb(34, 26, 43)";
tab_background_text = "rgb(215, 226, 239)";
toolbar_field = "rgb(34, 26, 43)";
toolbar_field_text = "rgb(255, 255, 255)";
tab_line = "rgb(0, 0, 0)";
popup = "rgb(42, 46, 50)";
popup_text = "rgb(252, 252, 252)";
tab_loading = "rgb(0, 0, 0)";
};
};
};
in {
programs.firefox = {
enable = true;
package = pkgs.firefox-devedition.overrideAttrs (pkg: let
entries = {
im-firefox = {
name = "IMs (Firefox)";
profile = "im";
nomime = true;
noremote = true;
};
trusted = {
name = "Trusted Firefox";
profile = "trusted";
nomime = true;
};
work = {
name = "Work Firefox";
profile = "work";
nomime = true;
};
general = {
name = "Firefox";
profile = "general";
};
schizo = {
name = "Schizo Firefox";
profile = "schizo";
nomime = true;
};
};
items = builtins.attrValues
(builtins.mapAttrs (name: entry: pkg.desktopItem.override (item: {
inherit name;
desktopName = entry.name;
mimeTypes = if entry ? nomime && entry.nomime
then []
else item.mimeTypes;
exec = "${item.exec} ${if entry ? noremote && entry.noremote then "-no-remote" else ""} -P ${entry.profile}";
})) entries);
imEntry = pkg.desktopItem.override (entry: {
name = "discord-firefox";
desktopName = "IMs (Firefox)";
@ -56,28 +172,44 @@ in {
in {
buildCommand = ''
${pkg.buildCommand}
cp ${imEntry}/share/applications/* $out/share/applications
'';
rm $out/share/applications/*
'' + lib.strings.concatMapStrings (item: "\ncp ${item}/share/applications/* $out/share/applications") items;
});
profiles = {
base = {
id = 1;
name = "BaseFF";
userChrome = builtins.readFile ./sideberry_chrome.css;
};
dev-edition-default = {
id = 0;
name = "dev-edition-default";
path = "default";
profiles = let
mkProfile = { name, id, settings, extensions ? [] }: {
inherit id settings name extensions;
path = name;
userChrome = ''
${builtins.readFile ./sideberry_chrome.css}
${builtins.readFile ./sideberry_hide_ext_button.css}
'';
settings = with modules; {}
// base
// minor-1
// annoying;
};
in {
base = {
id = 10;
name = "base";
};
schizo = mkProfile {
id = 0;
name = "schizo";
settings = modules.schizo;
extensions = with pkgs.nur.repos.rycee.firefox-addons; with extra-addons; [
darkreader
sidebery
sponsorblock
ublock-origin
umatrix
theme-purple
];
};
general = mkProfile {
id = 1;
name = "general";
settings = modules.general;
extensions = with pkgs.nur.repos.rycee.firefox-addons; with extra-addons; [
bitwarden
@ -88,11 +220,13 @@ in {
sponsorblock
ublock-origin
umatrix
theme-gray
];
};
im = {
id = 2;
name = "Im";
name = "im";
userChrome = builtins.readFile ./inline_tabs_chrome.css;
settings = modules.base
// prefgroups.misc.restore-pages;
@ -102,6 +236,40 @@ in {
vencord
];
};
trusted = mkProfile {
id = 3;
name = "trusted";
settings = modules.trusted;
extensions = with pkgs.nur.repos.rycee.firefox-addons; with extra-addons; [
bitwarden
darkreader
github-reposize
sidebery
simplelogin
ublock-origin
umatrix
theme-green
];
};
work = mkProfile {
id = 4;
name = "work";
settings = modules.trusted;
extensions = with pkgs.nur.repos.rycee.firefox-addons; with extra-addons; [
bitwarden
darkreader
github-reposize
sidebery
simplelogin
ublock-origin
umatrix
theme-orange
];
};
};
};
}

View file

@ -378,6 +378,7 @@ rec {
"privacy.sanitize.timeSpan" = 0;
};
# Note: breaks dark mode
resist-fingerprinting = {
"privacy.resistFingerprinting" = true;
};
@ -543,30 +544,47 @@ rec {
// misc.default-dark-theme
;
# Minor breakage / inconvenience
minor-1 = {}
// misc.disable-prefetching
// privacy.disable-captive-portals
// privacy.disable-search-suggestions
// security.disable-http-resources
// security.cross-origin.trimming
// security.cross-origin.same-host
// security.remove-webchannel-whitelist
// security.etp-strict
// privacy.sanitize-on-shutdown
// privacy.resist-fingerprinting
// security.disable-system-ui
;
minor-2 = {}
// security.disable-webgl
// privacy.sanitize-on-shutdown
// security.disable-sessionrestore
// security.disable-js-jit
;
annoying = {}
// privacy.resist-fingerprinting
// security.disable-js-jit
// privacy.webrtc.hide-ip-trusted
// privacy.ephemeral-cookies
// privacy.webrtc.disable
# // privacy.disable-referrer-headers
// security.cross-origin.trimming
// security.cross-origin.same-host
// privacy.disable-referrer-headers
;
trusted = {}
// modules.base
// modules.minor-1
;
general = {}
// modules.base
// modules.minor-1
// modules.minor-2
// privacy.ephemeral-cookies
// privacy.disable-referrer-headers
// privacy.webrtc.disable
;
schizo = modules.general // modules.annoying;
};
mkUserJs = prefs: lib.concatStrings (lib.mapAttrsToList (name: value: ''

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,30 @@
{ pkgs, name, theme }: let
json = builtins.toJSON {
manifest_version = 2;
version = "1.0";
browser_specific_settings.gecko = {
id = "theme-${name}@outfoxxed.me";
};
inherit name theme;
};
jsonFile = pkgs.writeTextFile {
name = "manifest.json";
text = json;
};
in pkgs.stdenvNoCC.mkDerivation {
pname = "firefox-theme-${name}.xpi";
version = "1.0";
preferLocalBuild = true;
unpackPhase = "true";
buildPhase = ''
cp ${jsonFile} manifest.json
${pkgs.zip}/bin/zip out.xpi manifest.json
'';
installPhase = ''
mv out.xpi $out
'';
}