1{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, zlib, readline, openssl
2, libiconv, pcsclite, libassuan, libXt
3, docbook_xsl, libxslt, docbook_xml_dtd_412
4, Carbon, PCSC, buildPackages
5, withApplePCSC ? stdenv.isDarwin
6}:
7
8stdenv.mkDerivation rec {
9 pname = "opensc";
10 version = "0.23.0";
11
12 src = fetchFromGitHub {
13 owner = "OpenSC";
14 repo = "OpenSC";
15 rev = version;
16 sha256 = "sha256-Yo8dwk7+d6q+hi7DmJ0GJM6/pmiDOiyEm/tEBSbCU8k=";
17 };
18
19 nativeBuildInputs = [ pkg-config autoreconfHook ];
20 buildInputs = [
21 zlib readline openssl libassuan
22 libXt libxslt libiconv docbook_xml_dtd_412
23 ]
24 ++ lib.optional stdenv.isDarwin Carbon
25 ++ (if withApplePCSC then [ PCSC ] else [ pcsclite ]);
26
27 env.NIX_CFLAGS_COMPILE = "-Wno-error";
28
29 configureFlags = [
30 "--enable-zlib"
31 "--enable-readline"
32 "--enable-openssl"
33 "--enable-pcsc"
34 "--enable-sm"
35 "--enable-man"
36 "--enable-doc"
37 "--localstatedir=/var"
38 "--sysconfdir=/etc"
39 "--with-xsl-stylesheetsdir=${docbook_xsl}/xml/xsl/docbook"
40 "--with-pcsc-provider=${
41 if withApplePCSC then
42 "${PCSC}/Library/Frameworks/PCSC.framework/PCSC"
43 else
44 "${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
45 }"
46 (lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform)
47 "XSLTPROC=${buildPackages.libxslt}/bin/xsltproc")
48 ];
49
50 PCSC_CFLAGS = lib.optionalString withApplePCSC
51 "-I${PCSC}/Library/Frameworks/PCSC.framework/Headers";
52
53 installFlags = [
54 "sysconfdir=$(out)/etc"
55 "completiondir=$(out)/etc"
56 ];
57
58 meta = with lib; {
59 description = "Set of libraries and utilities to access smart cards";
60 homepage = "https://github.com/OpenSC/OpenSC/wiki";
61 license = licenses.lgpl21Plus;
62 platforms = platforms.all;
63 maintainers = [ maintainers.michaeladler ];
64 };
65}