1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-02 15:11:03 +01:00

vicinae: update theme filetype (#8141)

As of v0.15.0, theme files use TOML instead of JSON and have a new structure.

The test actually didn't previously assert the existence of a theme file even though the example settings had a theme in them...
This commit is contained in:
Devin Droddy 2025-11-09 15:49:57 -05:00 committed by GitHub
parent be4a9233dd
commit b8645b18b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 100 additions and 55 deletions

View file

@ -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.
'';
}

View file

@ -8,6 +8,10 @@ let
cfg = config.programs.vicinae; cfg = config.programs.vicinae;
jsonFormat = pkgs.formats.json { }; 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 in
{ {
meta.maintainers = [ lib.maintainers.leiserfg ]; meta.maintainers = [ lib.maintainers.leiserfg ];
@ -73,35 +77,47 @@ in
}; };
themes = lib.mkOption { themes = lib.mkOption {
inherit (jsonFormat) type; inherit (tomlFormat) type;
default = { }; default = { };
description = '' 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 <https://docs.vicinae.com/theming/getting-started> for supported values.
The attribute name of the theme will be the name of theme json file, The attribute name of the theme will be the name of theme file,
e.g. `base16-default-dark` will be `base16-default-dark.json`. e.g. `base16-default-dark` will be `base16-default-dark.toml` (or `.json` if vicinae version is < 0.15.0).
''; '';
example = example =
lib.literalExpression # nix lib.literalExpression # nix
'' ''
# vicinae >= 0.15.0
{ {
base16-default-dark = { catppuccin-mocha = {
version = "1.0.0"; meta = {
appearance = "dark"; version = 1;
icon = /path/to/icon.png; name = "Catppuccin Mocha";
name = "base16 default dark"; description = "Cozy feeling with color-rich accents";
description = "base16 default dark by Chris Kempson"; variant = "dark";
palette = { icon = "icons/catppuccin-mocha.png";
background = "#181818"; inherits = "vicinae-dark";
foreground = "#d8d8d8"; };
blue = "#7cafc2";
green = "#a3be8c"; colors = {
magenta = "#ba8baf"; core = {
orange = "#dc9656"; background = "#1E1E2E";
purple = "#a16946"; foreground = "#CDD6F4";
red = "#ab4642"; secondary_background = "#181825";
yellow = "#f7ca88"; border = "#313244";
cyan = "#86c1b9"; accent = "#89B4FA";
};
accents = {
blue = "#89B4FA";
green = "#A6E3A1";
magenta = "#F5C2E7";
orange = "#FAB387";
purple = "#CBA6F7";
red = "#F38BA8";
yellow = "#F9E2AF";
cyan = "#94E2D5";
};
}; };
}; };
} }
@ -197,25 +213,33 @@ in
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg = { 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 = { configFile = {
"vicinae/vicinae.json" = lib.mkIf (cfg.settings != { }) { "vicinae/vicinae.json" = lib.mkIf (cfg.settings != { }) {
source = jsonFormat.generate "vicinae-settings" cfg.settings; source = jsonFormat.generate "vicinae-settings" cfg.settings;
}; };
} }
// lib.mapAttrs' ( // lib.optionalAttrs (!themeIsToml) themeFiles;
name: theme:
lib.nameValuePair "vicinae/themes/${name}.json" {
source = jsonFormat.generate "vicinae-${name}-theme" theme;
}
) cfg.themes;
dataFile = builtins.listToAttrs ( dataFile =
builtins.listToAttrs (
builtins.map (item: { builtins.map (item: {
name = "vicinae/extensions/${item.name}"; name = "vicinae/extensions/${item.name}";
value.source = item; value.source = item;
}) cfg.extensions }) cfg.extensions
); )
// lib.optionalAttrs themeIsToml themeFiles;
}; };
systemd.user.services.vicinae = lib.mkIf (cfg.systemd.enable && cfg.package != null) { systemd.user.services.vicinae = lib.mkIf (cfg.systemd.enable && cfg.package != null) {

View file

@ -28,22 +28,34 @@
}; };
}; };
themes = { themes = {
base16-default-dark = { catppuccin-mocha = {
version = "1.0.0"; meta = {
appearance = "dark"; version = 1;
name = "base16 default dark"; name = "Catppuccin Mocha";
description = "base16 default dark by Chris Kempson"; description = "Cozy feeling with color-rich accents";
palette = { variant = "dark";
background = "#181818"; icon = "icons/catppuccin-mocha.png";
foreground = "#d8d8d8"; inherits = "vicinae-dark";
blue = "#7cafc2"; };
green = "#a3be8c";
magenta = "#ba8baf"; colors = {
orange = "#dc9656"; core = {
purple = "#a16946"; background = "#1E1E2E";
red = "#ab4642"; foreground = "#CDD6F4";
yellow = "#f7ca88"; secondary_background = "#181825";
cyan = "#86c1b9"; 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 = '' nmt.script = ''
assertFileExists "home-files/.config/vicinae/vicinae.json" assertFileExists "home-files/.config/vicinae/vicinae.json"
assertFileExists "home-files/.config/systemd/user/vicinae.service" 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/gif-search/package.json"
assertFileExists "home-files/.local/share/vicinae/extensions/test-extension/package.json" assertFileExists "home-files/.local/share/vicinae/extensions/test-extension/package.json"
''; '';