about summary refs log tree commit diff
path: root/pkgs/tools/security/ccid/default.nix
blob: 12f65546e92e5bfc85c4d9d48a2aa99afc3f7fa9 (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ lib
, stdenv
, fetchurl
, flex
, pcsclite
, pkg-config
, libusb1
, perl
, zlib
, gitUpdater
}:

stdenv.mkDerivation rec {
  pname = "ccid";
  version = "1.5.5";

  src = fetchurl {
    url = "https://ccid.apdu.fr/files/${pname}-${version}.tar.bz2";
    hash = "sha256-GUcI91/jadRd18Feiz6Kfbi0nPxVV1dMoqLnbvEsoMo=";
  };

  postPatch = ''
    patchShebangs .
    substituteInPlace src/Makefile.in --replace /bin/echo echo
  '';

  configureFlags = [
    "--enable-twinserial"
    "--enable-serialconfdir=${placeholder "out"}/etc/reader.conf.d"
    "--enable-ccidtwindir=${placeholder "out"}/pcsc/drivers/serial"
    "--enable-usbdropdir=${placeholder "out"}/pcsc/drivers"
  ];

  # error: call to undeclared function 'InterruptRead';
  # ISO C99 and later do not support implicit function declarations
  env = lib.optionalAttrs stdenv.cc.isClang {
    NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
  };

  nativeBuildInputs = [
    flex
    pkg-config
    perl
  ];

  buildInputs = [
    pcsclite
    libusb1
    zlib
  ];

  postInstall = ''
    install -Dm 0444 -t $out/lib/udev/rules.d src/92_pcscd_ccid.rules
    substituteInPlace $out/lib/udev/rules.d/92_pcscd_ccid.rules \
      --replace "/usr/sbin/pcscd" "${pcsclite}/bin/pcscd"
  '';

  # The resulting shared object ends up outside of the default paths which are
  # usually getting stripped.
  stripDebugList = ["pcsc"];

  passthru.updateScript = gitUpdater {
    url = "https://salsa.debian.org/rousseau/CCID.git";
  };

  meta = with lib; {
    description = "PC/SC driver for USB CCID smart card readers";
    homepage = "https://ccid.apdu.fr/";
    license = licenses.lgpl21Plus;
    maintainers = [ maintainers.anthonyroussel ];
    platforms = platforms.unix;
  };
}