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; inherit (import ./prefgroups.nix inputs) modules prefgroups;
extra-addons = let extra-addons = let
buildFirefoxXpiAddon = lib.makeOverridable ({ buildFirefoxXpiAddon = {
stdenv ? pkgs.stdenv, src,
fetchurl ? pkgs.fetchurl, pname,
pname, version,
version, addonId
addonId, }: pkgs.stdenv.mkDerivation {
url, name = "${pname}-${version}";
sha256,
...
}: stdenv.mkDerivation {
name = "${pname}-${version}";
src = fetchurl { inherit url sha256; }; inherit src;
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = true; allowSubstitutes = true;
buildCommand = '' buildCommand = ''
dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
mkdir -p "$dst" mkdir -p "$dst"
install -v -m644 "$src" "$dst/${addonId}.xpi" 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 { in {
github-reposize = buildFirefoxXpiAddon { github-reposize = remoteXpiAddon {
pname = "github-reposize"; pname = "github-reposize";
version = "1.7.0"; version = "1.7.0";
addonId = "github-repo-size@mattelrah.com"; addonId = "github-repo-size@mattelrah.com";
url = "https://addons.mozilla.org/firefox/downloads/file/3854469/github_repo_size-1.7.0.xpi"; url = "https://addons.mozilla.org/firefox/downloads/file/3854469/github_repo_size-1.7.0.xpi";
sha256 = "2zGY12esYusaw2IzXM+1kP0B/0Urxu0yj7xXlDlutto="; sha256 = "2zGY12esYusaw2IzXM+1kP0B/0Urxu0yj7xXlDlutto=";
}; };
vencord = buildFirefoxXpiAddon { vencord = remoteXpiAddon {
pname = "vencord"; pname = "vencord";
version = "1.2.7"; version = "1.2.7";
addonId = "vencord-firefox@vendicated.dev"; addonId = "vencord-firefox@vendicated.dev";
url = "https://addons.mozilla.org/firefox/downloads/file/4123132/vencord_web-1.2.7.xpi"; url = "https://addons.mozilla.org/firefox/downloads/file/4123132/vencord_web-1.2.7.xpi";
sha256 = "A/XKdT0EuDHsQ7mcK9hsXAoAJYUt4Uvp/rtCf/9dAS0="; 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 { in {
programs.firefox = { programs.firefox = {
enable = true; enable = true;
package = pkgs.firefox-devedition.overrideAttrs (pkg: let 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: { imEntry = pkg.desktopItem.override (entry: {
name = "discord-firefox"; name = "discord-firefox";
desktopName = "IMs (Firefox)"; desktopName = "IMs (Firefox)";
@ -56,28 +172,44 @@ in {
in { in {
buildCommand = '' buildCommand = ''
${pkg.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 = { profiles = let
base = { mkProfile = { name, id, settings, extensions ? [] }: {
id = 1; inherit id settings name extensions;
name = "BaseFF"; path = name;
userChrome = builtins.readFile ./sideberry_chrome.css;
};
dev-edition-default = {
id = 0;
name = "dev-edition-default";
path = "default";
userChrome = '' userChrome = ''
${builtins.readFile ./sideberry_chrome.css} ${builtins.readFile ./sideberry_chrome.css}
${builtins.readFile ./sideberry_hide_ext_button.css} ${builtins.readFile ./sideberry_hide_ext_button.css}
''; '';
settings = with modules; {} };
// base in {
// minor-1 base = {
// annoying; 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; [ extensions = with pkgs.nur.repos.rycee.firefox-addons; with extra-addons; [
bitwarden bitwarden
@ -88,11 +220,13 @@ in {
sponsorblock sponsorblock
ublock-origin ublock-origin
umatrix umatrix
theme-gray
]; ];
}; };
im = { im = {
id = 2; id = 2;
name = "Im"; name = "im";
userChrome = builtins.readFile ./inline_tabs_chrome.css; userChrome = builtins.readFile ./inline_tabs_chrome.css;
settings = modules.base settings = modules.base
// prefgroups.misc.restore-pages; // prefgroups.misc.restore-pages;
@ -102,6 +236,40 @@ in {
vencord 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; "privacy.sanitize.timeSpan" = 0;
}; };
# Note: breaks dark mode
resist-fingerprinting = { resist-fingerprinting = {
"privacy.resistFingerprinting" = true; "privacy.resistFingerprinting" = true;
}; };
@ -543,30 +544,47 @@ rec {
// misc.default-dark-theme // misc.default-dark-theme
; ;
# Minor breakage / inconvenience
minor-1 = {} minor-1 = {}
// misc.disable-prefetching // misc.disable-prefetching
// privacy.disable-captive-portals // privacy.disable-captive-portals
// privacy.disable-search-suggestions // privacy.disable-search-suggestions
// security.disable-http-resources // security.disable-http-resources
// security.cross-origin.trimming
// security.cross-origin.same-host
// security.remove-webchannel-whitelist // security.remove-webchannel-whitelist
// security.etp-strict // security.etp-strict
// privacy.sanitize-on-shutdown ;
// privacy.resist-fingerprinting
// security.disable-system-ui minor-2 = {}
// security.disable-webgl // security.disable-webgl
// privacy.sanitize-on-shutdown
// security.disable-sessionrestore // security.disable-sessionrestore
// security.disable-js-jit
; ;
annoying = {} annoying = {}
// privacy.resist-fingerprinting
// security.disable-js-jit
// privacy.webrtc.hide-ip-trusted // privacy.webrtc.hide-ip-trusted
// privacy.ephemeral-cookies // privacy.ephemeral-cookies
// privacy.webrtc.disable // 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: '' 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
'';
}