forked from mirrors/nixpkgs
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
48 lines
781 B
Nix
48 lines
781 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
cfgFile = pkgs.writeText "reader.conf" "";
|
|
in
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.pcscd = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
description = "Whether to enable the PCSC-Lite daemon.";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf config.services.pcscd.enable {
|
|
|
|
systemd.services.pcscd = {
|
|
description = "PCSC-Lite daemon";
|
|
wantedBy = [ "multi-user.target" ];
|
|
preStart = ''
|
|
mkdir -p /var/lib/pcsc
|
|
rm -Rf /var/lib/pcsc/drivers
|
|
ln -s ${pkgs.ccid}/pcsc/drivers /var/lib/pcsc/
|
|
'';
|
|
serviceConfig = {
|
|
Type = "forking";
|
|
ExecStart = "${pkgs.pcsclite}/sbin/pcscd -c ${cfgFile}";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
}
|