1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

rio: add support for custom themes

This commit is contained in:
Hoang Nguyen 2025-11-03 00:35:27 +07:00 committed by Austin Horstman
parent e22fb25cde
commit 9d6e28fd32
4 changed files with 64 additions and 0 deletions

View file

@ -28,6 +28,25 @@ in
<https://raphamorim.io/rio/docs/#configuration-file> for options. <https://raphamorim.io/rio/docs/#configuration-file> for options.
''; '';
}; };
themes = lib.mkOption {
type = with lib.types; attrsOf (either settingsFormat.type path);
default = { };
description = ''
Theme files written to {file}`$XDG_CONFIG_HOME/rio/themes/`. See
<https://rioterm.com/docs/config#building-your-own-theme> for
supported values.
'';
example = lib.literalExpression ''
{
foobar.colors = {
background = "#282a36";
green = "#50fa7b";
dim-green = "#06572f";
};
}
'';
};
}; };
meta.maintainers = [ lib.maintainers.otavio ]; meta.maintainers = [ lib.maintainers.otavio ];
@ -42,6 +61,16 @@ in
xdg.configFile."rio/config.toml".source = xdg.configFile."rio/config.toml".source =
if lib.isPath cfg.settings then cfg.settings else settingsFormat.generate "rio.toml" cfg.settings; if lib.isPath cfg.settings then cfg.settings else settingsFormat.generate "rio.toml" cfg.settings;
}) })
(lib.mkIf (cfg.themes != { }) {
xdg.configFile = lib.mapAttrs' (
name: value:
lib.nameValuePair "rio/themes/${name}.toml" {
source =
if builtins.isPath value then value else settingsFormat.generate "rio-theme-${name}.toml" value;
}
) cfg.themes;
})
] ]
); );
} }

View file

@ -1,4 +1,5 @@
{ {
rio-example-settings = ./example-settings.nix; rio-example-settings = ./example-settings.nix;
rio-empty-settings = ./empty-settings.nix; rio-empty-settings = ./empty-settings.nix;
rio-themes = ./example-themes.nix;
} }

View file

@ -0,0 +1,30 @@
{ config, ... }:
{
programs.rio = {
enable = true;
package = config.lib.test.mkStubPackage { };
themes = {
foobar.colors = {
cyan = "#8be9fd";
green = "#50fa7b";
background = "#282a36";
};
foobar2 = ./foobar.toml;
};
};
nmt.script = ''
assertFileExists home-files/.config/rio/themes/foobar.toml
assertFileExists home-files/.config/rio/themes/foobar2.toml
assertFileContent \
home-files/.config/rio/themes/foobar.toml \
${./foobar.toml}
assertFileContent \
home-files/.config/rio/themes/foobar2.toml \
${./foobar.toml}
'';
}

View file

@ -0,0 +1,4 @@
[colors]
background = "#282a36"
cyan = "#8be9fd"
green = "#50fa7b"