Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions modules/programs/vivid.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ in
};

themes = mkOption {
type = with types; attrsOf path;
type = with types; attrsOf (either path yamlFormat.type);
default = { };
example = lib.literalExpression ''
{
Expand All @@ -93,10 +93,27 @@ in
url = "https://raw.githubusercontent.com/NearlyTRex/Vivid/refs/heads/master/themes/catppuccin-mocha.yml";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};

my-custom-theme = {
colors = {
blue = "0000ff";
};
core = {
directory = {
foreground = "blue";
font-style = "bold";
};
};
};
}
'';
description = "Theme for vivid";
description = ''
An attribute set of vivid themes.
Each value can either be a path to a theme file or an attribute set
defining the theme directly (which will be converted from Nix to YAML).
'';
};

};

config =
Expand All @@ -116,7 +133,10 @@ in
};
}
// (lib.mapAttrs' (
name: path: lib.nameValuePair "vivid/themes/${name}.yml" { source = path; }
name: value:
lib.nameValuePair "vivid/themes/${name}.yml" {
source = if lib.isAttrs value then yamlFormat.generate "${name}.yml" value else value;
}
) cfg.themes);

programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
Expand Down
5 changes: 5 additions & 0 deletions tests/modules/programs/vivid/example-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
themes = {
ayu = ./themes/ayu.yml;
mocha = ./themes/mocha.yml;
tiny = import ./themes/tiny.nix;
};
};

Expand All @@ -41,5 +42,9 @@
assertFileExists home-files/.config/vivid/themes/mocha.yml
assertFileContent home-files/.config/vivid/themes/mocha.yml \
${./themes/mocha.yml}

assertFileExists home-files/.config/vivid/themes/tiny.yml
assertFileContent home-files/.config/vivid/themes/tiny.yml \
${./themes/tiny.yml}
'';
}
15 changes: 15 additions & 0 deletions tests/modules/programs/vivid/themes/tiny.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
colors = {
primary = "00aaff";
secondary = "ff00aa";
};
core = {
directory = {
foreground = "primary";
};
"executable-file" = {
foreground = "secondary";
"font-style" = "bold";
};
};
}
9 changes: 9 additions & 0 deletions tests/modules/programs/vivid/themes/tiny.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
colors:
primary: 00aaff
secondary: ff00aa
core:
directory:
foreground: primary
executable-file:
font-style: bold
foreground: secondary