Optionalize mkTarget's 'humanName' and 'name' arguments by inferring 'humanName' from the 'name' attribute in the /modules/<MODULE>/meta.nix file, and 'name' from the /modules/<NAME>/ directory name. Inferring the 'humanName' and 'name' arguments ensures consistency and reduces boilerplate. The 'humanName' and 'name' arguments are optionalized instead of removed because complex modules generating target derivations need to distinguish between them. Closes: https://github.com/nix-community/stylix/issues/1661
188 lines
5.4 KiB
Nix
188 lines
5.4 KiB
Nix
{
|
|
mkTarget,
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
mkTarget {
|
|
options.luaBody = lib.mkOption {
|
|
type = lib.types.lines;
|
|
default = "";
|
|
internal = true;
|
|
};
|
|
config = [
|
|
(
|
|
{ colors }:
|
|
with colors;
|
|
{
|
|
programs.wezterm.colorSchemes.stylix = {
|
|
ansi = [
|
|
base00
|
|
base08
|
|
base0B
|
|
base0A
|
|
base0D
|
|
base0E
|
|
base0C
|
|
base05
|
|
];
|
|
brights = [
|
|
base03
|
|
base08
|
|
base0B
|
|
base0A
|
|
base0D
|
|
base0E
|
|
base0C
|
|
base07
|
|
];
|
|
background = base00;
|
|
cursor_bg = base05;
|
|
cursor_fg = base00;
|
|
compose_cursor = base06;
|
|
foreground = base05;
|
|
scrollbar_thumb = base01;
|
|
selection_bg = base05;
|
|
selection_fg = base00;
|
|
split = base03;
|
|
visual_bell = base09;
|
|
tab_bar = {
|
|
background = base01;
|
|
inactive_tab_edge = base01;
|
|
active_tab = {
|
|
bg_color = base00;
|
|
fg_color = base05;
|
|
};
|
|
inactive_tab = {
|
|
bg_color = base03;
|
|
fg_color = base05;
|
|
};
|
|
inactive_tab_hover = {
|
|
bg_color = base05;
|
|
fg_color = base00;
|
|
};
|
|
new_tab = {
|
|
bg_color = base03;
|
|
fg_color = base05;
|
|
};
|
|
new_tab_hover = {
|
|
bg_color = base05;
|
|
fg_color = base00;
|
|
};
|
|
};
|
|
};
|
|
stylix.targets.wezterm.luaBody = ''
|
|
color_scheme = "stylix",
|
|
window_frame = {
|
|
active_titlebar_bg = "${base03}",
|
|
active_titlebar_fg = "${base05}",
|
|
active_titlebar_border_bottom = "${base03}",
|
|
border_left_color = "${base01}",
|
|
border_right_color = "${base01}",
|
|
border_bottom_color = "${base01}",
|
|
border_top_color = "${base01}",
|
|
button_bg = "${base01}",
|
|
button_fg = "${base05}",
|
|
button_hover_bg = "${base05}",
|
|
button_hover_fg = "${base03}",
|
|
inactive_titlebar_bg = "${base01}",
|
|
inactive_titlebar_fg = "${base05}",
|
|
inactive_titlebar_border_bottom = "${base03}",
|
|
},
|
|
colors = {
|
|
tab_bar = {
|
|
background = "${base01}",
|
|
inactive_tab_edge = "${base01}",
|
|
active_tab = {
|
|
bg_color = "${base00}",
|
|
fg_color = "${base05}",
|
|
},
|
|
inactive_tab = {
|
|
bg_color = "${base03}",
|
|
fg_color = "${base05}",
|
|
},
|
|
inactive_tab_hover = {
|
|
bg_color = "${base05}",
|
|
fg_color = "${base00}",
|
|
},
|
|
new_tab = {
|
|
bg_color = "${base03}",
|
|
fg_color = "${base05}",
|
|
},
|
|
new_tab_hover = {
|
|
bg_color = "${base05}",
|
|
fg_color = "${base00}",
|
|
},
|
|
},
|
|
},
|
|
command_palette_bg_color = "${base01}",
|
|
command_palette_fg_color = "${base05}",
|
|
'';
|
|
}
|
|
)
|
|
(
|
|
{ fonts }:
|
|
{
|
|
stylix.targets.wezterm.luaBody = ''
|
|
font = wezterm.font_with_fallback {
|
|
"${fonts.monospace.name}",
|
|
"${fonts.emoji.name}",
|
|
},
|
|
font_size = ${toString fonts.sizes.terminal},
|
|
command_palette_font_size = ${toString fonts.sizes.popups},
|
|
'';
|
|
}
|
|
)
|
|
(
|
|
{ opacity }:
|
|
{
|
|
stylix.targets.wezterm.luaBody = "window_background_opacity = ${toString opacity.terminal},";
|
|
}
|
|
)
|
|
(
|
|
{ cfg }:
|
|
let
|
|
indent =
|
|
string: " " + lib.concatStringsSep "\n " (lib.splitString "\n" string);
|
|
in
|
|
{
|
|
xdg.configFile."wezterm/wezterm.lua" =
|
|
lib.mkIf (config.programs.wezterm.enable && cfg.luaBody != "")
|
|
{
|
|
text = lib.mkForce (
|
|
lib.concatLines [
|
|
''
|
|
-- Generated by Stylix
|
|
local wezterm = require("wezterm")
|
|
wezterm.add_to_config_reload_watch_list(wezterm.config_dir)
|
|
-- Allow working with both the current release and the nightly
|
|
local config = {}
|
|
if wezterm.config_builder then
|
|
config = wezterm.config_builder()
|
|
end
|
|
local stylix_base_config = {
|
|
''
|
|
(indent cfg.luaBody)
|
|
''
|
|
}
|
|
for key, value in pairs(stylix_base_config) do
|
|
config[key] = value
|
|
end
|
|
local function stylix_wrapped_config()
|
|
${config.programs.wezterm.extraConfig}
|
|
end
|
|
local stylix_user_config = stylix_wrapped_config()
|
|
if stylix_user_config then
|
|
for key, value in pairs(stylix_user_config) do
|
|
config[key] = value
|
|
end
|
|
end
|
|
return config
|
|
''
|
|
]
|
|
);
|
|
};
|
|
}
|
|
)
|
|
];
|
|
}
|