2019-10-14 13:11:43 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
{
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
yubikey-personalization
|
2020-01-11 20:00:01 +00:00
|
|
|
yubikey-manager
|
2019-10-14 13:11:43 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
services.udev.packages = with pkgs; [ yubikey-personalization ];
|
|
|
|
services.pcscd.enable = true;
|
2020-01-11 20:00:01 +00:00
|
|
|
systemd.user.sockets.gpg-agent-ssh.wantedBy = [ "sockets.target" ];
|
|
|
|
|
|
|
|
##restart pcscd if yubikey is plugged in
|
|
|
|
#services.udev.extraRules = ''
|
|
|
|
# ACTION=="add", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="2013", RUN+="${pkgs.writeDash "restart_pcscd" ''
|
|
|
|
# ${pkgs.systemd}/bin/systemctl restart pcscd.service
|
|
|
|
# ''}"
|
|
|
|
#'';
|
2019-10-14 13:11:43 +00:00
|
|
|
|
|
|
|
environment.shellInit = ''
|
2020-01-11 20:00:01 +00:00
|
|
|
if [ "$UID" -eq 1337 ] && [ -z "$SSH_CONNECTION" ]; then
|
2019-10-14 13:11:43 +00:00
|
|
|
export GPG_TTY="$(tty)"
|
2020-01-11 20:00:01 +00:00
|
|
|
gpg-connect-agent --quiet updatestartuptty /bye > /dev/null
|
2019-10-14 13:11:43 +00:00
|
|
|
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
|
2020-01-11 20:00:01 +00:00
|
|
|
if [ -z "$SSH_AUTH_SOCK" ]; then
|
|
|
|
export SSH_AUTH_SOCK=$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)
|
|
|
|
fi
|
|
|
|
|
2019-10-14 13:11:43 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
ssh.startAgent = false;
|
|
|
|
gnupg.agent = {
|
|
|
|
enable = true;
|
2020-01-11 20:00:01 +00:00
|
|
|
# enableSSHSupport = true;
|
2019-10-14 13:11:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|