fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Gabe Dunnthefuck: add instant mode option3e1f8df4

master
1.2 KiB51 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5{
6  meta.maintainers = [ hm.maintainers.ilaumjd ];
7
8  options.programs.thefuck = {
9    enable = mkEnableOption
10      "thefuck - magnificent app that corrects your previous console command";
11
12    package = mkPackageOption pkgs "thefuck" { };
13
14    enableInstantMode = mkEnableOption "thefuck's experimental instant mode";
15
16    enableBashIntegration = mkOption {
17      default = true;
18      type = types.bool;
19      description = ''
20        Whether to enable Bash integration.
21      '';
22    };
23
24    enableZshIntegration = mkOption {
25      default = true;
26      type = types.bool;
27      description = ''
28        Whether to enable Zsh integration.
29      '';
30    };
31  };
32
33  config = let
34    cfg = config.programs.thefuck;
35
36    cliArgs = cli.toGNUCommandLineShell { } {
37      alias = true;
38      enable-experimental-instant-mode = cfg.enableInstantMode;
39    };
40
41    shEvalCmd = ''
42      eval "$(${cfg.package}/bin/thefuck ${cliArgs})"
43    '';
44  in mkIf cfg.enable {
45    home.packages = [ cfg.package ];
46
47    programs.bash.initExtra = mkIf cfg.enableBashIntegration shEvalCmd;
48
49    programs.zsh.initExtra = mkIf cfg.enableZshIntegration shEvalCmd;
50  };
51}