keychain: add fish shell integration

The shell command is added in the interactiveShellInit, as it is the
equivalent of initExtra in bash or zsh.
This commit is contained in:
Julien Tanguy 2019-12-27 10:56:47 +01:00
parent 8d14ffbe88
commit 5992c1b469

View file

@ -10,9 +10,7 @@ let
++ optional (cfg.agents != []) "--agents ${concatStringsSep "," cfg.agents}" ++ optional (cfg.agents != []) "--agents ${concatStringsSep "," cfg.agents}"
++ optional (cfg.inheritType != null) "--inherit ${cfg.inheritType}"; ++ optional (cfg.inheritType != null) "--inherit ${cfg.inheritType}";
shellCommand = '' shellCommand = "${cfg.package}/bin/keychain --eval ${concatStringsSep " " flags} ${concatStringsSep " " cfg.keys}";
eval "$(${cfg.package}/bin/keychain --eval ${concatStringsSep " " flags} ${concatStringsSep " " cfg.keys})"
'';
in in
@ -71,6 +69,14 @@ in
''; '';
}; };
enableFishIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable Fish integration.
'';
};
enableZshIntegration = mkOption { enableZshIntegration = mkOption {
default = true; default = true;
type = types.bool; type = types.bool;
@ -82,7 +88,14 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration shellCommand; programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shellCommand; eval "$(${shellCommand})"
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
eval (${shellCommand})
'';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
eval "$(${shellCommand})"
'';
}; };
} }