mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 06:59:45 +01:00
wezterm: support color schemes
Allows users to specify TOML color schemes using Nix.
This commit is contained in:
parent
8675cfa549
commit
44dcad5604
2 changed files with 84 additions and 5 deletions
|
@ -5,6 +5,7 @@ with lib;
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.programs.wezterm;
|
cfg = config.programs.wezterm;
|
||||||
|
tomlFormat = pkgs.formats.toml { };
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.programs.wezterm = {
|
options.programs.wezterm = {
|
||||||
|
@ -44,13 +45,45 @@ in {
|
||||||
how to configure.
|
how to configure.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
colorSchemes = mkOption {
|
||||||
|
type = types.attrsOf (tomlFormat.type);
|
||||||
|
default = { };
|
||||||
|
example = literalExpression ''
|
||||||
|
myCoolTheme = {
|
||||||
|
ansi = [
|
||||||
|
"#222222" "#D14949" "#48874F" "#AFA75A"
|
||||||
|
"#599797" "#8F6089" "#5C9FA8" "#8C8C8C"
|
||||||
|
];
|
||||||
|
brights = [
|
||||||
|
"#444444" "#FF6D6D" "#89FF95" "#FFF484"
|
||||||
|
"#97DDFF" "#FDAAF2" "#85F5DA" "#E9E9E9"
|
||||||
|
];
|
||||||
|
background = "#1B1B1B";
|
||||||
|
cursor_bg = "#BEAF8A";
|
||||||
|
cursor_border = "#BEAF8A";
|
||||||
|
cursor_fg = "#1B1B1B";
|
||||||
|
foreground = "#BEAF8A";
|
||||||
|
selection_bg = "#444444";
|
||||||
|
selection_fg = "#E9E9E9";
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Attribute set of additional color schemes to be written to
|
||||||
|
<filename>$XDG_CONFIG_HOME/wezterm/colors</filename>, where each key is
|
||||||
|
taken as the name of the corresponding color scheme. See
|
||||||
|
<link xlink:href="https://wezfurlong.org/wezterm/config/appearance.html#defining-a-color-scheme-in-a-separate-file"/>
|
||||||
|
for more details of the TOML color scheme format.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile."wezterm/wezterm.lua" = {
|
xdg.configFile = {
|
||||||
text = ''
|
"wezterm/wezterm.lua".text = ''
|
||||||
-- Generated by Home Manager.
|
-- Generated by Home Manager.
|
||||||
-- See https://wezfurlong.org/wezterm/
|
-- See https://wezfurlong.org/wezterm/
|
||||||
|
|
||||||
|
@ -60,6 +93,9 @@ in {
|
||||||
|
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
'';
|
'';
|
||||||
};
|
} // mapAttrs' (name: value:
|
||||||
|
nameValuePair "wezterm/colors/${name}.toml" {
|
||||||
|
source = tomlFormat.generate "${name}.toml" { colors = value; };
|
||||||
|
}) cfg.colorSchemes;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,41 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
colorSchemes.test = {
|
||||||
|
ansi = [
|
||||||
|
"#222222"
|
||||||
|
"#D14949"
|
||||||
|
"#48874F"
|
||||||
|
"#AFA75A"
|
||||||
|
"#599797"
|
||||||
|
"#8F6089"
|
||||||
|
"#5C9FA8"
|
||||||
|
"#8C8C8C"
|
||||||
|
];
|
||||||
|
brights = [
|
||||||
|
"#444444"
|
||||||
|
"#FF6D6D"
|
||||||
|
"#89FF95"
|
||||||
|
"#FFF484"
|
||||||
|
"#97DDFF"
|
||||||
|
"#FDAAF2"
|
||||||
|
"#85F5DA"
|
||||||
|
"#E9E9E9"
|
||||||
|
];
|
||||||
|
background = "#1B1B1B";
|
||||||
|
cursor_bg = "#BEAF8A";
|
||||||
|
cursor_border = "#BEAF8A";
|
||||||
|
cursor_fg = "#1B1B1B";
|
||||||
|
foreground = "#BEAF8A";
|
||||||
|
selection_bg = "#444444";
|
||||||
|
selection_fg = "#E9E9E9";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
test.stubs.wezterm = { };
|
test.stubs.wezterm = { };
|
||||||
|
|
||||||
nmt.script = let
|
nmt.script = let
|
||||||
expected = builtins.toFile "wezterm.lua" ''
|
expectedConfig = builtins.toFile "wezterm.lua" ''
|
||||||
-- Generated by Home Manager.
|
-- Generated by Home Manager.
|
||||||
-- See https://wezfurlong.org/wezterm/
|
-- See https://wezfurlong.org/wezterm/
|
||||||
|
|
||||||
|
@ -40,8 +69,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
expectedColorScheme = builtins.toFile "test.toml" ''
|
||||||
|
[colors]
|
||||||
|
ansi = ["#222222", "#D14949", "#48874F", "#AFA75A", "#599797", "#8F6089", "#5C9FA8", "#8C8C8C"]
|
||||||
|
background = "#1B1B1B"
|
||||||
|
brights = ["#444444", "#FF6D6D", "#89FF95", "#FFF484", "#97DDFF", "#FDAAF2", "#85F5DA", "#E9E9E9"]
|
||||||
|
cursor_bg = "#BEAF8A"
|
||||||
|
cursor_border = "#BEAF8A"
|
||||||
|
cursor_fg = "#1B1B1B"
|
||||||
|
foreground = "#BEAF8A"
|
||||||
|
selection_bg = "#444444"
|
||||||
|
selection_fg = "#E9E9E9"
|
||||||
|
'';
|
||||||
in ''
|
in ''
|
||||||
assertFileExists home-files/.config/wezterm/wezterm.lua
|
assertFileExists home-files/.config/wezterm/wezterm.lua
|
||||||
assertFileContent home-files/.config/wezterm/wezterm.lua ${expected}
|
assertFileContent home-files/.config/wezterm/wezterm.lua ${expectedConfig}
|
||||||
|
assertFileExists home-files/.config/wezterm/colors/test.toml
|
||||||
|
assertFileContent home-files/.config/wezterm/colors/test.toml ${expectedColorScheme}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue