2023-12-17 19:17:59 +01:00
|
|
|
# References:
|
|
|
|
# * https://github.com/drduh/YubiKey-Guide
|
|
|
|
# * https://nixos.wiki/wiki/Yubikey
|
2024-08-29 03:26:04 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2023-12-17 19:17:59 +01:00
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
|
|
|
|
options.components.yubikey.enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# todo move this tho home manager
|
|
|
|
config = mkIf config.components.yubikey.enable {
|
|
|
|
|
|
|
|
services.pcscd.enable = true;
|
2024-05-27 10:48:38 +02:00
|
|
|
services.udev.packages = [ pkgs.yubikey-personalization ];
|
2023-12-17 19:17:59 +01:00
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
|
2024-08-14 16:43:55 +02:00
|
|
|
pkgs.yubikey-personalization
|
|
|
|
pkgs.yubikey-personalization-gui
|
|
|
|
pkgs.yubikey-manager
|
|
|
|
pkgs.yubikey-manager-qt
|
|
|
|
|
2023-12-17 19:17:59 +01:00
|
|
|
# for `gpg --export $keyid | hokey lint` to check keys
|
|
|
|
#pkgs.haskellPackages.hopenpgp-tools
|
|
|
|
|
|
|
|
# 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/
|
|
|
|
${pkgs.gnupg}/bin/gpg --card-status
|
|
|
|
echo "now the new key should work"
|
|
|
|
'')
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|