2026-04-07 17:08:12 +02:00
|
|
|
{ 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
|
2026-04-07 17:24:19 +02:00
|
|
|
ccid
|
2026-04-07 17:08:12 +02:00
|
|
|
];
|
|
|
|
|
|
2026-04-07 17:18:53 +02:00
|
|
|
# CCID driver for smartcard access (required for YubiKey CCID functionality)
|
2026-04-07 17:24:19 +02:00
|
|
|
# Set up the PC/SC drivers directory with CCID driver bundle
|
|
|
|
|
system.activationScripts.pcscdSetup = ''
|
|
|
|
|
mkdir -p /var/lib/pcsc/drivers/ccid.bundle
|
|
|
|
|
# Try to symlink CCID bundle files if they exist
|
|
|
|
|
if [ -d "${pkgs.ccid}/lib/pcsc/drivers/ccid.bundle" ]; then
|
|
|
|
|
ln -sf "${pkgs.ccid}/lib/pcsc/drivers/ccid.bundle"/* /var/lib/pcsc/drivers/ccid.bundle/ 2>/dev/null || true
|
|
|
|
|
fi
|
|
|
|
|
'';
|
2026-04-07 17:18:53 +02:00
|
|
|
|
2026-04-07 17:08:12 +02:00
|
|
|
# YubiKey management tools
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
|
yubikey-manager # ykman CLI
|
|
|
|
|
yubikey-personalization # ykpers / ykchalresp
|
|
|
|
|
yubico-piv-tool # PIV applet management
|
|
|
|
|
];
|
|
|
|
|
}
|