Skip to content

Commit

Permalink
Merge pull request #121085 from colemickens/gpg-ccid-udev
Browse files Browse the repository at this point in the history
nixos/hardware/gnupg-ccid: init udev rules
  • Loading branch information
stigtsp authored Dec 10, 2021
2 parents e817802 + 58a85eb commit 8f21565
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions nixos/modules/hardware/gpgsmartcards.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ config, lib, pkgs, ... }:

with lib;
let
# gnupg's manual describes how to setup ccid udev rules:
# https://www.gnupg.org/howtos/card-howto/en/ch02s03.html
# gnupg folks advised me (https://dev.gnupg.org/T5409) to look at debian's rules:
# https://salsa.debian.org/debian/gnupg2/-/blob/debian/main/debian/scdaemon.udev

# the latest rev of the entire debian gnupg2 repo as of 2021-04-28
# the scdaemon.udev file was last commited on 2021-01-05 (7817a03):
scdaemonUdevRev = "01898735a015541e3ffb43c7245ac1e612f40836";

scdaemonRules = pkgs.fetchurl {
url = "https://salsa.debian.org/debian/gnupg2/-/raw/${scdaemonUdevRev}/debian/scdaemon.udev";
sha256 = "08v0vp6950bz7galvc92zdss89y9vcwbinmbfcdldy8x72w6rqr3";
};

# per debian's udev deb hook (https://man7.org/linux/man-pages/man1/dh_installudev.1.html)
destination = "60-scdaemon.rules";

scdaemonUdevRulesPkg = pkgs.runCommandNoCC "scdaemon-udev-rules" {} ''
loc="$out/lib/udev/rules.d/"
mkdir -p "''${loc}"
cp "${scdaemonRules}" "''${loc}/${destination}"
'';

cfg = config.hardware.gpgSmartcards;
in {
options.hardware.gpgSmartcards = {
enable = mkEnableOption "udev rules for gnupg smart cards";
};

config = mkIf cfg.enable {
services.udev.packages = [ scdaemonUdevRulesPkg ];
};
}
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
./hardware/device-tree.nix
./hardware/gkraken.nix
./hardware/flirc.nix
./hardware/gpgsmartcards.nix
./hardware/i2c.nix
./hardware/sensor/hddtemp.nix
./hardware/sensor/iio.nix
Expand Down

0 comments on commit 8f21565

Please sign in to comment.