diff --git a/modules/misc/news/2025/11/2025-11-08_10-23-44.nix b/modules/misc/news/2025/11/2025-11-08_10-23-44.nix new file mode 100644 index 000000000..a02d19348 --- /dev/null +++ b/modules/misc/news/2025/11/2025-11-08_10-23-44.nix @@ -0,0 +1,8 @@ +{ config, ... }: +{ + time = "2025-11-08T15:23:44+00:00"; + condition = config.programs.vicinae.themes != { }; + message = '' + Vicinae theme definitions have been updated to a new format. See https://docs.vicinae.com/theming/getting-started for the new structure. + ''; +} diff --git a/modules/programs/vicinae.nix b/modules/programs/vicinae.nix index 726c68a08..0267f4fb0 100644 --- a/modules/programs/vicinae.nix +++ b/modules/programs/vicinae.nix @@ -8,6 +8,10 @@ let cfg = config.programs.vicinae; jsonFormat = pkgs.formats.json { }; + tomlFormat = pkgs.formats.toml { }; + + packageVersion = if cfg.package != null then lib.getVersion cfg.package else null; + themeIsToml = lib.versionAtLeast packageVersion "0.15.0"; in { meta.maintainers = [ lib.maintainers.leiserfg ]; @@ -73,35 +77,47 @@ in }; themes = lib.mkOption { - inherit (jsonFormat) type; + inherit (tomlFormat) type; default = { }; description = '' - Theme settings to add to the themes folder in `~/.config/vicinae/themes`. + Theme settings to add to the themes folder in `~/.config/vicinae/themes`. See for supported values. - The attribute name of the theme will be the name of theme json file, - e.g. `base16-default-dark` will be `base16-default-dark.json`. + The attribute name of the theme will be the name of theme file, + e.g. `base16-default-dark` will be `base16-default-dark.toml` (or `.json` if vicinae version is < 0.15.0). ''; example = lib.literalExpression # nix '' + # vicinae >= 0.15.0 { - base16-default-dark = { - version = "1.0.0"; - appearance = "dark"; - icon = /path/to/icon.png; - name = "base16 default dark"; - description = "base16 default dark by Chris Kempson"; - palette = { - background = "#181818"; - foreground = "#d8d8d8"; - blue = "#7cafc2"; - green = "#a3be8c"; - magenta = "#ba8baf"; - orange = "#dc9656"; - purple = "#a16946"; - red = "#ab4642"; - yellow = "#f7ca88"; - cyan = "#86c1b9"; + catppuccin-mocha = { + meta = { + version = 1; + name = "Catppuccin Mocha"; + description = "Cozy feeling with color-rich accents"; + variant = "dark"; + icon = "icons/catppuccin-mocha.png"; + inherits = "vicinae-dark"; + }; + + colors = { + core = { + background = "#1E1E2E"; + foreground = "#CDD6F4"; + secondary_background = "#181825"; + border = "#313244"; + accent = "#89B4FA"; + }; + accents = { + blue = "#89B4FA"; + green = "#A6E3A1"; + magenta = "#F5C2E7"; + orange = "#FAB387"; + purple = "#CBA6F7"; + red = "#F38BA8"; + yellow = "#F9E2AF"; + cyan = "#94E2D5"; + }; }; }; } @@ -197,26 +213,34 @@ in home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; - xdg = { - configFile = { - "vicinae/vicinae.json" = lib.mkIf (cfg.settings != { }) { - source = jsonFormat.generate "vicinae-settings" cfg.settings; - }; - } - // lib.mapAttrs' ( - name: theme: - lib.nameValuePair "vicinae/themes/${name}.json" { - source = jsonFormat.generate "vicinae-${name}-theme" theme; + xdg = + let + themeFormat = if themeIsToml then tomlFormat else jsonFormat; + themeExtension = if themeIsToml then "toml" else "json"; + themeFiles = lib.mapAttrs' ( + name: theme: + lib.nameValuePair "vicinae/themes/${name}.${themeExtension}" { + source = themeFormat.generate "vicinae-${name}-theme" theme; + } + ) cfg.themes; + in + { + configFile = { + "vicinae/vicinae.json" = lib.mkIf (cfg.settings != { }) { + source = jsonFormat.generate "vicinae-settings" cfg.settings; + }; } - ) cfg.themes; + // lib.optionalAttrs (!themeIsToml) themeFiles; - dataFile = builtins.listToAttrs ( - builtins.map (item: { - name = "vicinae/extensions/${item.name}"; - value.source = item; - }) cfg.extensions - ); - }; + dataFile = + builtins.listToAttrs ( + builtins.map (item: { + name = "vicinae/extensions/${item.name}"; + value.source = item; + }) cfg.extensions + ) + // lib.optionalAttrs themeIsToml themeFiles; + }; systemd.user.services.vicinae = lib.mkIf (cfg.systemd.enable && cfg.package != null) { Unit = { diff --git a/tests/modules/programs/vicinae/example-settings.nix b/tests/modules/programs/vicinae/example-settings.nix index b9de5f24f..3e914781e 100644 --- a/tests/modules/programs/vicinae/example-settings.nix +++ b/tests/modules/programs/vicinae/example-settings.nix @@ -28,22 +28,34 @@ }; }; themes = { - base16-default-dark = { - version = "1.0.0"; - appearance = "dark"; - name = "base16 default dark"; - description = "base16 default dark by Chris Kempson"; - palette = { - background = "#181818"; - foreground = "#d8d8d8"; - blue = "#7cafc2"; - green = "#a3be8c"; - magenta = "#ba8baf"; - orange = "#dc9656"; - purple = "#a16946"; - red = "#ab4642"; - yellow = "#f7ca88"; - cyan = "#86c1b9"; + catppuccin-mocha = { + meta = { + version = 1; + name = "Catppuccin Mocha"; + description = "Cozy feeling with color-rich accents"; + variant = "dark"; + icon = "icons/catppuccin-mocha.png"; + inherits = "vicinae-dark"; + }; + + colors = { + core = { + background = "#1E1E2E"; + foreground = "#CDD6F4"; + secondary_background = "#181825"; + border = "#313244"; + accent = "#89B4FA"; + }; + accents = { + blue = "#89B4FA"; + green = "#A6E3A1"; + magenta = "#F5C2E7"; + orange = "#FAB387"; + purple = "#CBA6F7"; + red = "#F38BA8"; + yellow = "#F9E2AF"; + cyan = "#94E2D5"; + }; }; }; }; @@ -71,6 +83,7 @@ nmt.script = '' assertFileExists "home-files/.config/vicinae/vicinae.json" assertFileExists "home-files/.config/systemd/user/vicinae.service" + assertFileExists "home-files/.local/share/vicinae/themes/catppuccin-mocha.toml" assertFileExists "home-files/.local/share/vicinae/extensions/gif-search/package.json" assertFileExists "home-files/.local/share/vicinae/extensions/test-extension/package.json" '';