summary refs log tree commit diff
path: root/nixos/modules/services/hardware/pcscd.nix
blob: 6e30dfb752d2a464973c038ab6adfe65e6105ab8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ config, lib, pkgs, ... }:

let
  cfgFile = pkgs.writeText "reader.conf" "";
in

with lib;

{

  ###### interface

  options = {

    services.pcscd = {

      enable = mkOption {
        default = false;
        description = "Whether to enable the PCSC-Lite daemon.";
      };

    };

  };


  ###### implementation

  config = mkIf config.services.pcscd.enable {

    systemd.sockets.pcscd = {
      description = "PCSC-Lite Socket";
      wantedBy = [ "sockets.target" ];
      before = [ "multi-user.target" ];
      socketConfig.ListenStream = "/run/pcscd/pcscd.comm";
    };

    systemd.services.pcscd = {
      description = "PCSC-Lite daemon";
      preStart = ''
          mkdir -p /var/lib/pcsc
          rm -Rf /var/lib/pcsc/drivers
          ln -s ${pkgs.ccid}/pcsc/drivers /var/lib/pcsc/
      '';
      serviceConfig = {
        Type = "forking";
        ExecStart = "${pkgs.pcsclite}/sbin/pcscd --auto-exit -c ${cfgFile}";
        ExecReload = "${pkgs.pcsclite}/sbin/pcscd --hotplug";
      };
    };

  };

}