about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pynitrokey/default.nix
blob: 41218201fd55ae6445349eeaef1c56965ad6023d (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{ lib
, buildPythonPackage
, fetchPypi
, pythonRelaxDepsHook
, installShellFiles
, libnitrokey
, flit-core
, certifi
, cffi
, click
, cryptography
, ecdsa
, fido2
, intelhex
, nkdfu
, python-dateutil
, pyusb
, requests
, spsdk
, tqdm
, tlv8
, typing-extensions
, pyserial
, protobuf
, click-aliases
, semver
, nethsm
, importlib-metadata
}:

let
  pname = "pynitrokey";
  version = "0.4.47";
  mainProgram = "nitropy";
in

buildPythonPackage {
  inherit pname version;
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-WOHDskGAZGhiU48JGV0yDhWIpFELFLHhn9g5sbchKKg=";
  };

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

  nativeBuildInputs = [
    flit-core
    installShellFiles
    pythonRelaxDepsHook
  ];

  pythonRelaxDeps = true;

  # pythonRelaxDepsHook runs in postBuild so cannot be used
  pypaBuildFlags = [ "--skip-dependency-check" ];

  # 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" ];

  postInstall = ''
    installShellCompletion --cmd ${mainProgram} \
      --bash <(_NITROPY_COMPLETE=bash_source $out/bin/${mainProgram}) \
      --zsh <(_NITROPY_COMPLETE=zsh_source $out/bin/${mainProgram}) \
      --fish <(_NITROPY_COMPLETE=fish_source $out/bin/${mainProgram})
  '';

  meta = with lib; {
    description = "Python client for Nitrokey devices";
    homepage = "https://github.com/Nitrokey/pynitrokey";
    changelog = "https://github.com/Nitrokey/pynitrokey/releases/tag/v${version}";
    license = with licenses; [ asl20 mit ];
    maintainers = with maintainers; [ frogamic raitobezarius ];
    inherit mainProgram;
  };
}