commit a5fbe03b27ef914c67ac29d6c03000c671925499 Author: Denis Knauf Date: Thu May 25 15:21:01 2023 +0200 depends on nixos-23.05-small instead of unstable. improvements from nixos-23.05-small copied, but newer version (0.4.37). diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..28651c2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1684968804, + "narHash": "sha256-y78lDeiJC/MSOM6HBe1VI5G2lrrmJMkWigRuOrf20uA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f69907854223d6d49f75b1ae52b2f6567f711d90", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..586e1b8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,14 @@ +# vim: set noet sw=2 ts=2 sts=2: +{ + description = "nitropy cli"; + inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05-small; + outputs = { self, nixpkgs }: { + defaultPackage.x86_64-linux = + # Notice the reference to nixpkgs here. + with import nixpkgs { + system = "x86_64-linux"; + config.allowUnfree = true; + }; + callPackage ./pynitrokey.nix { }; + }; +} diff --git a/pynitrokey.nix b/pynitrokey.nix new file mode 100644 index 0000000..6cee3e1 --- /dev/null +++ b/pynitrokey.nix @@ -0,0 +1,66 @@ +{ python3Packages, lib, pkgs, nrfutil, libnitrokey }: + +with python3Packages; + +buildPythonApplication rec { + pname = "pynitrokey"; + version = "0.4.37"; + format = "flit"; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256-KoZym1b+E0P3kRt0PTm9wCX4nO31isDIwEq38xMgDDU="; + }; + + propagatedBuildInputs = [ + certifi + cffi + click + cryptography + ecdsa + frozendict + fido2 + intelhex + nkdfu + nrfutil + python-dateutil + pyusb + requests + spsdk + tqdm + urllib3 + tlv8 + typing-extensions + ]; + + nativeBuildInputs = [ + pythonRelaxDepsHook + ]; + + pythonRelaxDeps = [ + "cryptography" + "protobuf" + "python-dateutil" + "spsdk" + "typing_extensions" + ]; + + # no tests + doCheck = false; + + # libnitrokey is not propagated to users of pynitrokey + # It is only usable from the wrapped bin/nitropy + makeWrapperArgs = [ + "--set LIBNK_PATH ${lib.makeLibraryPath [ libnitrokey ]}" + ]; + + pythonImportsCheck = [ "pynitrokey" ]; + + 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"; + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..6e3e2a8 --- /dev/null +++ b/shell.nix @@ -0,0 +1,12 @@ +# vim: set noet sw=2 ts=2 sts=2: +{}: +#{ pkgs ? import { } }: +let + pkgs = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-23.05-small.tar.gz) { config.allowUnfree = true; }; + pynitrokey = pkgs.callPackage ./pynitrokey.nix { }; +in + pkgs.mkShell { + packages = [ + pynitrokey + ]; + }