45 lines
1.3 KiB
Nix
45 lines
1.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
cfg = config.programs.helix;
|
|
inherit (cfg) extras;
|
|
tomlFormat = pkgs.formats.toml { };
|
|
inherit (lib) mkIf mkEnableOption mkOption types;
|
|
in
|
|
{
|
|
options.programs.helix.extras = {
|
|
autoTheme.enable = mkEnableOption "Automatically switch helix theme with night mode";
|
|
|
|
autoTheme.light = mkOption {
|
|
type = types.str;
|
|
description = "Light mode theme";
|
|
};
|
|
|
|
autoTheme.dark = mkOption {
|
|
type = types.str;
|
|
description = "Dark mode theme";
|
|
};
|
|
};
|
|
|
|
config = mkIf (cfg.enable && extras.autoTheme.enable) {
|
|
xdg.configFile = {
|
|
"helix/light.toml".source = tomlFormat.generate "helix-autotheme" (cfg.settings // { theme = extras.autoTheme.light; });
|
|
"helix/dark.toml".source = tomlFormat.generate "helix-autotheme" (cfg.settings // { theme = extras.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
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|