1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-16 16:19:44 +01:00
home-manager/modules/programs/thefuck.nix
Gabe Dunn 3e1f8df4f0
thefuck: add instant mode option
Also do a slight code cleanup.
2023-10-17 17:30:37 +02:00

51 lines
1.2 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
{
meta.maintainers = [ hm.maintainers.ilaumjd ];
options.programs.thefuck = {
enable = mkEnableOption
"thefuck - magnificent app that corrects your previous console command";
package = mkPackageOption pkgs "thefuck" { };
enableInstantMode = mkEnableOption "thefuck's experimental instant mode";
enableBashIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable Bash integration.
'';
};
enableZshIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable Zsh integration.
'';
};
};
config = let
cfg = config.programs.thefuck;
cliArgs = cli.toGNUCommandLineShell { } {
alias = true;
enable-experimental-instant-mode = cfg.enableInstantMode;
};
shEvalCmd = ''
eval "$(${cfg.package}/bin/thefuck ${cliArgs})"
'';
in mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration shEvalCmd;
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shEvalCmd;
};
}