|
| 1 | +{ catppuccinLib }: |
| 2 | +{ config, lib, ... }: |
| 3 | +{ |
| 4 | + options.catppuccin = { |
| 5 | + cosmic-desktop = catppuccinLib.mkCatppuccinOption { |
| 6 | + accentSupport = true; |
| 7 | + name = "cosmic-desktop"; |
| 8 | + }; |
| 9 | + |
| 10 | + cosmic-term = catppuccinLib.mkCatppuccinOption { name = "cosmic-term"; }; |
| 11 | + }; |
| 12 | + |
| 13 | + config = |
| 14 | + let |
| 15 | + cfg = config.catppuccin; |
| 16 | + in |
| 17 | + lib.mkMerge [ |
| 18 | + (lib.mkIf cfg.cosmic-desktop.enable { |
| 19 | + wayland.desktopManager.cosmic.components.config = |
| 20 | + let |
| 21 | + version = 1; |
| 22 | + in |
| 23 | + { |
| 24 | + "com.system76.CosmicTheme.Dark.Builder" = { |
| 25 | + inherit version; |
| 26 | + entries = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-settings/catppuccin-${cfg.cosmic-desktop.flavor}-${cfg.cosmic-desktop.accent}+round.ron"; |
| 27 | + }; |
| 28 | + |
| 29 | + "com.system76.CosmicTheme.Light.Builder" = { |
| 30 | + inherit version; |
| 31 | + entries = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-settings/catppuccin-latte-${cfg.cosmic-desktop.accent}+round.ron"; |
| 32 | + }; |
| 33 | + |
| 34 | + "com.system76.CosmicTheme.Mode" = { |
| 35 | + inherit version; |
| 36 | + entries.is_dark = cfg.cosmic-desktop.flavor != "latte"; |
| 37 | + }; |
| 38 | + }; |
| 39 | + }) |
| 40 | + |
| 41 | + (lib.mkIf cfg.cosmic-term.enable { |
| 42 | + wayland.desktopManager.cosmic.components.config."com.system76.CosmicTerm" = { |
| 43 | + version = 1; |
| 44 | + |
| 45 | + entries = |
| 46 | + let |
| 47 | + existingDark = |
| 48 | + config.wayland.desktopManager.cosmic.components.config."com.system76.CosmicTerm".entries.color_schemes_dark.attrs |
| 49 | + or [ ]; |
| 50 | + existingLight = |
| 51 | + config.wayland.desktopManager.cosmic.components.config."com.system76.CosmicTerm".entries.color_schemes_light.attrs |
| 52 | + or [ ]; |
| 53 | + maxDarkKey = |
| 54 | + if existingDark == [ ] then -1 else lib.foldl lib.max (-1) (map (t: t.key) existingDark); |
| 55 | + maxLightKey = |
| 56 | + if existingLight == [ ] then -1 else lib.foldl lib.max (-1) (map (t: t.key) existingLight); |
| 57 | + darkTheme = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-term/catppuccin-${cfg.cosmic-term.flavor}.ron"; |
| 58 | + lightTheme = lib.ron.importRON "${config.catppuccin.sources.cosmic-desktop}/themes/cosmic-term/catppuccin-latte.ron"; |
| 59 | + in |
| 60 | + { |
| 61 | + color_schemes_dark = lib.ron.mkMap ( |
| 62 | + existingDark |
| 63 | + ++ [ |
| 64 | + { |
| 65 | + key = maxDarkKey + 1; |
| 66 | + value = darkTheme; |
| 67 | + } |
| 68 | + ] |
| 69 | + ); |
| 70 | + color_schemes_light = lib.ron.mkMap ( |
| 71 | + existingLight |
| 72 | + ++ [ |
| 73 | + { |
| 74 | + key = maxLightKey + 1; |
| 75 | + value = lightTheme; |
| 76 | + } |
| 77 | + ] |
| 78 | + ); |
| 79 | + syntax_theme_dark = darkTheme.name; |
| 80 | + syntax_theme_light = lightTheme.name; |
| 81 | + }; |
| 82 | + }; |
| 83 | + }) |
| 84 | + ]; |
| 85 | +} |
0 commit comments