1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

mcfly: add settings option

This commit is contained in:
Robert Helgesson 2024-07-27 09:08:30 +02:00
parent bc2b96acda
commit 180158b46e
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -5,6 +5,8 @@ let
cfg = config.programs.mcfly;
tomlFormat = pkgs.formats.toml { };
bashIntegration = ''
eval "$(${getExe pkgs.mcfly} init bash)"
'' + optionalString cfg.fzf.enable ''
@ -40,6 +42,37 @@ in {
options.programs.mcfly = {
enable = mkEnableOption "mcfly";
settings = mkOption {
type = tomlFormat.type;
default = { };
example = literalExpression ''
{
colors = {
menubar = {
bg = "black";
fg = "red";
};
darkmode = {
prompt = "cyan";
timing = "yellow";
results_selection_fg = "cyan";
results_selection_bg = "black";
results_selection_hl = "red";
};
};
}
'';
description = ''
Settings written to {file}`~/.config/mcfly/config.toml`.
Note, if your McFly database is currently in {file}`~/.mcfly`,
then this option has no effect.
Move the database to {file}`$XDG_DATA_DIR/mcfly/history.db` and
remove {file}`~/.mcfly` to make the settings take effect. See
<https://github.com/cantino/mcfly#database-location>.
'';
};
keyScheme = mkOption {
type = types.enum [ "emacs" "vim" ];
default = "emacs";
@ -105,6 +138,11 @@ in {
{
home.packages = [ pkgs.mcfly ] ++ optional cfg.fzf.enable pkgs.mcfly-fzf;
# Oddly enough, McFly expects this in the data path, not in config.
xdg.dataFile."mcfly/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "mcfly-config.toml" cfg.settings;
};
programs.bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration;
programs.zsh.initExtra = mkIf cfg.enableZshIntegration zshIntegration;