From 180158b46ea02f1c8f794367f122e8f2a2e49cf8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 27 Jul 2024 09:08:30 +0200 Subject: [PATCH] mcfly: add settings option --- modules/programs/mcfly.nix | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/programs/mcfly.nix b/modules/programs/mcfly.nix index 450a2738..d0dddba2 100644 --- a/modules/programs/mcfly.nix +++ b/modules/programs/mcfly.nix @@ -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 + . + ''; + }; + 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;