about summary refs log tree commit diff
path: root/pkgs/tools/security/pynitrokey/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/security/pynitrokey/default.nix')
-rw-r--r--pkgs/tools/security/pynitrokey/default.nix77
1 files changed, 51 insertions, 26 deletions
diff --git a/pkgs/tools/security/pynitrokey/default.nix b/pkgs/tools/security/pynitrokey/default.nix
index 690d566c476d..2d1979c1b0c1 100644
--- a/pkgs/tools/security/pynitrokey/default.nix
+++ b/pkgs/tools/security/pynitrokey/default.nix
@@ -1,63 +1,82 @@
 { lib
-, python3Packages
+, buildPythonApplication
 , fetchPypi
-, nrfutil
+, pythonRelaxDepsHook
+, installShellFiles
 , libnitrokey
-, nix-update-script
+, 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
 }:
 
-with python3Packages;
-
-buildPythonApplication rec {
+let
   pname = "pynitrokey";
-  version = "0.4.40";
-  format = "pyproject";
+  version = "0.4.43";
+  mainProgram = "nitropy";
+in
+
+buildPythonApplication {
+  inherit pname version;
+  pyproject = true;
 
   src = fetchPypi {
     inherit pname version;
-    hash = "sha256-Hu+8UooDzv4GhkWt0sCckQQyHjWn4V/zt2ADlVCoHmk=";
+    hash = "sha256-dYOdokqALDg4Xn7N6Yd0skM/tit+j5+xY73sm9k76hE=";
   };
 
   propagatedBuildInputs = [
     certifi
     cffi
     click
-    click-aliases
     cryptography
     ecdsa
-    frozendict
     fido2
     intelhex
     nkdfu
-    nrfutil
     python-dateutil
     pyusb
     requests
-    semver
     spsdk
     tqdm
-    urllib3
     tlv8
     typing-extensions
+    pyserial
+    protobuf
+    click-aliases
+    semver
+    nethsm
     importlib-metadata
   ];
 
   nativeBuildInputs = [
     flit-core
+    installShellFiles
     pythonRelaxDepsHook
   ];
 
-  # FIXME: does pythonRelaxDepsHook not work for pypaBuildHook + flit-core?
-  pypaBuildFlags = [ "--skip-dependency-check" ];
+  pythonRelaxDeps = true;
 
-  pythonRelaxDeps = [
-    "click"
-    "cryptography"
-    "protobuf"
-    "python-dateutil"
-    "spsdk"
-    "typing_extensions"
-  ];
+  # 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
@@ -70,13 +89,19 @@ buildPythonApplication rec {
 
   pythonImportsCheck = [ "pynitrokey" ];
 
-  passthru.updateScript = nix-update-script { };
+  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 ];
-    mainProgram = "nitropy";
+    inherit mainProgram;
   };
 }