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;
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 <https://docs.vicinae.com/theming/getting-started> 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,25 +213,33 @@ in
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 = {
"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;
}
) cfg.themes;
// lib.optionalAttrs (!themeIsToml) themeFiles;
dataFile = builtins.listToAttrs (
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) {

View file

@ -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"
'';