2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-01-11 21:56:01 +00:00
|
|
|
|
2016-06-04 11:07:09 +00:00
|
|
|
with lib;
|
|
|
|
|
2014-03-21 22:52:24 +00:00
|
|
|
let
|
2016-06-04 11:07:09 +00:00
|
|
|
cfgFile = pkgs.writeText "reader.conf" config.services.pcscd.readerConfig;
|
2014-03-21 22:52:24 +00:00
|
|
|
|
2016-06-04 11:07:09 +00:00
|
|
|
pluginEnv = pkgs.buildEnv {
|
|
|
|
name = "pcscd-plugins";
|
|
|
|
paths = map (p: "${p}/pcsc/drivers") config.services.pcscd.plugins;
|
|
|
|
};
|
2010-01-11 21:56:01 +00:00
|
|
|
|
2016-06-04 11:07:09 +00:00
|
|
|
in {
|
2010-01-11 21:56:01 +00:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
services.pcscd = {
|
2016-06-04 11:07:09 +00:00
|
|
|
enable = mkEnableOption "PCSC-Lite daemon";
|
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [ pkgs.ccid ];
|
|
|
|
defaultText = "[ pkgs.ccid ]";
|
|
|
|
example = literalExample "[ pkgs.pcsc-cyberjack ]";
|
|
|
|
description = "Plugin packages to be used for PCSC-Lite.";
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2016-06-04 11:07:09 +00:00
|
|
|
readerConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
FRIENDLYNAME "Some serial reader"
|
|
|
|
DEVICENAME /dev/ttyS0
|
|
|
|
LIBPATH /path/to/serial_reader.so
|
|
|
|
CHANNELID 1
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Configuration for devices that aren't hotpluggable.
|
|
|
|
|
|
|
|
See <citerefentry><refentrytitle>reader.conf</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for valid options.
|
|
|
|
'';
|
|
|
|
};
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-11 21:56:01 +00:00
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.pcscd.enable {
|
|
|
|
|
2014-04-12 02:58:21 +00: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";
|
2016-06-04 11:07:09 +00:00
|
|
|
environment.PCSCLITE_HP_DROPDIR = pluginEnv;
|
2014-03-21 22:52:24 +00:00
|
|
|
serviceConfig = {
|
2018-06-21 10:40:15 +00:00
|
|
|
ExecStart = "${getBin pkgs.pcsclite}/sbin/pcscd -f -x -c ${cfgFile}";
|
|
|
|
ExecReload = "${getBin pkgs.pcsclite}/sbin/pcscd -H";
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
2014-03-21 22:52:24 +00:00
|
|
|
};
|
2010-01-11 21:56:01 +00:00
|
|
|
};
|
|
|
|
}
|