feat(gnupg): allow gpg as ssh-agent

Deactivate regular ssh-agent in NixOS confifurations
This commit is contained in:
Yorick Barbanneau 2025-04-04 23:56:13 +02:00
parent b4c25d7497
commit 141df5608d
3 changed files with 25 additions and 23 deletions

View file

@ -12,14 +12,19 @@ in
default = true;
description = "install password-store";
};
enableSshSupport = mkOption {
type = types.bool;
default = false;
description = "enable GnuPG agent SSH support";
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
# pinentry-gnome
gcr
];
home.packages = with pkgs; [
# pinentry-gnome
gcr
];
programs.gpg = {
enable = true;
scdaemonSettings = {
@ -31,9 +36,17 @@ in
enable = true;
enableScDaemon = true;
enableZshIntegration = true;
pinentry.package = pkgs.pinentry-gnome3;
pinentryPackage = pkgs.pinentry-gnome3;
enableSshSupport = cfg.enableSshSupport;
};
home.sessionVariablesExtra = lib.mkIf cfg.enableSshSupport ''
if [[ -z "''${SSH_AUTH_SOCK}" ]]; then
export SSH_AUTH_SOCK="$(${config.programs.gpg.package}/bin/gpgconf --list-dirs agent-ssh-socket)"
fi
'';
services.ssh-agent.enable = if cfg.enableSshSupport then false else true;
programs.password-store = {
enable = cfg.pass;
};