2020-04-24 23:36:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
prg = config.programs;
|
|
|
|
cfg = prg.thefuck;
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
bashAndZshInitScript = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
eval $(${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias})
|
|
|
|
'';
|
2022-04-27 09:35:20 +00:00
|
|
|
fishInitScript = ''
|
|
|
|
${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias} | source
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
programs.thefuck = {
|
|
|
|
enable = mkEnableOption "thefuck";
|
|
|
|
|
|
|
|
alias = mkOption {
|
|
|
|
default = "fuck";
|
|
|
|
type = types.str;
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
`thefuck` needs an alias to be configured.
|
|
|
|
The default value is `fuck`, but you can use anything else as well.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = with pkgs; [ thefuck ];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
programs.bash.interactiveShellInit = bashAndZshInitScript;
|
|
|
|
programs.zsh.interactiveShellInit = mkIf prg.zsh.enable bashAndZshInitScript;
|
|
|
|
programs.fish.interactiveShellInit = mkIf prg.fish.enable fishInitScript;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|