2019-10-24 02:20:38 +02:00
|
|
|
# References:
|
|
|
|
# * https://github.com/drduh/YubiKey-Guide
|
|
|
|
# * https://nixos.wiki/wiki/Yubikey
|
2019-12-20 05:54:26 +01:00
|
|
|
{ pkgs, ... }: {
|
2020-01-15 09:29:01 +01:00
|
|
|
|
2019-10-24 02:20:38 +02:00
|
|
|
services.pcscd.enable = true;
|
|
|
|
services.udev.packages = [
|
|
|
|
|
|
|
|
pkgs.yubikey-personalization
|
|
|
|
|
|
|
|
# additional services, but I just want gpg
|
|
|
|
# pkgs.libu2f-host
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
|
|
|
|
# for `gpg --export $keyid | hokey lint` to check keys
|
2019-10-26 13:46:37 +02:00
|
|
|
#pkgs.haskellPackages.hopenpgp-tools
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
# for otp keys (but I use pass otp)
|
|
|
|
# pkgs.yubioath-desktop
|
|
|
|
|
|
|
|
(pkgs.writers.writeDashBin "gpg-reset-yubikey-id" ''
|
|
|
|
echo "reset gpg to make new key available"
|
|
|
|
set -x
|
|
|
|
set -e
|
|
|
|
${pkgs.psmisc}/bin/killall gpg-agent
|
|
|
|
rm -r ~/.gnupg/private-keys-v1.d/
|
|
|
|
echo "now the new key should work"
|
|
|
|
'')
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
# use gpg for ssh
|
|
|
|
# ---------------
|
|
|
|
environment.shellInit = ''
|
|
|
|
export GPG_TTY="$(tty)"
|
|
|
|
gpg-connect-agent /bye
|
|
|
|
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
|
|
|
|
'';
|
|
|
|
programs = {
|
|
|
|
ssh.startAgent = false;
|
|
|
|
gnupg.agent = {
|
|
|
|
enable = true;
|
|
|
|
enableSSHSupport = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-01-15 09:29:01 +01:00
|
|
|
# use for pam (sudo)
|
|
|
|
# --------------------------
|
|
|
|
security.pam.u2f.enable = true;
|
|
|
|
security.pam.u2f.authFile = toString <desktop_secrets/yubikey/u2fAuthFile>;
|
2019-10-24 02:20:38 +02:00
|
|
|
}
|