summary refs log tree commit diff
path: root/pkgs/tools/security/pynitrokey/default.nix
blob: 9c36ceb3c841eb4964fdcf0d6ff65744de5f802f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{ lib
, python3Packages
, fetchPypi
, nrfutil
, libnitrokey
, nix-update-script
}:

with python3Packages;

buildPythonApplication rec {
  pname = "pynitrokey";
  version = "0.4.39";
  format = "pyproject";

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-KXYHeWwV9Tw1ZpO/vASHjDnceeb+1K0yIUohb7EcRAI=";
  };

  propagatedBuildInputs = [
    certifi
    cffi
    click
    click-aliases
    cryptography
    ecdsa
    frozendict
    fido2
    intelhex
    nkdfu
    nrfutil
    python-dateutil
    pyusb
    requests
    semver
    spsdk
    tqdm
    urllib3
    tlv8
    typing-extensions
    importlib-metadata
  ];

  nativeBuildInputs = [
    flit-core
    pythonRelaxDepsHook
  ];

  # FIXME: does pythonRelaxDepsHook not work for pypaBuildHook + flit-core?
  pypaBuildFlags = [ "--skip-dependency-check" ];

  pythonRelaxDeps = [
    "click"
    "cryptography"
    "protobuf"
    "python-dateutil"
    "spsdk"
    "typing_extensions"
  ];

  # libnitrokey is not propagated to users of the pynitrokey Python package.
  # It is only usable from the wrapped bin/nitropy
  makeWrapperArgs = [
    "--set LIBNK_PATH ${lib.makeLibraryPath [ libnitrokey ]}"
  ];

  # no tests
  doCheck = false;

  pythonImportsCheck = [ "pynitrokey" ];

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "Python client for Nitrokey devices";
    homepage = "https://github.com/Nitrokey/pynitrokey";
    license = with licenses; [ asl20 mit ];
    maintainers = with maintainers; [ frogamic ];
    mainProgram = "nitropy";
  };
}