|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchFromGitHub, |
| 5 | + pcsclite, |
| 6 | + PCSC, |
| 7 | + pkg-config, |
| 8 | + cmake, |
| 9 | + zlib, |
| 10 | + pandoc, |
| 11 | + doxygen, |
| 12 | + graphviz, |
| 13 | + openssl, |
| 14 | + cmocka, |
| 15 | +}: |
| 16 | + |
| 17 | +stdenv.mkDerivation (finalAttrs: { |
| 18 | + pname = "globalplatform"; |
| 19 | + version = "2.4.0-unreleased"; |
| 20 | + |
| 21 | + src = fetchFromGitHub { |
| 22 | + owner = "kaoh"; |
| 23 | + repo = "globalplatform"; |
| 24 | + rev = "0f970751c5d9e8a7030f897ca2d1b86d0eeba4c2"; |
| 25 | + sha256 = "sha256-H/muc/gY5glXPWKj75fHi6+1DAP91YGAUefdQkX9nfk="; |
| 26 | + }; |
| 27 | + |
| 28 | + nativeBuildInputs = [ |
| 29 | + pkg-config |
| 30 | + cmake |
| 31 | + pandoc |
| 32 | + doxygen |
| 33 | + graphviz |
| 34 | + ]; |
| 35 | + |
| 36 | + buildInputs = |
| 37 | + [ |
| 38 | + zlib |
| 39 | + openssl |
| 40 | + ] |
| 41 | + ++ lib.optionals stdenv.hostPlatform.isLinux [ |
| 42 | + pcsclite |
| 43 | + ] |
| 44 | + ++ lib.optionals stdenv.hostPlatform.isDarwin [ |
| 45 | + PCSC |
| 46 | + ]; |
| 47 | + |
| 48 | + cmakeFlags = [ |
| 49 | + "-DTESTING=ON" |
| 50 | + ]; |
| 51 | + |
| 52 | + doCheck = true; |
| 53 | + |
| 54 | + nativeCheckInputs = [ |
| 55 | + cmocka |
| 56 | + ]; |
| 57 | + |
| 58 | + preCheck = '' |
| 59 | + cp "$src/gpshell/helloworld.cap" globalplatform/src |
| 60 | + cp "$src/globalplatform/src/rsa_pub_key_test.pem" globalplatform/src |
| 61 | + ''; |
| 62 | + |
| 63 | + # libglobalplatform.so uses dlopen() to load specified connection plugins at runtime. |
| 64 | + # Currently, libgppcscconnectionplugin.so is the only plugin included. |
| 65 | + # The user has to specify custom plugin locations by setting LD_LIBRARY_PATH. |
| 66 | + |
| 67 | + postFixup = |
| 68 | + lib.optionalString stdenv.hostPlatform.isLinux '' |
| 69 | + patchelf $out/lib/libglobalplatform.so --add-rpath "$out/lib" |
| 70 | + '' |
| 71 | + + lib.optionalString stdenv.hostPlatform.isDarwin '' |
| 72 | + install_name_tool -add_rpath "$out/lib" "$out/lib/libglobalplatform.dylib" |
| 73 | + ''; |
| 74 | + |
| 75 | + meta = { |
| 76 | + description = "C library + command-line for Open- / GlobalPlatform smart cards"; |
| 77 | + mainProgram = "gpshell"; |
| 78 | + homepage = "https://github.com/kaoh/globalplatform"; |
| 79 | + # Clarify license for GPShell |
| 80 | + # https://github.com/kaoh/globalplatform/issues/81 |
| 81 | + license = lib.licenses.gpl3Plus; |
| 82 | + platforms = lib.platforms.linux ++ lib.platforms.darwin; |
| 83 | + maintainers = with lib.maintainers; [ stargate01 ]; |
| 84 | + }; |
| 85 | +}) |
0 commit comments