summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/development/vsmartcard-vpcd.nix
blob: c1ce972b998eef7d5c7d99ce13512793dc64aaae (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:

let

  cfg = config.services.vsmartcard-vpcd;

in
{

  options.services.vsmartcard-vpcd = {
    enable = lib.mkEnableOption "Virtual smart card driver.";

    port = lib.mkOption {
      type = lib.types.port;
      default = 35963;
      description = ''
        Port number vpcd will be listening on.
      '';
    };

    hostname = lib.mkOption {
      type = lib.types.str;
      default = "/dev/null";
      description = ''
        Hostname of a waiting vpicc server vpcd will be connecting to. Use /dev/null for listening mode.
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    services.pcscd.readerConfigs = [
      ''
        FRIENDLYNAME "Virtual PCD"
        DEVICENAME   ${cfg.hostname}:0x${lib.toHexString cfg.port}
        LIBPATH      ${pkgs.vsmartcard-vpcd}/var/lib/pcsc/drivers/serial/libifdvpcd.so
        CHANNELID    0x${lib.toHexString cfg.port}
      ''
    ];

    environment.systemPackages = [ pkgs.vsmartcard-vpcd ];
  };

  meta.maintainers = with lib.maintainers; [ stargate01 ];
}