1{ lib
2, stdenv
3, fetchurl
4, flex
5, pcsclite
6, pkg-config
7, libusb1
8, perl
9, zlib
10, gitUpdater
11}:
12
13stdenv.mkDerivation rec {
14 pname = "ccid";
15 version = "1.5.5";
16
17 src = fetchurl {
18 url = "https://ccid.apdu.fr/files/${pname}-${version}.tar.bz2";
19 hash = "sha256-GUcI91/jadRd18Feiz6Kfbi0nPxVV1dMoqLnbvEsoMo=";
20 };
21
22 postPatch = ''
23 patchShebangs .
24 substituteInPlace src/Makefile.in --replace /bin/echo echo
25 '';
26
27 configureFlags = [
28 "--enable-twinserial"
29 "--enable-serialconfdir=${placeholder "out"}/etc/reader.conf.d"
30 "--enable-ccidtwindir=${placeholder "out"}/pcsc/drivers/serial"
31 "--enable-usbdropdir=${placeholder "out"}/pcsc/drivers"
32 ];
33
34 # error: call to undeclared function 'InterruptRead';
35 # ISO C99 and later do not support implicit function declarations
36 env = lib.optionalAttrs stdenv.cc.isClang {
37 NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
38 };
39
40 nativeBuildInputs = [
41 flex
42 pkg-config
43 perl
44 ];
45
46 buildInputs = [
47 pcsclite
48 libusb1
49 zlib
50 ];
51
52 postInstall = ''
53 install -Dm 0444 -t $out/lib/udev/rules.d src/92_pcscd_ccid.rules
54 substituteInPlace $out/lib/udev/rules.d/92_pcscd_ccid.rules \
55 --replace "/usr/sbin/pcscd" "${pcsclite}/bin/pcscd"
56 '';
57
58 # The resulting shared object ends up outside of the default paths which are
59 # usually getting stripped.
60 stripDebugList = ["pcsc"];
61
62 passthru.updateScript = gitUpdater {
63 url = "https://salsa.debian.org/rousseau/CCID.git";
64 };
65
66 meta = with lib; {
67 description = "PC/SC driver for USB CCID smart card readers";
68 homepage = "https://ccid.apdu.fr/";
69 license = licenses.lgpl21Plus;
70 maintainers = [ maintainers.anthonyroussel ];
71 platforms = platforms.unix;
72 };
73}