1{ 2 lib, 3 buildPythonPackage, 4 fetchPypi, 5 pythonRelaxDepsHook, 6 installShellFiles, 7 libnitrokey, 8 flit-core, 9 certifi, 10 cffi, 11 click, 12 cryptography, 13 ecdsa, 14 fido2, 15 intelhex, 16 nkdfu, 17 python-dateutil, 18 pyusb, 19 requests, 20 spsdk, 21 tqdm, 22 tlv8, 23 typing-extensions, 24 pyserial, 25 protobuf, 26 click-aliases, 27 semver, 28 nethsm, 29 importlib-metadata, 30}: 31 32let 33 pname = "pynitrokey"; 34 version = "0.4.47"; 35 mainProgram = "nitropy"; 36in 37 38buildPythonPackage { 39 inherit pname version; 40 pyproject = true; 41 42 src = fetchPypi { 43 inherit pname version; 44 hash = "sha256-WOHDskGAZGhiU48JGV0yDhWIpFELFLHhn9g5sbchKKg="; 45 }; 46 47 propagatedBuildInputs = [ 48 certifi 49 cffi 50 click 51 cryptography 52 ecdsa 53 fido2 54 intelhex 55 nkdfu 56 python-dateutil 57 pyusb 58 requests 59 spsdk 60 tqdm 61 tlv8 62 typing-extensions 63 pyserial 64 protobuf 65 click-aliases 66 semver 67 nethsm 68 importlib-metadata 69 ]; 70 71 nativeBuildInputs = [ 72 flit-core 73 installShellFiles 74 pythonRelaxDepsHook 75 ]; 76 77 pythonRelaxDeps = true; 78 79 # pythonRelaxDepsHook runs in postBuild so cannot be used 80 pypaBuildFlags = [ "--skip-dependency-check" ]; 81 82 # libnitrokey is not propagated to users of the pynitrokey Python package. 83 # It is only usable from the wrapped bin/nitropy 84 makeWrapperArgs = [ "--set LIBNK_PATH ${lib.makeLibraryPath [ libnitrokey ]}" ]; 85 86 # no tests 87 doCheck = false; 88 89 pythonImportsCheck = [ "pynitrokey" ]; 90 91 postInstall = '' 92 installShellCompletion --cmd ${mainProgram} \ 93 --bash <(_NITROPY_COMPLETE=bash_source $out/bin/${mainProgram}) \ 94 --zsh <(_NITROPY_COMPLETE=zsh_source $out/bin/${mainProgram}) \ 95 --fish <(_NITROPY_COMPLETE=fish_source $out/bin/${mainProgram}) 96 ''; 97 98 meta = with lib; { 99 description = "Python client for Nitrokey devices"; 100 homepage = "https://github.com/Nitrokey/pynitrokey"; 101 changelog = "https://github.com/Nitrokey/pynitrokey/releases/tag/v${version}"; 102 license = with licenses; [ 103 asl20 104 mit 105 ]; 106 maintainers = with maintainers; [ 107 frogamic 108 raitobezarius 109 ]; 110 inherit mainProgram; 111 }; 112}