about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-12-04 02:01:21 +0100
committerGitHub <noreply@github.com>2023-12-04 02:01:21 +0100
commitd39479ec822a6725d26a71cf26a25df665eb57ea (patch)
treeb288da4d82cd600b4fcb7661e2f7338b3f51a6b3 /pkgs
parent64f5f2c32524043514d7691239067a9ecc811a1d (diff)
parenta3c12b75e5437e0537714e309c2f29dee3bcaa12 (diff)
Merge pull request #265789 from frogamic/auto-update/pynitrokey
pynitrokey: 0.4.40 -> 0.4.42
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/python-modules/nethsm/default.nix51
-rw-r--r--pkgs/tools/security/pynitrokey/default.nix77
-rw-r--r--pkgs/top-level/all-packages.nix2
-rw-r--r--pkgs/top-level/python-packages.nix2
4 files changed, 105 insertions, 27 deletions
diff --git a/pkgs/development/python-modules/nethsm/default.nix b/pkgs/development/python-modules/nethsm/default.nix
new file mode 100644
index 0000000000000..902fa62e33873
--- /dev/null
+++ b/pkgs/development/python-modules/nethsm/default.nix
@@ -0,0 +1,51 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, pythonRelaxDepsHook
+, flit-core
+, certifi
+, cryptography
+, python-dateutil
+, typing-extensions
+, urllib3
+}:
+
+let
+  pname = "nethsm";
+  version = "1.0.0";
+in
+
+buildPythonPackage {
+  inherit pname version;
+  pyproject = true;
+
+  src = fetchPypi {
+    inherit pname version;
+    hash = "sha256-sENuSdA4pYt8v2w2RvDkcQLYCP9V0vZOdWOlkNBi3/o=";
+  };
+
+  propagatedBuildInputs = [
+    certifi
+    cryptography
+    python-dateutil
+    typing-extensions
+    urllib3
+  ];
+
+  nativeBuildInputs = [
+    flit-core
+    pythonRelaxDepsHook
+  ];
+
+  pythonRelaxDeps = true;
+
+  pythonImportsCheck = [ "nethsm" ];
+
+  meta = with lib; {
+    description = "Client-side Python SDK for NetHSM";
+    homepage = "https://github.com/Nitrokey/nethsm-sdk-py";
+    changelog = "https://github.com/Nitrokey/nethsm-sdk-py/releases/tag/v${version}";
+    license = with licenses; [ asl20 ];
+    maintainers = with maintainers; [ frogamic ];
+  };
+}
diff --git a/pkgs/tools/security/pynitrokey/default.nix b/pkgs/tools/security/pynitrokey/default.nix
index 690d566c476d8..f6171b35c7014 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.42";
+  mainProgram = "nitropy";
+in
+
+buildPythonApplication {
+  inherit pname version;
+  pyproject = true;
 
   src = fetchPypi {
     inherit pname version;
-    hash = "sha256-Hu+8UooDzv4GhkWt0sCckQQyHjWn4V/zt2ADlVCoHmk=";
+    hash = "sha256-KLUuMTGiPqm2C3+TWS7nBNZAq+rGxAL/mMaT94SkYWY=";
   };
 
   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;
   };
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index e6bd6eb8d7689..a35ec0b9d1b3c 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -41736,7 +41736,7 @@ with pkgs;
 
   xrq = callPackage ../applications/misc/xrq { };
 
-  pynitrokey = callPackage ../tools/security/pynitrokey { };
+  pynitrokey = python3Packages.callPackage ../tools/security/pynitrokey { };
 
   nitrokey-app = libsForQt5.callPackage ../tools/security/nitrokey-app { };
 
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 68ff15c5e5be1..b60ba9aafd156 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -8142,6 +8142,8 @@ self: super: with self; {
 
   netdisco = callPackage ../development/python-modules/netdisco { };
 
+  nethsm = callPackage ../development/python-modules/nethsm { };
+
   netifaces = callPackage ../development/python-modules/netifaces { };
 
   netmiko = callPackage ../development/python-modules/netmiko { };