Skip to content

Commit

Permalink
programs: add zen-browser
Browse files Browse the repository at this point in the history
Signed-off-by: Myned <[email protected]>
  • Loading branch information
Myned committed Feb 17, 2025
1 parent 786c090 commit 4b8f745
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 0 deletions.
6 changes: 6 additions & 0 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 25 additions & 0 deletions flake.in.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions options/custom/desktops/hyprland/rules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ in {
(class "^firefox.*$" rules)
(class "^google-chrome$" rules)
(class "^vivaldi.*$" rules)
(class "^zen$" rules)
];

clipboard = rules: [
Expand Down
1 change: 1 addition & 0 deletions options/custom/programs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ with lib; {
nautilus.enable = true;
nvtop.enable = true;
wezterm.enable = true;
zen-browser.enable = true;
})

(mkIf config.custom.full {
Expand Down
72 changes: 72 additions & 0 deletions options/custom/programs/firefox/zen-browser.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
};
}
];
};
}

0 comments on commit 4b8f745

Please sign in to comment.