1 { config, lib, pkgs, ... }:
3 # gnupg's manual describes how to setup ccid udev rules:
4 # https://www.gnupg.org/howtos/card-howto/en/ch02s03.html
5 # gnupg folks advised me (https://dev.gnupg.org/T5409) to look at debian's rules:
6 # https://salsa.debian.org/debian/gnupg2/-/blob/debian/main/debian/scdaemon.udev
8 # the latest rev of the entire debian gnupg2 repo as of 2021-04-28
9 # the scdaemon.udev file was last committed on 2021-01-05 (7817a03):
10 scdaemonUdevRev = "01898735a015541e3ffb43c7245ac1e612f40836";
12 scdaemonRules = pkgs.fetchurl {
13 url = "https://salsa.debian.org/debian/gnupg2/-/raw/${scdaemonUdevRev}/debian/scdaemon.udev";
14 sha256 = "08v0vp6950bz7galvc92zdss89y9vcwbinmbfcdldy8x72w6rqr3";
17 # per debian's udev deb hook (https://man7.org/linux/man-pages/man1/dh_installudev.1.html)
18 destination = "60-scdaemon.rules";
20 scdaemonUdevRulesPkg = pkgs.runCommand "scdaemon-udev-rules" {} ''
21 loc="$out/lib/udev/rules.d/"
23 cp "${scdaemonRules}" "''${loc}/${destination}"
26 cfg = config.hardware.gpgSmartcards;
28 options.hardware.gpgSmartcards = {
29 enable = lib.mkEnableOption "udev rules for gnupg smart cards";
32 config = lib.mkIf cfg.enable {
33 services.udev.packages = [ scdaemonUdevRulesPkg ];