1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9
10 cfg = config.services.vsmartcard-vpcd;
11
12in
13{
14
15 options.services.vsmartcard-vpcd = {
16 enable = lib.mkEnableOption "Virtual smart card driver.";
17
18 port = lib.mkOption {
19 type = lib.types.port;
20 default = 35963;
21 description = ''
22 Port number vpcd will be listening on.
23 '';
24 };
25
26 hostname = lib.mkOption {
27 type = lib.types.str;
28 default = "/dev/null";
29 description = ''
30 Hostname of a waiting vpicc server vpcd will be connecting to. Use /dev/null for listening mode.
31 '';
32 };
33 };
34
35 config = lib.mkIf cfg.enable {
36 services.pcscd.readerConfigs = [
37 ''
38 FRIENDLYNAME "Virtual PCD"
39 DEVICENAME ${cfg.hostname}:0x${lib.toHexString cfg.port}
40 LIBPATH ${pkgs.vsmartcard-vpcd}/var/lib/pcsc/drivers/serial/libifdvpcd.so
41 CHANNELID 0x${lib.toHexString cfg.port}
42 ''
43 ];
44
45 environment.systemPackages = [ pkgs.vsmartcard-vpcd ];
46 };
47
48 meta.maintainers = with lib.maintainers; [ stargate01 ];
49}