nixpkgs/nixos/modules/programs/pay-respects.nix
Fernando Rodrigues c346fd5125
nixos/pay-respects: fix interactiveShellInit for fish and zsh
Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
2024-11-15 17:56:54 +00:00

58 lines
1.3 KiB
Nix

{
config,
pkgs,
lib,
...
}:
let
inherit (lib)
getExe
maintainers
mkEnableOption
mkIf
mkOption
optionalString
types
;
inherit (types) str;
cfg = config.programs.pay-respects;
initScript =
shell:
if (shell != "fish") then
''
eval $(${getExe pkgs.pay-respects} ${shell} --alias ${cfg.alias})
''
else
''
${getExe pkgs.pay-respects} ${shell} --alias ${cfg.alias} | source
'';
in
{
options = {
programs.pay-respects = {
enable = mkEnableOption "pay-respects, an app which corrects your previous console command";
alias = mkOption {
default = "f";
type = str;
description = ''
`pay-respects` needs an alias to be configured.
The default value is `f`, but you can use anything else as well.
'';
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.pay-respects ];
programs = {
bash.interactiveShellInit = initScript "bash";
fish.interactiveShellInit = optionalString config.programs.fish.enable (initScript "fish");
zsh.interactiveShellInit = optionalString config.programs.zsh.enable (initScript "zsh");
};
};
meta.maintainers = with maintainers; [ sigmasquadron ];
}