1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-26 03:39:47 +01:00
home-manager/modules/programs/thefuck.nix
Gabe Dunn 2ca2163ece
thefuck: add instant mode option
Also do a slight code cleanup.
2024-04-10 21:26:28 +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;
};
}