2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-01-11 21:56:01 +00:00
|
|
|
|
2014-03-21 22:52:24 +00:00
|
|
|
let
|
|
|
|
cfgFile = pkgs.writeText "reader.conf" "";
|
|
|
|
in
|
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2010-01-11 21:56:01 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
services.pcscd = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the PCSC-Lite daemon.";
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.pcscd.enable {
|
|
|
|
|
2014-04-12 03:58:21 +01:00
|
|
|
systemd.sockets.pcscd = {
|
|
|
|
description = "PCSC-Lite Socket";
|
|
|
|
wantedBy = [ "sockets.target" ];
|
|
|
|
before = [ "multi-user.target" ];
|
|
|
|
socketConfig.ListenStream = "/run/pcscd/pcscd.comm";
|
|
|
|
};
|
|
|
|
|
2014-03-21 22:52:24 +00:00
|
|
|
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";
|
2014-04-12 03:58:21 +01:00
|
|
|
ExecStart = "${pkgs.pcsclite}/sbin/pcscd --auto-exit -c ${cfgFile}";
|
|
|
|
ExecReload = "${pkgs.pcsclite}/sbin/pcscd --hotplug";
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
2014-03-21 22:52:24 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
}
|