typioca: 2.7.0 -> 2.8.0
[NixPkgs.git] / nixos / modules / programs / thefuck.nix
blobe057d1ca657de21248a0baf2e2b2329f80285234
1 { config, pkgs, lib, ... }:
3 with lib;
5 let
6   prg = config.programs;
7   cfg = prg.thefuck;
9   bashAndZshInitScript = ''
10     eval $(${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias})
11   '';
12   fishInitScript = ''
13     ${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias} | source
14   '';
16   {
17     options = {
18       programs.thefuck = {
19         enable = mkEnableOption (lib.mdDoc "thefuck");
21         alias = mkOption {
22           default = "fuck";
23           type = types.str;
25           description = lib.mdDoc ''
26             `thefuck` needs an alias to be configured.
27             The default value is `fuck`, but you can use anything else as well.
28           '';
29         };
30       };
31     };
33     config = mkIf cfg.enable {
34       environment.systemPackages = with pkgs; [ thefuck ];
36       programs.bash.interactiveShellInit = bashAndZshInitScript;
37       programs.zsh.interactiveShellInit = mkIf prg.zsh.enable bashAndZshInitScript;
38       programs.fish.interactiveShellInit = mkIf prg.fish.enable fishInitScript;
39     };
40   }