1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-04 06:42:33 +03:00
nixpkgs/nixos/modules/programs/thefuck.nix

44 lines
1,021 B
Nix
Raw Normal View History

{
config,
pkgs,
lib,
...
}:
2017-06-14 10:57:38 +02:00
let
prg = config.programs;
cfg = prg.thefuck;
bashAndZshInitScript = ''
eval $(${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias})
'';
fishInitScript = ''
${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias} | source
'';
2017-06-14 10:57:38 +02:00
in
{
options = {
programs.thefuck = {
enable = lib.mkEnableOption "thefuck, an app which corrects your previous console command";
2017-06-14 10:57:38 +02:00
alias = lib.mkOption {
default = "fuck";
type = lib.types.str;
2017-06-14 10:57:38 +02:00
description = ''
`thefuck` needs an alias to be configured.
The default value is `fuck`, but you can use anything else as well.
'';
2017-06-14 10:57:38 +02:00
};
};
};
2017-06-14 10:57:38 +02:00
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ thefuck ];
programs.bash.interactiveShellInit = bashAndZshInitScript;
programs.zsh.interactiveShellInit = lib.mkIf prg.zsh.enable bashAndZshInitScript;
programs.fish.interactiveShellInit = lib.mkIf prg.fish.enable fishInitScript;
};
}