1{
2 config,
3 pkgs,
4 lib,
5 ...
6}:
7
8let
9 prg = config.programs;
10 cfg = prg.thefuck;
11
12 bashAndZshInitScript = ''
13 eval $(${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias})
14 '';
15 fishInitScript = ''
16 ${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias} | source
17 '';
18in
19{
20 options = {
21 programs.thefuck = {
22 enable = lib.mkEnableOption "thefuck, an app which corrects your previous console command";
23
24 alias = lib.mkOption {
25 default = "fuck";
26 type = lib.types.str;
27
28 description = ''
29 `thefuck` needs an alias to be configured.
30 The default value is `fuck`, but you can use anything else as well.
31 '';
32 };
33 };
34 };
35
36 config = lib.mkIf cfg.enable {
37 environment.systemPackages = with pkgs; [ thefuck ];
38
39 programs.bash.interactiveShellInit = bashAndZshInitScript;
40 programs.zsh.interactiveShellInit = lib.mkIf prg.zsh.enable bashAndZshInitScript;
41 programs.fish.interactiveShellInit = lib.mkIf prg.fish.enable fishInitScript;
42 };
43}