Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 fetchFromGitLab, 5 fetchpatch, 6 meson, 7 ninja, 8 flex, 9 pkg-config, 10 perl, 11 python3, 12 dbus, 13 polkit, 14 systemdLibs, 15 udev, 16 dbusSupport ? stdenv.hostPlatform.isLinux, 17 systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs, 18 udevSupport ? dbusSupport, 19 libusb1, 20 testers, 21 nix-update-script, 22 pname ? "pcsclite", 23 polkitSupport ? false, 24}: 25 26stdenv.mkDerivation (finalAttrs: { 27 inherit pname; 28 version = "2.3.0"; 29 30 outputs = [ 31 "out" 32 "lib" 33 "dev" 34 "doc" 35 "man" 36 ]; 37 38 src = fetchFromGitLab { 39 domain = "salsa.debian.org"; 40 owner = "rousseau"; 41 repo = "PCSC"; 42 rev = "refs/tags/${finalAttrs.version}"; 43 hash = "sha256-37qeWGEuutF0cOOidoLchKJLQCvJFdVRZXepWzD4pZs="; 44 }; 45 46 # fix build with macOS 11 SDK 47 patches = [ 48 (fetchpatch { 49 url = "https://salsa.debian.org/rousseau/PCSC/-/commit/f41fdaaf7c82bc270af6d7439c6da037bf149be8.patch"; 50 revert = true; 51 hash = "sha256-8A76JfYqcILi52X9l/uIpJXeRJDf2dkrNEToOsxGZXk="; 52 }) 53 ]; 54 55 mesonFlags = [ 56 (lib.mesonOption "sysconfdir" "/etc") 57 # The OS should care on preparing the drivers into this location 58 (lib.mesonOption "usbdropdir" "/var/lib/pcsc/drivers") 59 (lib.mesonBool "libsystemd" systemdSupport) 60 (lib.mesonBool "polkit" polkitSupport) 61 (lib.mesonOption "ipcdir" "/run/pcscd") 62 ] 63 ++ lib.optionals systemdSupport [ 64 (lib.mesonOption "systemdunit" "system") 65 ] 66 ++ lib.optionals (!udevSupport) [ 67 (lib.mesonBool "libudev" false) 68 ]; 69 70 # disable building pcsc-wirecheck{,-gen} when cross compiling 71 # see also: https://github.com/LudovicRousseau/PCSC/issues/25 72 postPatch = '' 73 substituteInPlace src/libredirect.c src/spy/libpcscspy.c \ 74 --replace-fail "libpcsclite_real.so.1" "$lib/lib/libpcsclite_real.so.1" 75 '' 76 + lib.optionalString systemdSupport '' 77 substituteInPlace meson.build \ 78 --replace-fail \ 79 "systemdsystemunitdir = systemd.get_variable(pkgconfig : 'systemd' + unit + 'unitdir')" \ 80 "systemdsystemunitdir = '${placeholder "out"}/lib/systemd/system'" 81 '' 82 + lib.optionalString polkitSupport '' 83 substituteInPlace meson.build \ 84 --replace-fail \ 85 "install_dir : polkit_dep.get_variable('policydir')" \ 86 "install_dir : '${placeholder "out"}/share/polkit-1/actions'" 87 ''; 88 89 postInstall = '' 90 # pcsc-spy is a debugging utility and it drags python into the closure 91 moveToOutput bin/pcsc-spy "$dev" 92 ''; 93 94 nativeBuildInputs = [ 95 meson 96 ninja 97 flex 98 pkg-config 99 perl 100 ]; 101 102 buildInputs = [ 103 python3 104 ] 105 ++ lib.optionals systemdSupport [ systemdLibs ] 106 ++ lib.optionals (!systemdSupport && udevSupport) [ udev ] 107 ++ lib.optionals dbusSupport [ dbus ] 108 ++ lib.optionals polkitSupport [ polkit ] 109 ++ lib.optionals (!udevSupport) [ libusb1 ]; 110 111 passthru = { 112 tests = { 113 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 114 version = testers.testVersion { 115 package = finalAttrs.finalPackage; 116 command = "pcscd --version"; 117 }; 118 }; 119 updateScript = nix-update-script { }; 120 }; 121 122 meta = { 123 description = "Middleware to access a smart card using SCard API (PC/SC)"; 124 homepage = "https://pcsclite.apdu.fr/"; 125 changelog = "https://salsa.debian.org/rousseau/PCSC/-/blob/${finalAttrs.version}/ChangeLog"; 126 license = lib.licenses.bsd3; 127 mainProgram = "pcscd"; 128 maintainers = [ lib.maintainers.anthonyroussel ]; 129 pkgConfigModules = [ "libpcsclite" ]; 130 platforms = lib.platforms.unix; 131 broken = !(polkitSupport -> dbusSupport) || !(systemdSupport -> dbusSupport); 132 }; 133})