{ pkgs, ... }: { # Create the plugdev group (required for user-space USB access to YubiKey) users.groups.plugdev = {}; # Enable PC/SC daemon — required for GPG smartcard (gpg --card-status) and YubiKey services.pcscd.enable = true; # udev rules so the YubiKey gets plugdev group ownership and correct permissions services.udev.packages = with pkgs; [ yubikey-personalization libu2f-host ]; # Give pcscd access to the YubiKey CCID USB interface (interface 1 on FIDO+CCID devices) services.udev.extraRules = '' SUBSYSTEM=="usb", ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0406", MODE="0666" ''; # CCID driver for smartcard access # NixOS's services.pcscd.plugins does not populate /var/lib/pcsc/drivers, # so we symlink the ifd-ccid.bundle from the ccid package directly. system.activationScripts.pcscdSetup = '' mkdir -p /var/lib/pcsc/drivers rm -rf /var/lib/pcsc/drivers/ifd-ccid.bundle 2>/dev/null || true ln -sf "${pkgs.ccid}/pcsc/drivers/ifd-ccid.bundle" /var/lib/pcsc/drivers/ifd-ccid.bundle ''; # YubiKey management tools environment.systemPackages = with pkgs; [ yubikey-manager # ykman CLI yubikey-personalization # ykpers / ykchalresp yubico-piv-tool # PIV applet management ]; }