diff --git a/modules/programs/vivid.nix b/modules/programs/vivid.nix index cdb77fc40..b50b69b65 100644 --- a/modules/programs/vivid.nix +++ b/modules/programs/vivid.nix @@ -80,7 +80,7 @@ in }; themes = mkOption { - type = with types; attrsOf path; + type = with types; attrsOf (either path yamlFormat.type); default = { }; example = lib.literalExpression '' { @@ -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 = @@ -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 '' diff --git a/tests/modules/programs/vivid/example-config.nix b/tests/modules/programs/vivid/example-config.nix index e46f0ab21..dd4c1c13f 100644 --- a/tests/modules/programs/vivid/example-config.nix +++ b/tests/modules/programs/vivid/example-config.nix @@ -26,6 +26,7 @@ themes = { ayu = ./themes/ayu.yml; mocha = ./themes/mocha.yml; + tiny = import ./themes/tiny.nix; }; }; @@ -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} ''; } diff --git a/tests/modules/programs/vivid/themes/tiny.nix b/tests/modules/programs/vivid/themes/tiny.nix new file mode 100644 index 000000000..aee7769ce --- /dev/null +++ b/tests/modules/programs/vivid/themes/tiny.nix @@ -0,0 +1,15 @@ +{ + colors = { + primary = "00aaff"; + secondary = "ff00aa"; + }; + core = { + directory = { + foreground = "primary"; + }; + "executable-file" = { + foreground = "secondary"; + "font-style" = "bold"; + }; + }; +} diff --git a/tests/modules/programs/vivid/themes/tiny.yml b/tests/modules/programs/vivid/themes/tiny.yml new file mode 100644 index 000000000..c8d435fcb --- /dev/null +++ b/tests/modules/programs/vivid/themes/tiny.yml @@ -0,0 +1,9 @@ +colors: + primary: 00aaff + secondary: ff00aa +core: + directory: + foreground: primary + executable-file: + font-style: bold + foreground: secondary