diff options
author | Stig <stig@stig.io> | 2021-12-10 14:22:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 14:22:06 +0100 |
commit | 8f215659013838d254d356b6e28b8044c3104936 (patch) | |
tree | 54f2f3c6579ed09e94efe26ca4edc0e7aaba8ad6 /nixos/modules/hardware | |
parent | e817802236920008e46b6493b08200026157fef9 (diff) | |
parent | 58a85eb2224de21dbaaed73afaf5d321140b4834 (diff) | |
download | nixpkgs-8f215659013838d254d356b6e28b8044c3104936.tar nixpkgs-8f215659013838d254d356b6e28b8044c3104936.tar.gz nixpkgs-8f215659013838d254d356b6e28b8044c3104936.tar.bz2 nixpkgs-8f215659013838d254d356b6e28b8044c3104936.tar.lz nixpkgs-8f215659013838d254d356b6e28b8044c3104936.tar.xz nixpkgs-8f215659013838d254d356b6e28b8044c3104936.tar.zst nixpkgs-8f215659013838d254d356b6e28b8044c3104936.zip |
Merge pull request #121085 from colemickens/gpg-ccid-udev
nixos/hardware/gnupg-ccid: init udev rules
Diffstat (limited to 'nixos/modules/hardware')
-rw-r--r-- | nixos/modules/hardware/gpgsmartcards.nix | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/nixos/modules/hardware/gpgsmartcards.nix b/nixos/modules/hardware/gpgsmartcards.nix new file mode 100644 index 00000000000..6e5fcda6b85 --- /dev/null +++ b/nixos/modules/hardware/gpgsmartcards.nix @@ -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 ]; + }; +} |