pcscd: allow multiple readerConfig entries
This commit is contained in:
parent
f6e9c84743
commit
735f85e845
@ -1,11 +1,16 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.pcscd;
|
||||
cfgFile = pkgs.writeText "reader.conf" config.services.pcscd.readerConfig;
|
||||
cfgFile = pkgs.writeText "reader.conf" (
|
||||
builtins.concatStringsSep "\n\n" config.services.pcscd.readerConfigs
|
||||
);
|
||||
|
||||
package = if config.security.polkit.enable
|
||||
then pkgs.pcscliteWithPolkit
|
||||
else pkgs.pcsclite;
|
||||
package = if config.security.polkit.enable then pkgs.pcscliteWithPolkit else pkgs.pcsclite;
|
||||
|
||||
pluginEnv = pkgs.buildEnv {
|
||||
name = "pcscd-plugins";
|
||||
@ -14,6 +19,20 @@ let
|
||||
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkChangedOptionModule
|
||||
[ "services" "pcscd" "readerConfig" ]
|
||||
[ "services" "pcscd" "readerConfigs" ]
|
||||
(
|
||||
config:
|
||||
let
|
||||
readerConfig = lib.getAttrFromPath [ "services" "pcscd" "readerConfig" ] config;
|
||||
in
|
||||
[ readerConfig ]
|
||||
)
|
||||
)
|
||||
];
|
||||
|
||||
options.services.pcscd = {
|
||||
enable = lib.mkEnableOption "PCSC-Lite daemon, to access smart cards using SCard API (PC/SC)";
|
||||
|
||||
@ -24,15 +43,17 @@ in
|
||||
description = "Plugin packages to be used for PCSC-Lite.";
|
||||
};
|
||||
|
||||
readerConfig = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
example = ''
|
||||
FRIENDLYNAME "Some serial reader"
|
||||
DEVICENAME /dev/ttyS0
|
||||
LIBPATH /path/to/serial_reader.so
|
||||
CHANNELID 1
|
||||
'';
|
||||
readerConfigs = lib.mkOption {
|
||||
type = lib.types.listOf lib.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.
|
||||
|
||||
@ -68,7 +89,10 @@ in
|
||||
# around it, we force the path to the cfgFile.
|
||||
#
|
||||
# https://github.com/NixOS/nixpkgs/issues/121088
|
||||
serviceConfig.ExecStart = [ "" "${lib.getExe package} -f -x -c ${cfgFile} ${lib.escapeShellArgs cfg.extraArgs}" ];
|
||||
serviceConfig.ExecStart = [
|
||||
""
|
||||
"${lib.getExe package} -f -x -c ${cfgFile} ${lib.escapeShellArgs cfg.extraArgs}"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user