mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
opencode: make the themes also accept path
- Removed unnecessary empty-themes test.
This commit is contained in:
parent
fddb33a1a5
commit
6ea30b26cd
5 changed files with 31 additions and 18 deletions
|
|
@ -141,10 +141,13 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
themes = mkOption {
|
themes = mkOption {
|
||||||
inherit (jsonFormat) type;
|
type = lib.types.attrsOf (lib.types.either jsonFormat.type lib.types.path);
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
Custom themes for opencode. The attribute name becomes the theme filename.
|
Custom themes for opencode. The attribute name becomes the theme
|
||||||
|
filename, and the value is either:
|
||||||
|
- An attribute set, that is converted to a json
|
||||||
|
- A path to a file conaining the content
|
||||||
Themes are stored in {file}`$XDG_CONFIG_HOME/opencode/themes/` directory.
|
Themes are stored in {file}`$XDG_CONFIG_HOME/opencode/themes/` directory.
|
||||||
Set `programs.opencode.settings.theme` to enable the custom theme.
|
Set `programs.opencode.settings.theme` to enable the custom theme.
|
||||||
See <https://opencode.ai/docs/themes/> for the documentation.
|
See <https://opencode.ai/docs/themes/> for the documentation.
|
||||||
|
|
@ -188,14 +191,21 @@ in
|
||||||
) cfg.agents
|
) cfg.agents
|
||||||
// lib.mapAttrs' (
|
// lib.mapAttrs' (
|
||||||
name: content:
|
name: content:
|
||||||
lib.nameValuePair "opencode/themes/${name}.json" {
|
lib.nameValuePair "opencode/themes/${name}.json" (
|
||||||
source = jsonFormat.generate "opencode-${name}.json" (
|
if lib.isPath content then
|
||||||
{
|
{
|
||||||
"$schema" = "https://opencode.ai/theme.json";
|
source = content;
|
||||||
}
|
}
|
||||||
// content
|
else
|
||||||
);
|
{
|
||||||
}
|
source = jsonFormat.generate "opencode-${name}.json" (
|
||||||
|
{
|
||||||
|
"$schema" = "https://opencode.ai/theme.json";
|
||||||
|
}
|
||||||
|
// content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
) cfg.themes;
|
) cfg.themes;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,6 @@
|
||||||
opencode-agents-path = ./agents-path.nix;
|
opencode-agents-path = ./agents-path.nix;
|
||||||
opencode-commands-path = ./commands-path.nix;
|
opencode-commands-path = ./commands-path.nix;
|
||||||
opencode-mixed-content = ./mixed-content.nix;
|
opencode-mixed-content = ./mixed-content.nix;
|
||||||
opencode-themes = ./themes.nix;
|
opencode-themes-inline = ./themes-inline.nix;
|
||||||
|
opencode-themes-path = ./themes-path.nix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
programs.opencode = {
|
|
||||||
enable = true;
|
|
||||||
themes = { };
|
|
||||||
};
|
|
||||||
nmt.script = ''
|
|
||||||
assertPathNotExists home-files/.config/opencode/themes
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
11
tests/modules/programs/opencode/themes-path.nix
Normal file
11
tests/modules/programs/opencode/themes-path.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/opencode/themes/my-theme.json
|
||||||
|
assertFileContent home-files/.config/opencode/themes/my-theme.json \
|
||||||
|
${./my-theme.json}
|
||||||
|
'';
|
||||||
|
programs.opencode = {
|
||||||
|
enable = true;
|
||||||
|
themes.my-theme = ./my-theme.json;
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue