Skip to content

Commit 6adddc1

Browse files
committed
vivid: modify themes option with custom nix entries
1 parent d305eec commit 6adddc1

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

modules/programs/vivid.nix

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ in
8080
};
8181

8282
themes = mkOption {
83-
type = with types; attrsOf path;
83+
type = with types; attrsOf (either path yamlFormat.type);
8484
default = { };
8585
example = lib.literalExpression ''
8686
{
@@ -93,10 +93,27 @@ in
9393
url = "https://raw.githubusercontent.com/NearlyTRex/Vivid/refs/heads/master/themes/catppuccin-mocha.yml";
9494
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
9595
};
96+
97+
my-custom-theme = {
98+
colors = {
99+
blue = "0000ff";
100+
};
101+
core = {
102+
directory = {
103+
foreground = "blue";
104+
font-style = "bold";
105+
};
106+
};
107+
};
96108
}
97109
'';
98-
description = "Theme for vivid";
110+
description = ''
111+
An attribute set of vivid themes.
112+
Each value can either be a path to a theme file or an attribute set
113+
defining the theme directly (which will be converted from Nix to YAML).
114+
'';
99115
};
116+
100117
};
101118

102119
config =
@@ -116,7 +133,10 @@ in
116133
};
117134
}
118135
// (lib.mapAttrs' (
119-
name: path: lib.nameValuePair "vivid/themes/${name}.yml" { source = path; }
136+
name: value:
137+
lib.nameValuePair "vivid/themes/${name}.yml" {
138+
source = if lib.isAttrs value then yamlFormat.generate "${name}.yml" value else value;
139+
}
120140
) cfg.themes);
121141

122142
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''

tests/modules/programs/vivid/example-config.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
themes = {
2727
ayu = ./themes/ayu.yml;
2828
mocha = ./themes/mocha.yml;
29+
tiny = import ./themes/tiny.nix;
2930
};
3031
};
3132

@@ -41,5 +42,9 @@
4142
assertFileExists home-files/.config/vivid/themes/mocha.yml
4243
assertFileContent home-files/.config/vivid/themes/mocha.yml \
4344
${./themes/mocha.yml}
45+
46+
assertFileExists home-files/.config/vivid/themes/tiny.yml
47+
assertFileContent home-files/.config/vivid/themes/tiny.yml \
48+
${./themes/tiny.yml}
4449
'';
4550
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
colors = {
3+
primary = "00aaff";
4+
secondary = "ff00aa";
5+
};
6+
core = {
7+
directory = {
8+
foreground = "primary";
9+
};
10+
"executable-file" = {
11+
foreground = "secondary";
12+
"font-style" = "bold";
13+
};
14+
};
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
colors:
2+
primary: 00aaff
3+
secondary: ff00aa
4+
core:
5+
directory:
6+
foreground: primary
7+
executable-file:
8+
font-style: bold
9+
foreground: secondary

0 commit comments

Comments
 (0)