2017-06-14 09:57:38 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2017-07-23 08:22:33 +01:00
|
|
|
prg = config.programs;
|
|
|
|
cfg = prg.thefuck;
|
|
|
|
|
2022-05-01 17:00:18 +01:00
|
|
|
bashAndZshInitScript = ''
|
2017-07-23 08:22:33 +01:00
|
|
|
eval $(${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias})
|
|
|
|
'';
|
2022-05-01 17:00:18 +01:00
|
|
|
fishInitScript = ''
|
|
|
|
${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias} | source
|
|
|
|
'';
|
2017-06-14 09:57:38 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
programs.thefuck = {
|
2022-08-28 20:18:44 +01:00
|
|
|
enable = mkEnableOption (lib.mdDoc "thefuck");
|
2017-06-14 09:57:38 +01:00
|
|
|
|
|
|
|
alias = mkOption {
|
|
|
|
default = "fuck";
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.str;
|
2017-06-14 09:57:38 +01:00
|
|
|
|
2022-08-14 08:03:30 +01:00
|
|
|
description = lib.mdDoc ''
|
2017-06-14 09:57:38 +01: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 ];
|
2017-07-23 08:22:33 +01:00
|
|
|
|
2022-05-01 17:00:18 +01:00
|
|
|
programs.bash.interactiveShellInit = bashAndZshInitScript;
|
|
|
|
programs.zsh.interactiveShellInit = mkIf prg.zsh.enable bashAndZshInitScript;
|
|
|
|
programs.fish.interactiveShellInit = mkIf prg.fish.enable fishInitScript;
|
2017-06-14 09:57:38 +01:00
|
|
|
};
|
|
|
|
}
|