53 lines
1.2 KiB
Nix
53 lines
1.2 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.helix;
|
|
tomlFormat = pkgs.formats.toml { };
|
|
in
|
|
{
|
|
options.programs.helix = {
|
|
autoTheme = {
|
|
enable = lib.mkEnableOption "Automatically switch helix theme with night mode";
|
|
|
|
light = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Light mode theme";
|
|
};
|
|
|
|
dark = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Dark mode theme";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf (cfg.enable && cfg.autoTheme.enable) {
|
|
xdg.configFile = {
|
|
"helix/light.toml".source = tomlFormat.generate "helix-autotheme" (
|
|
cfg.settings // { theme = cfg.autoTheme.light; }
|
|
);
|
|
"helix/dark.toml".source = tomlFormat.generate "helix-autotheme" (
|
|
cfg.settings // { theme = cfg.autoTheme.dark; }
|
|
);
|
|
};
|
|
|
|
programs.fish.functions = {
|
|
hx = {
|
|
wraps = "hx";
|
|
description = "Helix invocation wrapper to automatically select the right theme";
|
|
body = ''
|
|
if is-dark-mode
|
|
command hx --config ${config.xdg.configHome}/helix/dark.toml $argv
|
|
else
|
|
command hx --config ${config.xdg.configHome}/helix/light.toml $argv
|
|
end
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|