2021-04-26 19:14:03 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2024-01-13 08:15:51 +00:00
|
|
|
, fetchFromGitLab
|
2024-07-31 10:19:44 +00:00
|
|
|
, fetchpatch
|
|
|
|
, meson
|
|
|
|
, ninja
|
2024-01-13 08:15:51 +00:00
|
|
|
, flex
|
2021-04-26 19:14:03 +00:00
|
|
|
, pkg-config
|
|
|
|
, perl
|
|
|
|
, python3
|
|
|
|
, dbus
|
|
|
|
, polkit
|
2023-11-16 04:20:00 +00:00
|
|
|
, systemdLibs
|
2024-05-15 15:35:15 +00:00
|
|
|
, udev
|
2024-09-26 11:04:55 +00:00
|
|
|
, dbusSupport ? stdenv.hostPlatform.isLinux
|
2024-05-15 15:35:15 +00:00
|
|
|
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs
|
|
|
|
, udevSupport ? dbusSupport
|
|
|
|
, libusb1
|
2024-07-31 10:19:44 +00:00
|
|
|
, Foundation
|
2021-04-26 19:14:03 +00:00
|
|
|
, IOKit
|
2024-01-13 08:15:51 +00:00
|
|
|
, testers
|
|
|
|
, nix-update-script
|
2022-11-02 22:02:43 +00:00
|
|
|
, pname ? "pcsclite"
|
|
|
|
, polkitSupport ? false
|
2021-04-26 19:14:03 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
assert polkitSupport -> dbusSupport;
|
|
|
|
assert systemdSupport -> dbusSupport;
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2022-11-02 22:02:43 +00:00
|
|
|
inherit pname;
|
2024-07-31 10:19:44 +00:00
|
|
|
version = "2.2.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
outputs = [ "out" "lib" "dev" "doc" "man" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "salsa.debian.org";
|
|
|
|
owner = "rousseau";
|
|
|
|
repo = "PCSC";
|
|
|
|
rev = "refs/tags/${finalAttrs.version}";
|
2024-07-31 10:19:44 +00:00
|
|
|
hash = "sha256-hKyxXqZaqg8KGFoBWhRHV1/50uoxqiG0RsYtgw2BuQ4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-07-31 10:19:44 +00:00
|
|
|
# fix build with macOS 11 SDK
|
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://salsa.debian.org/rousseau/PCSC/-/commit/f41fdaaf7c82bc270af6d7439c6da037bf149be8.patch";
|
|
|
|
revert = true;
|
|
|
|
hash = "sha256-8A76JfYqcILi52X9l/uIpJXeRJDf2dkrNEToOsxGZXk=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
mesonFlags = [
|
|
|
|
(lib.mesonOption "sysconfdir" "/etc")
|
2020-04-24 23:36:52 +00:00
|
|
|
# The OS should care on preparing the drivers into this location
|
2024-07-31 10:19:44 +00:00
|
|
|
(lib.mesonOption "usbdropdir" "/var/lib/pcsc/drivers")
|
|
|
|
(lib.mesonBool "libsystemd" systemdSupport)
|
|
|
|
(lib.mesonBool "polkit" polkitSupport)
|
|
|
|
(lib.mesonOption "ipcdir" "/run/pcscd")
|
2024-05-15 15:35:15 +00:00
|
|
|
] ++ lib.optionals systemdSupport [
|
2024-07-31 10:19:44 +00:00
|
|
|
(lib.mesonOption "systemdunit" "system")
|
2024-05-15 15:35:15 +00:00
|
|
|
] ++ lib.optionals (!udevSupport) [
|
2024-07-31 10:19:44 +00:00
|
|
|
(lib.mesonBool "libudev" false)
|
2024-01-13 08:15:51 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
# disable building pcsc-wirecheck{,-gen} when cross compiling
|
|
|
|
# see also: https://github.com/LudovicRousseau/PCSC/issues/25
|
2024-07-31 10:19:44 +00:00
|
|
|
postPatch = ''
|
2024-05-15 15:35:15 +00:00
|
|
|
substituteInPlace src/libredirect.c src/spy/libpcscspy.c \
|
|
|
|
--replace-fail "libpcsclite_real.so.1" "$lib/lib/libpcsclite_real.so.1"
|
2024-07-31 10:19:44 +00:00
|
|
|
'' + lib.optionalString systemdSupport ''
|
|
|
|
substituteInPlace meson.build \
|
|
|
|
--replace-fail \
|
|
|
|
"systemdsystemunitdir = systemd.get_variable(pkgconfig : 'systemd' + unit + 'unitdir')" \
|
|
|
|
"systemdsystemunitdir = '${placeholder "out"}/lib/systemd/system'"
|
|
|
|
'' + lib.optionalString polkitSupport ''
|
|
|
|
substituteInPlace meson.build \
|
|
|
|
--replace-fail \
|
|
|
|
"install_dir : polkit_dep.get_variable('policydir')" \
|
|
|
|
"install_dir : '${placeholder "out"}/share/polkit-1/actions'"
|
2024-02-29 20:09:43 +00:00
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
|
|
|
# pcsc-spy is a debugging utility and it drags python into the closure
|
|
|
|
moveToOutput bin/pcsc-spy "$dev"
|
|
|
|
'';
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
nativeBuildInputs = [
|
2024-07-31 10:19:44 +00:00
|
|
|
meson
|
|
|
|
ninja
|
2024-01-13 08:15:51 +00:00
|
|
|
flex
|
|
|
|
pkg-config
|
|
|
|
perl
|
|
|
|
];
|
2021-03-19 17:17:44 +00:00
|
|
|
|
|
|
|
buildInputs = [ python3 ]
|
2024-05-15 15:35:15 +00:00
|
|
|
++ lib.optionals systemdSupport [ systemdLibs ]
|
|
|
|
++ lib.optionals (!systemdSupport && udevSupport) [ udev ]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ Foundation IOKit ]
|
2024-05-15 15:35:15 +00:00
|
|
|
++ lib.optionals dbusSupport [ dbus ]
|
|
|
|
++ lib.optionals polkitSupport [ polkit ]
|
|
|
|
++ lib.optionals (!udevSupport) [ libusb1 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
passthru = {
|
2024-05-15 15:35:15 +00:00
|
|
|
tests = {
|
|
|
|
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
|
|
|
version = testers.testVersion {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
command = "pcscd --version";
|
|
|
|
};
|
2024-01-13 08:15:51 +00:00
|
|
|
};
|
|
|
|
updateScript = nix-update-script { };
|
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
meta = {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Middleware to access a smart card using SCard API (PC/SC)";
|
|
|
|
homepage = "https://pcsclite.apdu.fr/";
|
2024-01-13 08:15:51 +00:00
|
|
|
changelog = "https://salsa.debian.org/rousseau/PCSC/-/blob/${finalAttrs.version}/ChangeLog";
|
2024-05-15 15:35:15 +00:00
|
|
|
license = lib.licenses.bsd3;
|
2024-01-13 08:15:51 +00:00
|
|
|
mainProgram = "pcscd";
|
2024-05-15 15:35:15 +00:00
|
|
|
maintainers = [ lib.maintainers.anthonyroussel ];
|
|
|
|
pkgConfigModules = [ "libpcsclite" ];
|
|
|
|
platforms = lib.platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-01-13 08:15:51 +00:00
|
|
|
})
|