diff --git a/configuration.nix b/configuration.nix index ea64fa4..419101f 100644 --- a/configuration.nix +++ b/configuration.nix @@ -63,6 +63,11 @@ # TODO: Remove when on stable ghostty = unstable.ghostty; + # TODO: Use official package when available + # https://github.com/NixOS/nixpkgs/issues/327982 + zen-browser = inputs.zen-browser.packages.${pkgs.system}.zen-browser; + zen-browser-unwrapped = inputs.zen-browser.packages.${pkgs.system}.zen-browser-unwrapped; + ### Python # https://nixos.org/manual/nixpkgs/unstable/#how-to-override-a-python-package-for-all-python-versions-using-extensions #?? PKG = pyprev.PKG.overridePythonAttrs {}; @@ -171,6 +176,7 @@ }; users = { + # FIXME: Separate root from sharedModules root = { # Inherit from user programs.home-manager.enable = config.home-manager.users.${config.custom.username}.programs.home-manager.enable; diff --git a/flake.in.nix b/flake.in.nix index c2b2269..3061907 100644 --- a/flake.in.nix +++ b/flake.in.nix @@ -68,6 +68,7 @@ nixgl-unstable = flake "github:nix-community/nixGL" // unstable "nixpkgs"; stylix-unstable = flake "github:danth/stylix" // unstable "nixpkgs"; walker = flake "github:abenz1267/walker?ref=v0.12.8" // unstable "nixpkgs"; + zen-browser = flake "github:youwen5/zen-browser-flake" // unstable "nixpkgs"; ### Branches nixpkgs-master = flake "github:NixOS/nixpkgs/master"; @@ -140,6 +141,30 @@ inputs.anyrun.homeManagerModules.default inputs.nix-flatpak.homeManagerModules.nix-flatpak inputs.walker.homeManagerModules.default + + # TODO: Use official module when supported + # https://github.com/nix-community/home-manager/blob/master/modules/programs/floorp.nix + (let + modulePath = ["programs" "zen-browser"]; + mkFirefoxModule = import "${inputs."home-manager-${branch}"}/modules/programs/firefox/mkFirefoxModule.nix"; + in + mkFirefoxModule { + inherit modulePath; + name = "Zen"; + wrappedPackageName = "zen-browser"; + unwrappedPackageName = "zen-browser-unwrapped"; + visible = true; + + platforms.linux = { + configPath = ".zen"; + vendorPath = ".mozilla"; + }; + + platforms.darwin = { + configPath = "Library/Application Support/Zen"; + vendorPath = "Library/Application Support/Mozilla"; + }; + }) ]; # Branch-specific overlays diff --git a/flake.nix b/flake.nix index de99163..ecf75db 100644 --- a/flake.nix +++ b/flake.nix @@ -164,6 +164,10 @@ inputs.nixpkgs.follows = "nixpkgs-unstable"; url = "github:abenz1267/walker?ref=v0.12.8"; }; + zen-browser = { + inputs.nixpkgs.follows = "nixpkgs-unstable"; + url = "github:youwen5/zen-browser-flake"; + }; }; outputs = inputs: inputs.flakegen ./flake.in.nix inputs; } \ No newline at end of file diff --git a/options/custom/desktops/hyprland/rules.nix b/options/custom/desktops/hyprland/rules.nix index 5146c38..49c75d1 100644 --- a/options/custom/desktops/hyprland/rules.nix +++ b/options/custom/desktops/hyprland/rules.nix @@ -210,6 +210,7 @@ in { (class "^firefox.*$" rules) (class "^google-chrome$" rules) (class "^vivaldi.*$" rules) + (class "^zen$" rules) ]; clipboard = rules: [ diff --git a/options/custom/programs/default.nix b/options/custom/programs/default.nix index 4cb3f3b..f19a525 100644 --- a/options/custom/programs/default.nix +++ b/options/custom/programs/default.nix @@ -42,6 +42,7 @@ with lib; { nautilus.enable = true; nvtop.enable = true; wezterm.enable = true; + zen-browser.enable = true; }) (mkIf config.custom.full { diff --git a/options/custom/programs/firefox/zen-browser.nix b/options/custom/programs/firefox/zen-browser.nix new file mode 100644 index 0000000..edfd35f --- /dev/null +++ b/options/custom/programs/firefox/zen-browser.nix @@ -0,0 +1,72 @@ +{ + config, + inputs, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.custom.programs.zen-browser; +in { + options.custom.programs.zen-browser = { + enable = mkOption {default = false;}; + }; + + config = mkIf cfg.enable { + home-manager.sharedModules = [ + { + # https://zen-browser.app/ + # https://github.com/youwen5/zen-browser-flake + programs.zen-browser = mkMerge [ + (import "${inputs.self}/modules/firefox.nix" { + inherit config inputs lib pkgs; + + # TODO: Revisit Zen themes + theme = false; + }) + + { + enable = true; + + profiles.default.settings = { + "zen.pinned-tab-manager.close-shortcut-behavior" = "reset-unload-switch"; + "zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url" = true; + "zen.tab-unloader.timeout-minutes" = 60; + "zen.theme.accent-color" = "#d33682"; + "zen.theme.color-prefs.colorful" = false; + "zen.theme.color-prefs.use-workspace-colors" = true; + "zen.theme.pill-button" = true; + "zen.urlbar.replace-newtab" = false; + "zen.view.compact.hide-toolbar" = true; + "zen.view.sidebar-expanded" = false; + "zen.view.use-single-toolbar" = false; + "zen.welcome-screen.seen" = true; + "zen.workspaces.container-specific-essentials-enabled" = true; + "zen.workspaces.force-container-workspace" = true; + "zen.workspaces.hide-deactivated-workspaces" = true; + "zen.workspaces.individual-pinned-tabs" = false; + "zen.workspaces.show-icon-strip" = false; + }; + } + ]; + + home = { + activation = { + # HACK: Zen only recognizes profiles that include the ZenAvatarPath key + update-zen-browser-profile = lib.home-manager.hm.dag.entryAfter ["writeBoundary"] '' + run sed -i \ + 's|\[Profile\([0-9]*\)\]|[Profile\1]\nZenAvatarPath=chrome://browser/content/zen-avatars/avatar-95.svg|' \ + "$HOME/.zen/profiles.ini" + ''; + }; + + file = { + ".zen/profiles.ini" = { + force = true; + }; + }; + }; + } + ]; + }; +}