258 lines
7.2 KiB
Nix
258 lines
7.2 KiB
Nix
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux;
|
|
|
|
extensionUrl = "https://git.mizuki.guru/imnyang/thisiswindowsfigma/releases/download/v1.0.0/d168a70cb6a24fe4a478-1.0.0.xpi";
|
|
extensionId = "figma-windows-ua-spoofer@imnyang.local";
|
|
|
|
profileName = "imnyang";
|
|
darwinProfilePath = "Profiles/${profileName}";
|
|
|
|
firefoxSettings = {
|
|
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
|
|
"browser.uidensity" = 0;
|
|
"browser.theme.dark-private-windows" = false;
|
|
};
|
|
|
|
userChrome = ''
|
|
:root {
|
|
--mizuki-bg: #fcf8f9;
|
|
--mizuki-fg: #191017;
|
|
--mizuki-muted: #707d8a;
|
|
--mizuki-border: #f2e6ea;
|
|
--mizuki-surface: #fdf7f9;
|
|
--mizuki-hover: #8165700f;
|
|
--mizuki-active: #8165701a;
|
|
--mizuki-selection: #ecb7d5;
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
:root {
|
|
--mizuki-bg: #191017;
|
|
--mizuki-fg: #fafafa;
|
|
--mizuki-muted: #a9a9b1;
|
|
--mizuki-border: #2c1f2d;
|
|
--mizuki-surface: #191017;
|
|
--mizuki-hover: #2c1f2d80;
|
|
--mizuki-active: #2c1f2d;
|
|
--mizuki-selection: #604562;
|
|
}
|
|
}
|
|
|
|
#navigator-toolbox,
|
|
#TabsToolbar,
|
|
#nav-bar,
|
|
#PersonalToolbar,
|
|
#sidebar-box,
|
|
#sidebar-header {
|
|
background-color: var(--mizuki-bg) !important;
|
|
color: var(--mizuki-fg) !important;
|
|
}
|
|
|
|
#navigator-toolbox {
|
|
border-bottom: 1px solid var(--mizuki-border) !important;
|
|
}
|
|
|
|
#urlbar-background,
|
|
#searchbar {
|
|
background-color: var(--mizuki-surface) !important;
|
|
border-color: var(--mizuki-border) !important;
|
|
color: var(--mizuki-fg) !important;
|
|
}
|
|
|
|
#urlbar[focused] > #urlbar-background,
|
|
#searchbar:focus-within {
|
|
border-color: var(--mizuki-selection) !important;
|
|
box-shadow: 0 0 0 1px var(--mizuki-selection) !important;
|
|
}
|
|
|
|
.tab-background {
|
|
border-radius: 10px 10px 0 0 !important;
|
|
}
|
|
|
|
.tab-background[selected] {
|
|
background-color: var(--mizuki-active) !important;
|
|
}
|
|
|
|
.tabbrowser-tab:not([selected]):hover .tab-background,
|
|
toolbarbutton:hover,
|
|
#urlbar:hover > #urlbar-background {
|
|
background-color: var(--mizuki-hover) !important;
|
|
}
|
|
|
|
toolbarbutton[open],
|
|
toolbarbutton[checked],
|
|
toolbarbutton:active {
|
|
background-color: var(--mizuki-active) !important;
|
|
}
|
|
|
|
#TabsToolbar .tabbrowser-tab,
|
|
#urlbar-input,
|
|
#identity-icon-label,
|
|
toolbarbutton {
|
|
color: var(--mizuki-fg) !important;
|
|
}
|
|
|
|
.tabbrowser-tab:not([selected]) .tab-label,
|
|
#sidebar-title {
|
|
color: var(--mizuki-muted) !important;
|
|
}
|
|
'';
|
|
|
|
userContent = ''
|
|
@-moz-document url("about:home"), url("about:newtab"), url("about:privatebrowsing") {
|
|
body,
|
|
.outer-wrapper,
|
|
.activity-stream {
|
|
background: #fcf8f9 !important;
|
|
color: #191017 !important;
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
body,
|
|
.outer-wrapper,
|
|
.activity-stream {
|
|
background: #191017 !important;
|
|
color: #fafafa !important;
|
|
}
|
|
}
|
|
}
|
|
'';
|
|
|
|
userJs = lib.concatStringsSep "\n" (
|
|
lib.mapAttrsToList (name: value: ''user_pref(${builtins.toJSON name}, ${builtins.toJSON value});'') firefoxSettings
|
|
) + "\n";
|
|
in
|
|
lib.mkMerge [
|
|
(lib.mkIf isLinux {
|
|
programs.firefox = {
|
|
enable = true;
|
|
package = pkgs.firefox-devedition;
|
|
|
|
policies = {
|
|
DisableAppUpdate = true;
|
|
ExtensionSettings = {
|
|
${extensionId} = {
|
|
installation_mode = "force_installed";
|
|
install_url = extensionUrl;
|
|
};
|
|
};
|
|
};
|
|
|
|
profiles.${profileName} = {
|
|
id = 0;
|
|
name = profileName;
|
|
path = "${profileName}.default";
|
|
isDefault = true;
|
|
|
|
settings = firefoxSettings;
|
|
inherit userChrome userContent;
|
|
};
|
|
};
|
|
|
|
xdg.mimeApps.defaultApplications = {
|
|
"text/html" = [ "firefox-devedition.desktop" ];
|
|
"x-scheme-handler/http" = [ "firefox-devedition.desktop" ];
|
|
"x-scheme-handler/https" = [ "firefox-devedition.desktop" ];
|
|
"x-scheme-handler/about" = [ "firefox-devedition.desktop" ];
|
|
"x-scheme-handler/unknown" = [ "firefox-devedition.desktop" ];
|
|
};
|
|
})
|
|
|
|
(lib.mkIf isDarwin {
|
|
home.activation.configureFirefoxDeveloperEdition = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
firefox_dir="$HOME/Library/Application Support/Firefox"
|
|
profiles_ini="$firefox_dir/profiles.ini"
|
|
|
|
mkdir -p "$firefox_dir/Profiles"
|
|
|
|
profile_info=""
|
|
if [ -f "$profiles_ini" ]; then
|
|
profile_info=$(
|
|
awk '
|
|
function flush() {
|
|
if (in_profile && path != "") {
|
|
if (is_default == "1") {
|
|
print is_relative "|" path
|
|
found = 1
|
|
exit
|
|
}
|
|
if (first == "") {
|
|
first = is_relative "|" path
|
|
}
|
|
}
|
|
}
|
|
BEGIN { in_profile = 0; is_relative = "1" }
|
|
/^\\[Profile[0-9]+\\]$/ { flush(); in_profile = 1; path = ""; is_default = "0"; is_relative = "1"; next }
|
|
/^\\[/ { flush(); in_profile = 0; next }
|
|
in_profile && /^Path=/ { path = substr($0, 6); next }
|
|
in_profile && /^Default=1$/ { is_default = "1"; next }
|
|
in_profile && /^IsRelative=/ { is_relative = substr($0, 12); next }
|
|
END {
|
|
if (!found) {
|
|
flush()
|
|
}
|
|
if (!found && first != "") {
|
|
print first
|
|
}
|
|
}
|
|
' "$profiles_ini"
|
|
)
|
|
fi
|
|
|
|
if [ -n "$profile_info" ]; then
|
|
is_relative="''${profile_info%%|*}"
|
|
profile_path="''${profile_info#*|}"
|
|
if [ "$is_relative" = "1" ]; then
|
|
profile_dir="$firefox_dir/$profile_path"
|
|
else
|
|
profile_dir="$profile_path"
|
|
fi
|
|
else
|
|
profile_dir="$firefox_dir/${darwinProfilePath}"
|
|
cat > "$profiles_ini" <<'EOF'
|
|
[Profile0]
|
|
Name=${profileName}
|
|
IsRelative=1
|
|
Path=${darwinProfilePath}
|
|
Default=1
|
|
|
|
[General]
|
|
StartWithLastProfile=1
|
|
Version=2
|
|
EOF
|
|
fi
|
|
|
|
mkdir -p "$profile_dir/chrome"
|
|
cp ${pkgs.writeText "firefox-devedition-user.js" userJs} "$profile_dir/user.js"
|
|
cp ${pkgs.writeText "firefox-devedition-userChrome.css" userChrome} "$profile_dir/chrome/userChrome.css"
|
|
cp ${pkgs.writeText "firefox-devedition-userContent.css" userContent} "$profile_dir/chrome/userContent.css"
|
|
'';
|
|
|
|
home.file = {
|
|
"Library/Preferences/org.mozilla.firefoxdeveloperedition.plist".text = ''
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>EnterprisePoliciesEnabled</key>
|
|
<true/>
|
|
<key>DisableAppUpdate</key>
|
|
<true/>
|
|
<key>ExtensionSettings</key>
|
|
<dict>
|
|
<key>${extensionId}</key>
|
|
<dict>
|
|
<key>installation_mode</key>
|
|
<string>force_installed</string>
|
|
<key>install_url</key>
|
|
<string>${extensionUrl}</string>
|
|
</dict>
|
|
</dict>
|
|
</dict>
|
|
</plist>
|
|
'';
|
|
};
|
|
})
|
|
]
|