overlays: add and use pyscard overlay

Changed files
+89 -3
global
overlays
+3 -3
global/overlays/default.nix
···
-
inputs:
-
with inputs; [
-
mystia.overlays.default
]
···
+
inputs: [
+
inputs.mystia.overlays.default
+
(import ./temp/pyscard) # FIXME: remove on next flake update
]
+14
global/overlays/temp/pyscard/default.nix
···
···
+
final: prev: {
+
python3 = prev.python3.override {
+
self = final.python3;
+
+
packageOverrides = (final': prev': {
+
pyscard = final.python3Packages.callPackage ./package.nix {
+
inherit (final.darwin.apple_sdk.frameworks) PCSC; # apple carp
+
};
+
});
+
};
+
+
# probably some `rec` carp
+
python3Packages = final.python3.pkgs;
+
}
+72
global/overlays/temp/pyscard/package.nix
···
···
+
{
+
lib,
+
buildPythonPackage,
+
fetchFromGitHub,
+
PCSC,
+
pcsclite,
+
pkg-config,
+
pytestCheckHook,
+
setuptools,
+
stdenv,
+
swig,
+
}:
+
+
let
+
# Package does not support configuring the pcsc library.
+
withApplePCSC = stdenv.isDarwin;
+
in
+
+
buildPythonPackage rec {
+
pname = "pyscard";
+
version = "2.0.9";
+
pyproject = true;
+
+
src = fetchFromGitHub {
+
owner = "LudovicRousseau";
+
repo = "pyscard";
+
rev = "refs/tags/${version}";
+
hash = "sha256-DO4Ea+mlrWPpOLI8Eki+03UnsOXEhN2PAl0+gdN5sTo=";
+
};
+
+
build-system = [ setuptools ];
+
+
nativeBuildInputs = [ swig ] ++ lib.optionals (!withApplePCSC) [ pkg-config ];
+
+
buildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
+
+
nativeCheckInputs = [ pytestCheckHook ];
+
+
postPatch =
+
if withApplePCSC then
+
''
+
substituteInPlace smartcard/scard/winscarddll.c \
+
--replace-fail "/System/Library/Frameworks/PCSC.framework/PCSC" \
+
"${PCSC}/Library/Frameworks/PCSC.framework/PCSC"
+
''
+
else
+
''
+
substituteInPlace setup.py --replace "pkg-config" "$PKG_CONFIG"
+
substituteInPlace smartcard/scard/winscarddll.c \
+
--replace-fail "libpcsclite.so.1" \
+
"${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
+
'';
+
+
preCheck = ''
+
# remove src module, so tests use the installed module instead
+
rm -r smartcard
+
'';
+
+
disabledTests = [
+
# AssertionError
+
"test_hresult"
+
"test_low_level"
+
];
+
+
meta = with lib; {
+
description = "Smartcard library for python";
+
homepage = "https://pyscard.sourceforge.io/";
+
changelog = "https://github.com/LudovicRousseau/pyscard/releases/tag/${version}";
+
license = licenses.lgpl21Plus;
+
maintainers = with maintainers; [ layus ];
+
};
+
}