mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
halloy: add themes option (#7043)
This commit is contained in:
@@ -10,11 +10,12 @@ let
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.programs.halloy;
|
||||
|
||||
formatter = pkgs.formats.toml { };
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||
@@ -23,7 +24,7 @@ in
|
||||
enable = mkEnableOption "halloy";
|
||||
package = mkPackageOption pkgs "halloy" { nullable = true; };
|
||||
settings = mkOption {
|
||||
type = formatter.type;
|
||||
inherit (tomlFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
"buffer.channel.topic".enabled = true;
|
||||
@@ -38,12 +39,57 @@ in
|
||||
found here: <https://halloy.chat/configuration/index.html>.
|
||||
'';
|
||||
};
|
||||
themes = mkOption {
|
||||
type = types.attrsOf (
|
||||
types.oneOf [
|
||||
tomlFormat.type
|
||||
types.lines
|
||||
types.path
|
||||
]
|
||||
);
|
||||
default = { };
|
||||
example = {
|
||||
general = {
|
||||
background = "<string>";
|
||||
border = "<string>";
|
||||
horizontal_rule = "<string>";
|
||||
unread_indicator = "<string>";
|
||||
};
|
||||
text = {
|
||||
primary = "<string>";
|
||||
secondary = "<string>";
|
||||
tertiary = "<string>";
|
||||
success = "<string>";
|
||||
error = "<string>";
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Each theme is written to {file}`$XDG_CONFIG_HOME/halloy/themes/NAME.toml`.
|
||||
See <https://halloy.chat/configuration/themes/index.html> for more information.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
xdg.configFile."halloy/config.toml" = mkIf (cfg.settings != { }) {
|
||||
source = formatter.generate "halloy-config" cfg.settings;
|
||||
};
|
||||
xdg.configFile = lib.mkMerge [
|
||||
{
|
||||
"halloy/config.toml" = mkIf (cfg.settings != { }) {
|
||||
source = tomlFormat.generate "halloy-config" cfg.settings;
|
||||
};
|
||||
}
|
||||
(lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "halloy/themes/${name}.toml" {
|
||||
source =
|
||||
if lib.isString value then
|
||||
pkgs.writeText "halloy-theme-${name}" value
|
||||
else if builtins.isPath value || lib.isStorePath value then
|
||||
value
|
||||
else
|
||||
tomlFormat.generate "halloy-theme-${name}" value;
|
||||
}
|
||||
) cfg.themes)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,11 +9,29 @@
|
||||
channels = [ "#halloy" ];
|
||||
};
|
||||
};
|
||||
themes.my-theme = {
|
||||
general = {
|
||||
background = "<string>";
|
||||
border = "<string>";
|
||||
horizontal_rule = "<string>";
|
||||
unread_indicator = "<string>";
|
||||
};
|
||||
text = {
|
||||
primary = "<string>";
|
||||
secondary = "<string>";
|
||||
tertiary = "<string>";
|
||||
success = "<string>";
|
||||
error = "<string>";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/halloy/config.toml
|
||||
assertFileContent home-files/.config/halloy/config.toml \
|
||||
${./example-config.toml}
|
||||
${./example-config.toml}
|
||||
assertFileExists home-files/.config/halloy/themes/my-theme.toml
|
||||
assertFileContent home-files/.config/halloy/themes/my-theme.toml \
|
||||
${./my-theme.toml}
|
||||
'';
|
||||
}
|
||||
|
||||
12
tests/modules/programs/halloy/my-theme.toml
Normal file
12
tests/modules/programs/halloy/my-theme.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[general]
|
||||
background = "<string>"
|
||||
border = "<string>"
|
||||
horizontal_rule = "<string>"
|
||||
unread_indicator = "<string>"
|
||||
|
||||
[text]
|
||||
error = "<string>"
|
||||
primary = "<string>"
|
||||
secondary = "<string>"
|
||||
success = "<string>"
|
||||
tertiary = "<string>"
|
||||
Reference in New Issue
Block a user