feat: support custom icons (#196)

Resolves https://github.com/0xc000022070/zen-browser-flake/issues/195.
This commit is contained in:
Luis Quiñones
2026-01-10 08:39:23 -05:00
committed by GitHub
parent 8b2302d8c1
commit 6cc402ae03
2 changed files with 20 additions and 2 deletions

View File

@@ -71,6 +71,12 @@ in {
description = "Extra preferences to be included.";
};
icon = mkOption {
type = types.nullOr (types.either types.str types.path);
default = null;
description = "Icon to be used for the application. It's only expected to work on Linux.";
};
profiles = mkOption {
type = with types;
attrsOf (
@@ -280,6 +286,12 @@ in {
};
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.icon == null || pkgs.stdenv.isLinux;
message = "The 'icon' option is only supported on Linux.";
}
];
programs.zen-browser = {
package = lib.mkDefault (
(pkgs.wrapFirefox (self.packages.${pkgs.stdenv.hostPlatform.system}."${name}-unwrapped".override {
@@ -288,7 +300,9 @@ in {
policies = cfg.policies;
}) {
icon =
if name == "beta"
if cfg.icon != null
then cfg.icon
else if name == "beta"
then "zen-browser"
else "zen-${name}";
}).override

View File

@@ -1,6 +1,7 @@
{
name,
variant,
icon ? null,
policies ? {},
lib,
stdenv,
@@ -138,7 +139,10 @@ in
name = binaryName;
desktopName = "Zen Browser${lib.optionalString (name == "twilight") " Twilight"}";
exec = "${binaryName} %u";
icon = desktopIconName;
icon =
if icon != null && (lib.isString icon || lib.isPath icon)
then icon
else desktopIconName;
type = "Application";
mimeTypes = [
"text/html"