diff --git a/modules/home-manager/all-modules.nix b/modules/home-manager/all-modules.nix index d4e30b15..c454879d 100644 --- a/modules/home-manager/all-modules.nix +++ b/modules/home-manager/all-modules.nix @@ -8,6 +8,7 @@ ./btop.nix ./cava.nix ./chrome.nix + ./cosmic.nix ./cursors.nix ./delta.nix ./dunst.nix diff --git a/modules/home-manager/cosmic.nix b/modules/home-manager/cosmic.nix new file mode 100644 index 00000000..4bbc3fac --- /dev/null +++ b/modules/home-manager/cosmic.nix @@ -0,0 +1,85 @@ +{ catppuccinLib }: +{ config, lib, ... }: +{ + options.catppuccin = { + cosmic-desktop = catppuccinLib.mkCatppuccinOption { + accentSupport = true; + name = "cosmic-desktop"; + }; + + cosmic-term = catppuccinLib.mkCatppuccinOption { name = "cosmic-term"; }; + }; + + config = + let + cfg = config.catppuccin; + in + lib.mkMerge [ + (lib.mkIf cfg.cosmic-desktop.enable { + wayland.desktopManager.cosmic.components.config = + let + version = 1; + in + { + "com.system76.CosmicTheme.Dark.Builder" = { + inherit version; + entries = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-settings/catppuccin-${cfg.cosmic-desktop.flavor}-${cfg.cosmic-desktop.accent}+round.ron"; + }; + + "com.system76.CosmicTheme.Light.Builder" = { + inherit version; + entries = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-settings/catppuccin-latte-${cfg.cosmic-desktop.accent}+round.ron"; + }; + + "com.system76.CosmicTheme.Mode" = { + inherit version; + entries.is_dark = cfg.cosmic-desktop.flavor != "latte"; + }; + }; + }) + + (lib.mkIf cfg.cosmic-term.enable { + wayland.desktopManager.cosmic.components.config."com.system76.CosmicTerm" = { + version = 1; + + entries = + let + existingDark = + config.wayland.desktopManager.cosmic.components.config."com.system76.CosmicTerm".entries.color_schemes_dark.attrs + or [ ]; + existingLight = + config.wayland.desktopManager.cosmic.components.config."com.system76.CosmicTerm".entries.color_schemes_light.attrs + or [ ]; + maxDarkKey = + if existingDark == [ ] then -1 else lib.foldl lib.max (-1) (map (t: t.key) existingDark); + maxLightKey = + if existingLight == [ ] then -1 else lib.foldl lib.max (-1) (map (t: t.key) existingLight); + darkTheme = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-term/catppuccin-${cfg.cosmic-term.flavor}.ron"; + lightTheme = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-term/catppuccin-latte.ron"; + in + { + color_schemes_dark = lib.ron.mkMap ( + existingDark + ++ [ + { + key = maxDarkKey + 1; + value = darkTheme; + } + ] + ); + color_schemes_light = lib.ron.mkMap ( + existingLight + ++ [ + { + key = maxLightKey + 1; + value = lightTheme; + } + ] + ); + syntax_theme_dark = darkTheme.name; + syntax_theme_light = lightTheme.name; + }; + }; + }) + ]; +} diff --git a/pkgs/sources.json b/pkgs/sources.json index 2809cffe..d633982e 100644 --- a/pkgs/sources.json +++ b/pkgs/sources.json @@ -34,6 +34,11 @@ "lastModified": "2024-09-03", "rev": "0746f77974330338ee2e1e4d1ef9872eba57eb26" }, + "cosmic-desktop": { + "hash": "sha256-NAQnHS+XrMJ/rPgSS5nEQOMBhQtF6mP1i/0QP5arQ64=", + "lastModified": "2025-04-22", + "rev": "95e81098042dd2102f0b258f6990f886c5759692" + }, "cursors": { "hash": "sha256-qis6p+/m7+DdRDYzLq9yB2eZGpfZe5z5xRsa/1HoIG4=", "lastModified": "2025-02-22",