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 = {
|
|
|
|
enable = mkEnableOption "thefuck";
|
|
|
|
|
|
|
|
alias = mkOption {
|
|
|
|
default = "fuck";
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.str;
|
2017-06-14 09:57:38 +01:00
|
|
|
|
|
|
|
description = ''
|
|
|
|
`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
|
|
|
};
|
|
|
|
}
|