2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-01-11 22:56:01 +01:00
|
|
|
|
2016-06-04 13:07:09 +02:00
|
|
|
with lib;
|
|
|
|
|
2014-03-21 23:52:24 +01:00
|
|
|
let
|
2016-06-04 13:07:09 +02:00
|
|
|
cfgFile = pkgs.writeText "reader.conf" config.services.pcscd.readerConfig;
|
2014-03-21 23:52:24 +01:00
|
|
|
|
2016-06-04 13:07:09 +02:00
|
|
|
pluginEnv = pkgs.buildEnv {
|
|
|
|
name = "pcscd-plugins";
|
|
|
|
paths = map (p: "${p}/pcsc/drivers") config.services.pcscd.plugins;
|
|
|
|
};
|
2010-01-11 22:56:01 +01:00
|
|
|
|
2016-06-04 13:07:09 +02:00
|
|
|
in {
|
2010-01-11 22:56:01 +01:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-01-11 22:56:01 +01:00
|
|
|
services.pcscd = {
|
2016-06-04 13:07:09 +02: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 22:56:01 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2016-06-04 13:07:09 +02: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 22:56:01 +01:00
|
|
|
};
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-01-11 22:56:01 +01:00
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.pcscd.enable {
|
|
|
|
|
2014-04-12 04:58:21 +02:00
|
|
|
systemd.sockets.pcscd = {
|
|
|
|
description = "PCSC-Lite Socket";
|
|
|
|
wantedBy = [ "sockets.target" ];
|
|
|
|
before = [ "multi-user.target" ];
|
|
|
|
socketConfig.ListenStream = "/run/pcscd/pcscd.comm";
|
|
|
|
};
|
|
|
|
|
2014-03-21 23:52:24 +01:00
|
|
|
systemd.services.pcscd = {
|
|
|
|
description = "PCSC-Lite daemon";
|
2016-06-04 13:07:09 +02:00
|
|
|
environment.PCSCLITE_HP_DROPDIR = pluginEnv;
|
2014-03-21 23:52:24 +01:00
|
|
|
serviceConfig = {
|
2016-06-04 13:07:09 +02:00
|
|
|
ExecStart = "${pkgs.pcsclite}/sbin/pcscd -f -x -c ${cfgFile}";
|
|
|
|
ExecReload = "${pkgs.pcsclite}/sbin/pcscd -H";
|
2010-01-11 22:56:01 +01:00
|
|
|
};
|
2014-03-21 23:52:24 +01:00
|
|
|
};
|
2010-01-11 22:56:01 +01:00
|
|
|
};
|
|
|
|
}
|