diff --git a/flake/dev/flake.lock b/flake/dev/flake.lock index 19dc64b0..97e0a72a 100644 --- a/flake/dev/flake.lock +++ b/flake/dev/flake.lock @@ -321,7 +321,8 @@ "nixvim": "nixvim", "nvf": "nvf", "spicetify-nix": "spicetify-nix", - "treefmt-nix": "treefmt-nix" + "treefmt-nix": "treefmt-nix", + "zen-browser": "zen-browser" } }, "spicetify-nix": { @@ -381,6 +382,29 @@ "repo": "treefmt-nix", "type": "github" } + }, + "zen-browser": { + "inputs": { + "home-manager": [ + "home-manager" + ], + "nixpkgs": [ + "dev-nixpkgs" + ] + }, + "locked": { + "lastModified": 1752758254, + "narHash": "sha256-VP+f1kJmTsJW+62HtJRZw/luhKHaT06lByAI3/6dXSQ=", + "owner": "0xc000022070", + "repo": "zen-browser-flake", + "rev": "9aa65a267cba3e8334e3af8ec005e75d9c391bbe", + "type": "github" + }, + "original": { + "owner": "0xc000022070", + "repo": "zen-browser-flake", + "type": "github" + } } }, "root": "root", diff --git a/flake/dev/flake.nix b/flake/dev/flake.nix index 25c7a948..0f53b2bd 100644 --- a/flake/dev/flake.nix +++ b/flake/dev/flake.nix @@ -173,6 +173,14 @@ url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "dev-nixpkgs"; }; + + zen-browser = { + url = "github:0xc000022070/zen-browser-flake"; + inputs = { + nixpkgs.follows = "dev-nixpkgs"; + home-manager.follows = "home-manager"; + }; + }; # keep-sorted end }; diff --git a/modules/zen-browser/hm.nix b/modules/zen-browser/hm.nix new file mode 100644 index 00000000..2f19e690 --- /dev/null +++ b/modules/zen-browser/hm.nix @@ -0,0 +1,72 @@ +{ + mkTarget, + lib, + config, + options, + ... +}: +mkTarget { + name = "zen-browser"; + humanName = "Zen Browser"; + + extraOptions = { + profileNames = lib.mkOption { + description = "The Zen Browser profile names to apply styling on."; + type = lib.types.listOf lib.types.str; + + default = [ ]; + example = [ "default" ]; + }; + }; + + configElements = + lib.optionals (builtins.hasAttr "zen-browser" options.programs) + [ + ( + { cfg }: + { + warnings = + lib.optional (config.programs.zen-browser.enable && cfg.profileNames == [ ]) + ''stylix: zen-browser: `config.stylix.targets.zen-browser.profileNames` is not set. Declare profile names with 'config.stylix.targets.zen-browser.profileNames = [ "" ];'.''; + } + ) + ( + { + cfg, + fonts, + }: + { + programs.zen-browser.profiles = lib.genAttrs cfg.profileNames (_: { + settings = { + "font.name.monospace.x-western" = fonts.monospace.name; + "font.name.sans-serif.x-western" = fonts.sansSerif.name; + "font.name.serif.x-western" = fonts.serif.name; + }; + }); + } + ) + ( + { + cfg, + colors, + }: + { + programs.zen-browser.profiles = lib.genAttrs cfg.profileNames (_: { + settings = { + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + }; + + userChrome = colors { + template = ./userChrome.css.mustache; + extension = ".css"; + }; + + userContent = colors { + template = ./userContent.css.mustache; + extension = ".css"; + }; + }); + } + ) + ]; +} diff --git a/modules/zen-browser/meta.nix b/modules/zen-browser/meta.nix new file mode 100644 index 00000000..5ca67793 --- /dev/null +++ b/modules/zen-browser/meta.nix @@ -0,0 +1,38 @@ +{ lib, ... }: +{ + name = "Zen Browser"; + homepage = "https://zen-browser.app"; + maintainers = [ lib.maintainers.MrSom3body ]; + description = '' + This module supports the [Zen Browser](https://zen-browser.app). + + > [!IMPORTANT] + > + > For any theming to be applied, you need to tell this module which + > [profiles](https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data) + > you're using: + > + > ```nix + > { + > programs.zen-browser = { + > enable = true; + > + > profiles = { + > my-profile = { + > # bookmarks, extensions, search engines... + > }; + > my-friends-profile = { + > # bookmarks, extensions, search engines... + > }; + > }; + > }; + > + > stylix.targets.zen-browser.profileNames = [ "my-profile" "my-friends-profile" ]; + > } + > ``` + > + > This is necessary due to a limitation of the module system: we can either + > detect the list of profiles, or change their configuration, but we can't do + > both without infinite recursion. + ''; +} diff --git a/modules/zen-browser/testbeds/zen-browser.nix b/modules/zen-browser/testbeds/zen-browser.nix new file mode 100644 index 00000000..118aedc3 --- /dev/null +++ b/modules/zen-browser/testbeds/zen-browser.nix @@ -0,0 +1,22 @@ +{ lib, ... }: +let + profileName = "stylix"; +in +{ + stylix.testbed.ui.command.text = "zen"; + + home-manager.sharedModules = lib.singleton { + programs.zen-browser = { + enable = true; + profiles.${profileName} = { + isDefault = true; + settings = { + "app.normandy.first_run" = false; + "zen.welcome-screen.seen" = true; + }; + }; + }; + + stylix.targets.zen-browser.profileNames = [ profileName ]; + }; +} diff --git a/modules/zen-browser/userChrome.css.mustache b/modules/zen-browser/userChrome.css.mustache new file mode 100644 index 00000000..8b9ab12d --- /dev/null +++ b/modules/zen-browser/userChrome.css.mustache @@ -0,0 +1,126 @@ +:root { + --zen-colors-primary: #{{base02-hex}} !important; + --zen-primary-color: #{{base0D-hex}} !important; + --zen-colors-secondary: #{{base02-hex}} !important; + --zen-colors-tertiary: #{{base01-hex}} !important; + --zen-colors-border: #{{base0D-hex}} !important; + --toolbarbutton-icon-fill: #{{base0D-hex}} !important; + --lwt-text-color: #{{base05-hex}} !important; + --toolbar-field-color: #{{base05-hex}} !important; + --tab-selected-textcolor: #{{base05-hex}} !important; + --toolbar-field-focus-color: #{{base05-hex}} !important; + --toolbar-color: #{{base05-hex}} !important; + --newtab-text-primary-color: #{{base05-hex}} !important; + --arrowpanel-color: #{{base05-hex}} !important; + --arrowpanel-background: #{{base00-hex}} !important; + --sidebar-text-color: #{{base05-hex}} !important; + --lwt-sidebar-text-color: #{{base05-hex}} !important; + --lwt-sidebar-background-color: #{{base00-hex}} !important; + --toolbar-bgcolor: #{{base02-hex}} !important; + --newtab-background-color: #{{base00-hex}} !important; + --zen-themed-toolbar-bg: #{{base00-hex}} !important; + --zen-main-browser-background: #{{base00-hex}} !important; + --toolbox-bgcolor-inactive: #{{base01-hex}} !important; +} + +#permissions-granted-icon { + color: #{{base05-hex}} !important; +} + +.sidebar-placesTree { + background-color: #{{base00-hex}} !important; +} + +#zen-workspaces-button { + background-color: #{{base00-hex}} !important; +} + +#TabsToolbar { + background-color: #{{base00-hex}} !important; +} + +#urlbar-background { + background-color: #{{base02-hex}} !important; +} + +.content-shortcuts { + background-color: #{{base00-hex}} !important; + border-color: #{{base0D-hex}} !important; +} + +.urlbarView-url { + color: #{{base0D-hex}} !important; +} + +#zenEditBookmarkPanelFaviconContainer { + background: #{{base00-hex}} !important; +} + +#zen-media-controls-toolbar { + & #zen-media-progress-bar { + &::-moz-range-track { + background: #{{base02-hex}} !important; + } + } +} + +toolbar .toolbarbutton-1 { + &:not([disabled]) { + &:is([open], [checked]) + > :is( + .toolbarbutton-icon, + .toolbarbutton-text, + .toolbarbutton-badge-stack + ) { + fill: #{{base00-hex}}; + } + } +} + +.identity-color-blue { + --identity-tab-color: #{{base0D-hex}} !important; + --identity-icon-color: #{{base0D-hex}} !important; +} + +.identity-color-turquoise { + --identity-tab-color: #{{base0C-hex}} !important; + --identity-icon-color: #{{base0C-hex}} !important; +} + +.identity-color-green { + --identity-tab-color: #{{base0B-hex}} !important; + --identity-icon-color: #{{base0B-hex}} !important; +} + +.identity-color-yellow { + --identity-tab-color: #{{base0A-hex}} !important; + --identity-icon-color: #{{base0A-hex}} !important; +} + +.identity-color-orange { + --identity-tab-color: #{{base09-hex}} !important; + --identity-icon-color: #{{base09-hex}} !important; +} + +.identity-color-red { + --identity-tab-color: #{{base08-hex}} !important; + --identity-icon-color: #{{base08-hex}} !important; +} + +.identity-color-pink { + --identity-tab-color: #{{base0E-hex}} !important; + --identity-icon-color: #{{base0E-hex}} !important; +} + +.identity-color-purple { + --identity-tab-color: #{{base0F-hex}} !important; + --identity-icon-color: #{{base0F-hex}} !important; +} + +hbox#titlebar { + background-color: #{{base00-hex}} !important; +} + +#zen-appcontent-navbar-container { + background-color: #{{base00-hex}} !important; +} diff --git a/modules/zen-browser/userContent.css.mustache b/modules/zen-browser/userContent.css.mustache new file mode 100644 index 00000000..37c79895 --- /dev/null +++ b/modules/zen-browser/userContent.css.mustache @@ -0,0 +1,149 @@ +/* Common variables affecting all pages */ +@-moz-document url-prefix("about:") { + :root { + --in-content-page-color: #{{base05-hex}} !important; + --color-accent-primary: #{{base0D-hex}} !important; + --color-accent-primary-hover: #{{base0D-hex}} !important; + --color-accent-primary-active: #{{base0D-hex}} !important; + background-color: #{{base00-hex}} !important; + --in-content-page-background: #{{base00-hex}} !important; + } +} + +/* Variables and styles specific to about:newtab and about:home */ +@-moz-document url("about:newtab"), url("about:home") { + + :root { + --newtab-background-color: #{{base00-hex}} !important; + --newtab-background-color-secondary: #{{base02-hex}} !important; + --newtab-element-hover-color: #{{base02-hex}} !important; + --newtab-text-primary-color: #{{base05-hex}} !important; + --newtab-wordmark-color: #{{base05-hex}} !important; + --newtab-primary-action-background: #{{base0D-hex}} !important; + } + + .icon { + color: #{{base0D-hex}} !important; + } + + .search-wrapper .logo-and-wordmark .logo { + display: inline-block !important; + height: 82px !important; + width: 82px !important; + background-size: 82px !important; + } + + @media (max-width: 609px) { + .search-wrapper .logo-and-wordmark .logo { + background-size: 64px !important; + height: 64px !important; + width: 64px !important; + } + } + + .card-outer:is(:hover, :focus, .active):not(.placeholder) .card-title { + color: #{{base0D-hex}} !important; + } + + .top-site-outer .search-topsite { + background-color: #{{base0D-hex}} !important; + } + + .compact-cards .card-outer .card-context .card-context-icon.icon-download { + fill: #{{base0B-hex}} !important; + } +} + +/* Variables and styles specific to about:preferences */ +@-moz-document url-prefix("about:preferences") { + :root { + --zen-colors-tertiary: #{{base01-hex}} !important; + --in-content-text-color: #{{base05-hex}} !important; + --link-color: #{{base0D-hex}} !important; + --link-color-hover: #{{base0D-hex}} !important; + --zen-colors-primary: #{{base02-hex}} !important; + --in-content-box-background: #{{base02-hex}} !important; + --zen-primary-color: #{{base0D-hex}} !important; + } + + groupbox , moz-card{ + background: #{{base00-hex}} !important; + } + + button, + groupbox menulist { + background: #{{base02-hex}} !important; + color: #{{base05-hex}} !important; + } + + .main-content { + background-color: #{{base00-hex}} !important; + } + + .identity-color-blue { + --identity-tab-color: #{{base0D-hex}} !important; + --identity-icon-color: #{{base0D-hex}} !important; + } + + .identity-color-turquoise { + --identity-tab-color: #{{base0C-hex}} !important; + --identity-icon-color: #{{base0C-hex}} !important; + } + + .identity-color-green { + --identity-tab-color: #{{base0B-hex}} !important; + --identity-icon-color: #{{base0B-hex}} !important; + } + + .identity-color-yellow { + --identity-tab-color: #{{base0A-hex}} !important; + --identity-icon-color: #{{base0A-hex}} !important; + } + + .identity-color-orange { + --identity-tab-color: #{{base09-hex}} !important; + --identity-icon-color: #{{base09-hex}} !important; + } + + .identity-color-red { + --identity-tab-color: #{{base08-hex}} !important; + --identity-icon-color: #{{base08-hex}} !important; + } + + .identity-color-pink { + --identity-tab-color: #{{base0E-hex}} !important; + --identity-icon-color: #{{base0E-hex}} !important; + } + + .identity-color-purple { + --identity-tab-color: #{{base0F-hex}} !important; + --identity-icon-color: #{{base0F-hex}} !important; + } + +/* Variables and styles specific to about:addons */ +@-moz-document url-prefix("about:addons") { + :root { + --zen-dark-color-mix-base: #{{base01-hex}} !important; + --background-color-box: #{{base00-hex}} !important; + } +} + +/* Variables and styles specific to about:protections */ +@-moz-document url-prefix("about:protections") { + :root { + --zen-primary-color: #{{base00-hex}} !important; + --social-color: #{{base0E-hex}} !important; + --coockie-color: #{{base0D-hex}} !important; + --fingerprinter-color: #{{base0A-hex}} !important; + --cryptominer-color: #{{base0F-hex}} !important; + --tracker-color: #{{base0B-hex}} !important; + --in-content-primary-button-background-hover: #{{base03-hex}} !important; + --in-content-primary-button-text-color-hover: #{{base05-hex}} !important; + --in-content-primary-button-background: #{{base03-hex}} !important; + --in-content-primary-button-text-color: #{{base05-hex}} !important; + } + + .card { + background-color: #{{base02-hex}} !important; + } +} diff --git a/stylix/testbed/default.nix b/stylix/testbed/default.nix index 982ac67d..da52f7b6 100644 --- a/stylix/testbed/default.nix +++ b/stylix/testbed/default.nix @@ -37,6 +37,12 @@ let inherit (inputs.spicetify-nix.nixosModules) spicetify; nvf = inputs.nvf.nixosModules.default; + + zen-browser = { + home-manager.sharedModules = [ + inputs.zen-browser.homeModules.default + ]; + }; }; }; in