mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
zellij: add themes option (#7031)
This commit is contained in:
parent
ff915842e4
commit
5daf23a38f
3 changed files with 120 additions and 12 deletions
|
|
@ -71,6 +71,21 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
themes = mkOption {
|
||||
type = types.attrsOf (
|
||||
types.oneOf [
|
||||
yamlFormat.type
|
||||
types.path
|
||||
types.lines
|
||||
]
|
||||
);
|
||||
default = { };
|
||||
description = ''
|
||||
Each them is written to {file}`$XDG_CONFIG_HOME/zellij/themes/NAME.kdl`.
|
||||
See <https://zellij.dev/documentation/themes.html> for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
enableBashIntegration = mkShellIntegrationOption (
|
||||
lib.hm.shell.mkBashIntegrationOption { inherit config; }
|
||||
);
|
||||
|
|
@ -95,17 +110,32 @@ in
|
|||
|
||||
# Zellij switched from yaml to KDL in version 0.32.0:
|
||||
# https://github.com/zellij-org/zellij/releases/tag/v0.32.0
|
||||
xdg.configFile."zellij/config.yaml" =
|
||||
mkIf (cfg.settings != { } && (lib.versionOlder cfg.package.version "0.32.0"))
|
||||
{
|
||||
source = yamlFormat.generate "zellij.yaml" cfg.settings;
|
||||
};
|
||||
|
||||
xdg.configFile."zellij/config.kdl" =
|
||||
mkIf (cfg.settings != { } && (lib.versionAtLeast cfg.package.version "0.32.0"))
|
||||
{
|
||||
text = lib.hm.generators.toKDL { } cfg.settings;
|
||||
};
|
||||
xdg.configFile = lib.mkMerge [
|
||||
{
|
||||
"zellij/config.yaml" =
|
||||
mkIf (cfg.settings != { } && (lib.versionOlder cfg.package.version "0.32.0"))
|
||||
{
|
||||
source = yamlFormat.generate "zellij.yaml" cfg.settings;
|
||||
};
|
||||
"zellij/config.kdl" =
|
||||
mkIf (cfg.settings != { } && (lib.versionAtLeast cfg.package.version "0.32.0"))
|
||||
{
|
||||
text = lib.hm.generators.toKDL { } cfg.settings;
|
||||
};
|
||||
}
|
||||
(lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "zellij/themes/${name}.kdl" {
|
||||
source =
|
||||
if builtins.isPath value || lib.isStorePath value then
|
||||
value
|
||||
else
|
||||
pkgs.writeText "zellij-theme-${name}" (
|
||||
if lib.isString value then value else lib.hm.generators.toKDL { } value
|
||||
);
|
||||
}
|
||||
) cfg.themes)
|
||||
];
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||
eval "$(${lib.getExe cfg.package} setup --generate-auto-start bash)"
|
||||
|
|
|
|||
|
|
@ -1 +1,4 @@
|
|||
{ zellij-enable-shells = ./enable-shells.nix; }
|
||||
{
|
||||
zellij-enable-shells = ./enable-shells.nix;
|
||||
zellij-theme = ./theme.nix;
|
||||
}
|
||||
|
|
|
|||
75
tests/modules/programs/zellij/theme.nix
Normal file
75
tests/modules/programs/zellij/theme.nix
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
programs.zellij = {
|
||||
enable = true;
|
||||
themes = {
|
||||
example.themes.example = {
|
||||
ribbon_unselected = {
|
||||
base = [
|
||||
0
|
||||
0
|
||||
0
|
||||
];
|
||||
background = [
|
||||
255
|
||||
153
|
||||
0
|
||||
];
|
||||
emphasis_0 = [
|
||||
255
|
||||
53
|
||||
94
|
||||
];
|
||||
emphasis_1 = [
|
||||
255
|
||||
255
|
||||
255
|
||||
];
|
||||
emphasis_2 = [
|
||||
0
|
||||
217
|
||||
227
|
||||
];
|
||||
emphasis_3 = [
|
||||
255
|
||||
0
|
||||
255
|
||||
];
|
||||
};
|
||||
};
|
||||
text = ''
|
||||
themes {
|
||||
example {
|
||||
ribbon_unselected {
|
||||
background 255 153 0
|
||||
base 0 0 0
|
||||
emphasis_0 255 53 94
|
||||
emphasis_1 255 255 255
|
||||
emphasis_2 0 217 227
|
||||
emphasis_3 255 0 255
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/zellij/themes/example.kdl
|
||||
assertFileContent home-files/.config/zellij/themes/text.kdl \
|
||||
${pkgs.writeText "theme-text-expected" ''
|
||||
themes {
|
||||
example {
|
||||
ribbon_unselected {
|
||||
background 255 153 0
|
||||
base 0 0 0
|
||||
emphasis_0 255 53 94
|
||||
emphasis_1 255 255 255
|
||||
emphasis_2 0 217 227
|
||||
emphasis_3 255 0 255
|
||||
}
|
||||
}
|
||||
}
|
||||
''}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue