Merge pull request #183099 from sbruder/update-pynitrokey

This commit is contained in:
Sandro 2022-08-17 14:02:10 +02:00 committed by GitHub
commit 2908c2160c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 2527 additions and 4 deletions

View File

@ -0,0 +1,72 @@
{ lib
, buildPythonPackage
, fetchPypi
, fetchpatch
, capstone
, cmsis-pack-manager
, colorama
, intelhex
, intervaltree
, natsort
, prettytable
, pyelftools
, pylink-square
, pyusb
, pyyaml
, typing-extensions
, stdenv
, hidapi
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "pyocd";
version = "0.34.1";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-Fpa2IEsLOQ8ylGI/5D6h+22j1pvrvE9IMIyhCtyM6qU=";
};
patches = [
# https://github.com/pyocd/pyOCD/pull/1332
(fetchpatch {
name = "libusb-package-optional.patch";
url = "https://github.com/pyocd/pyOCD/commit/0b980cf253e3714dd2eaf0bddeb7172d14089649.patch";
sha256 = "sha256-B2+50VntcQELeakJbCeJdgI1iBU+h2NkXqba+LRYa/0=";
})
];
propagatedBuildInputs = [
capstone
cmsis-pack-manager
colorama
intelhex
intervaltree
natsort
prettytable
pyelftools
pylink-square
pyusb
pyyaml
typing-extensions
] ++ lib.optionals (!stdenv.isLinux) [
hidapi
];
checkInputs = [ pytestCheckHook ];
pythonImportsCheck = [ "pyocd" ];
postPatch = ''
substituteInPlace setup.cfg \
--replace "libusb-package>=1.0,<2.0" ""
'';
meta = with lib; {
description = "Python library for programming and debugging Arm Cortex-M microcontrollers";
homepage = "https://pyocd.io/";
license = licenses.asl20;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -0,0 +1,37 @@
{ lib, stdenv, fetchzip, pkg-config, libusb1, systemdMinimal }:
let
binDirPrefix = if stdenv.isDarwin then "osx_" else "linux_";
in
stdenv.mkDerivation rec {
pname = "libusbsio";
version = "2.1.11";
src = fetchzip {
url = "https://www.nxp.com/downloads/en/libraries/libusbsio-${version}-src.zip";
sha256 = "sha256-qgoeaGWTWdTk5XpJwoauckEQlqB9lp5x2+TN09vQttI=";
};
postPatch = ''
rm -r bin/*
'';
nativeBuildInputs = [ pkg-config ];
buildInputs = [
libusb1
systemdMinimal # libudev
];
installPhase = ''
runHook preInstall
install -D bin/${binDirPrefix}${stdenv.hostPlatform.parsed.cpu.name}/libusbsio${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libusbsio${stdenv.hostPlatform.extensions.sharedLibrary}
runHook postInstall
'';
meta = with lib; {
homepage = "https://www.nxp.com/design/software/development-software/library-for-windows-macos-and-ubuntu-linux:LIBUSBSIO";
description = "Library for communicating with devices connected via the USB bridge on LPC-Link2 and MCU-Link debug probes on supported NXP microcontroller evaluation boards";
platforms = platforms.all;
license = licenses.bsd3;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -0,0 +1,21 @@
{ lib, buildPythonPackage, fetchPypi }:
buildPythonPackage rec {
pname = "argparse-addons";
version = "0.8.0";
src = fetchPypi {
pname = "argparse_addons";
inherit version;
sha256 = "sha256-uwiBB5RNM56NLnCnYwXd41FUTixb3rrxwttWrS5tzeg=";
};
pythonImportsCheck = [ "argparse_addons" ];
meta = with lib; {
description = "Additional Python argparse types and actions";
homepage = "https://github.com/eerimoq/argparse_addons";
license = licenses.mit;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -0,0 +1,26 @@
{ lib, buildPythonPackage, fetchPypi, argparse-addons, humanfriendly, pyelftools }:
buildPythonPackage rec {
pname = "bincopy";
version = "17.10.2";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-d1l+kqyGkBvctfKRHxCpve/8mLa7nTfDwXzxgJznce4=";
};
propagatedBuildInputs = [
argparse-addons
humanfriendly
pyelftools
];
pythonImportsCheck = [ "bincopy" ];
meta = with lib; {
description = "Mangling of various file formats that conveys binary information (Motorola S-Record, Intel HEX, TI-TXT, ELF and binary files)";
homepage = "https://github.com/eerimoq/bincopy";
license = licenses.mit;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
{ lib
, fetchPypi
, rustPlatform
, stdenv
, Security
, writeShellScriptBin
, buildPythonPackage
, setuptools-scm
, appdirs
, milksnake
, pyyaml
, hypothesis
, jinja2
, mock
, pytestCheckHook
}:
let
pname = "cmsis-pack-manager";
version = "0.4.0";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-NeUG6PFI2eTwq5SNtAB6ZMA1M3z1JmMND29V9/O5sgw=";
};
native = rustPlatform.buildRustPackage {
name = "${pname}-${version}-native";
inherit src;
buildInputs = lib.optionals stdenv.isDarwin [
Security
];
sourceRoot = "${pname}-${version}/rust";
cargoLock.lockFile = ./Cargo.lock;
postPatch = ''
cp ${./Cargo.lock} Cargo.lock
'';
cargoBuildFlags = [ "--lib" ];
};
in
buildPythonPackage rec {
inherit pname version src;
# The cargo build is already run in a separate derivation
postPatch = ''
substituteInPlace setup.py \
--replace "'cargo', 'build'," "'true',"
'';
nativeBuildInputs = [ setuptools-scm ];
propagatedBuildInputs = [ appdirs milksnake pyyaml ];
checkInputs = [ hypothesis jinja2 mock pytestCheckHook ];
preBuild = ''
mkdir -p rust/target/release/deps
ln -s ${native}/lib/libcmsis_cffi${stdenv.hostPlatform.extensions.sharedLibrary} rust/target/release/deps/
'';
preCheck = ''
# Otherwise the test uses a dummy library (missing all symbols)
ln -sf ../build/lib/cmsis_pack_manager/_native__lib${stdenv.hostPlatform.extensions.sharedLibrary} cmsis_pack_manager/_native__lib${stdenv.hostPlatform.extensions.sharedLibrary}
'';
pythonImportsCheck = [ "cmsis_pack_manager" ];
meta = with lib; {
description = "A Rust and Python module for handling CMSIS Pack files";
homepage = "https://github.com/pyocd/cmsis-pack-manager";
license = licenses.asl20;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -0,0 +1,32 @@
{ lib, buildPythonPackage, fetchPypi }:
buildPythonPackage rec {
pname = "hexdump";
version = "3.3";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-14GkOwwWrOP5Nmqt5z6K06e9UTfVjwtFqy0/VIdvINs=";
extension = "zip";
};
# the source zip has no prefix, so everything gets unpacked to /build otherwise
sourceRoot = "source";
unpackPhase = ''
runHook preUnpack
mkdir source
pushd source
unzip $src
popd
runHook postUnpack
'';
pythonImportsCheck = [ "hexdump" ];
meta = with lib; {
description = "Library to dump binary data to hex format and restore from there";
homepage = "https://pypi.org/project/hexdump/"; # BitBucket site returns 404
license = licenses.publicDomain;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -0,0 +1,34 @@
{ lib, buildPythonPackage, libusbsio }:
buildPythonPackage rec {
pname = "libusbsio";
inherit (libusbsio) version;
src = "${libusbsio.src}/python";
# The source includes both the python module directly and also a source tarball for it.
# The direct files lack setup information, the tarball includes unwanted binaries.
# This takes only the setup files from the tarball.
postUnpack = ''
tar -C python --strip-components=1 -xf python/dist/libusbsio-${version}.tar.gz libusbsio-${version}/{setup.py,setup.cfg,pyproject.toml}
rm -r python/dist
'';
postPatch = ''
substituteInPlace libusbsio/libusbsio.py \
--replace "dllpath = LIBUSBSIO._lookup_dll_path(dfltdir, dllname)" 'dllpath = "${libusbsio}/lib/" + dllname'
'';
buildInputs = [ libusbsio ];
doCheck = false; # they require a device to be connected over USB
pythonImportsCheck = [ "libusbsio" ];
meta = with lib; {
description = "NXP Secure Provisioning SDK";
homepage = "https://github.com/NXPmicro/spsdk";
license = licenses.bsd3;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -22,9 +22,16 @@ buildPythonPackage rec {
hash = "sha256-CmDypmlc/kb6ONCUggjT1Iqd29xNSLRaGh5Hz36dvOw="; hash = "sha256-CmDypmlc/kb6ONCUggjT1Iqd29xNSLRaGh5Hz36dvOw=";
}; };
postPatch = ''
for file in oscrypto/_openssl/_lib{crypto,ssl}_c{ffi,types}.py; do
substituteInPlace $file \
--replace "get_library('crypto', 'libcrypto.dylib', '42')" "'${openssl.out}/lib/libcrypto${stdenv.hostPlatform.extensions.sharedLibrary}'" \
--replace "get_library('ssl', 'libssl', '44')" "'${openssl.out}/lib/libssl${stdenv.hostPlatform.extensions.sharedLibrary}'"
done
'';
propagatedBuildInputs = [ propagatedBuildInputs = [
asn1crypto asn1crypto
openssl
]; ];
checkInputs = [ checkInputs = [

View File

@ -0,0 +1,24 @@
{ lib, buildPythonPackage, fetchPypi, autoPatchelfHook }:
buildPythonPackage rec {
pname = "pypemicro";
version = "0.1.9";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-HouDBlqfokKhbdWWDCfaUJrqIEC5f+sSnVmsrRseFmU=";
};
pythonImportsCheck = [ "pypemicro" ];
# tests are neither pytest nor unittest compatible and require a device
# connected via USB
doCheck = false;
meta = with lib; {
description = "Python interface for PEMicro debug probes";
homepage = "https://github.com/NXPmicro/pypemicro";
license = with licenses; [ bsd3 unfree ]; # it includes shared libraries for which no license is available (https://github.com/NXPmicro/pypemicro/issues/10)
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -0,0 +1,116 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, fetchpatch
, dos2unix
, pythonRelaxDepsHook
, asn1crypto
, astunparse
, bincopy
, bitstring
, click
, click-option-group
, cmsis-pack-manager
, commentjson
, crcmod
, cryptography
, deepmerge
, fastjsonschema
, hexdump
, jinja2
, libusbsio
, oscrypto
, pycryptodome
, pylink-square
, pyocd
, pypemicro
, pyserial
, ruamel-yaml
, sly
, pytestCheckHook
, voluptuous
}:
buildPythonPackage rec {
pname = "spsdk";
version = "1.6.3";
src = fetchFromGitHub {
owner = "NXPmicro";
repo = pname;
rev = version;
sha256 = "sha256-JMhd2XdbjEN6SUzFgcBHd/dStiuYeXXis6pfijSfUso=";
};
patches = [
# https://github.com/NXPmicro/spsdk/pull/43
(fetchpatch {
name = "cryptography-37-compat.patch";
url = "https://github.com/NXPmicro/spsdk/commit/a85b854de1093de593d27fa64de442224ab2e0fd.patch";
sha256 = "sha256-4pXV/8RaNuGl7KNdoGD/8YnPQ2ZmUQOjXWA/Yy0Kxu8=";
})
# https://github.com/NXPmicro/spsdk/pull/41
(fetchpatch {
name = "blhost-click-8-1-compat.patch";
url = "https://github.com/NXPmicro/spsdk/commit/5112b1b69aa681d265035475e73d28ea0c8cb6ab.patch";
sha256 = "sha256-Okz6Er6OVuAA5IlB5IabSa/gUSLa+E2Ltd+J3uoIg6o=";
})
];
nativeBuildInputs = [ pythonRelaxDepsHook ];
pythonRelaxDeps = [
"cmsis-pack-manager"
"cryptography"
"deepmerge"
"jinja2"
"pylink-square"
"pyocd"
];
pythonRemoveDeps = [ "pyocd-pemicro" ];
propagatedBuildInputs = [
asn1crypto
astunparse
bincopy
bitstring
click
click-option-group
cmsis-pack-manager
commentjson
crcmod
cryptography
deepmerge
fastjsonschema
hexdump
jinja2
libusbsio
oscrypto
pycryptodome
pylink-square
pyocd
pypemicro
pyserial
ruamel-yaml
sly
];
checkInputs = [
pytestCheckHook
voluptuous
];
disabledTests = [
# tests also fail on debian, so presumable they are broken
"test_elftosb_mbi_signed"
"test_elftosb_sb31"
];
pythonImportsCheck = [ "spsdk" ];
meta = with lib; {
description = "NXP Secure Provisioning SDK";
homepage = "https://github.com/NXPmicro/spsdk";
license = licenses.bsd3;
maintainers = with maintainers; [ frogamic sbruder ];
};
}

View File

@ -1,15 +1,15 @@
{ python3Packages, lib }: { python3Packages, lib, nrfutil }:
with python3Packages; with python3Packages;
buildPythonApplication rec { buildPythonApplication rec {
pname = "pynitrokey"; pname = "pynitrokey";
version = "0.4.9"; version = "0.4.26";
format = "flit"; format = "flit";
src = fetchPypi { src = fetchPypi {
inherit pname version; inherit pname version;
sha256 = "sha256-mhH6mVgLRX87PSGTFkj1TE75jU1lwcaRZWbC67T+vWo="; sha256 = "sha256-OuLR6txvoOpOUYpkjA5UkXUIIa1hYCwTmmPuUC3i4zM=";
}; };
propagatedBuildInputs = [ propagatedBuildInputs = [
@ -18,17 +18,25 @@ buildPythonApplication rec {
ecdsa ecdsa
fido2 fido2
intelhex intelhex
nrfutil
pyserial pyserial
pyusb pyusb
requests requests
pygments pygments
python-dateutil python-dateutil
spsdk
urllib3 urllib3
cffi cffi
cbor cbor
nkdfu nkdfu
]; ];
# spsdk is patched to allow for newer cryptography
postPatch = ''
substituteInPlace pyproject.toml \
--replace "cryptography >=3.4.4,<37" "cryptography"
'';
# no tests # no tests
doCheck = false; doCheck = false;

View File

@ -10032,6 +10032,8 @@ with pkgs;
pympress = callPackage ../applications/office/pympress { }; pympress = callPackage ../applications/office/pympress { };
pyocd = python3Packages.callPackage ../development/embedded/pyocd { };
pyspread = libsForQt5.callPackage ../applications/office/pyspread { }; pyspread = libsForQt5.callPackage ../applications/office/pyspread { };
teapot = callPackage ../applications/office/teapot { }; teapot = callPackage ../applications/office/teapot { };
@ -19946,6 +19948,8 @@ with pkgs;
libusbmuxd = callPackage ../development/libraries/libusbmuxd { }; libusbmuxd = callPackage ../development/libraries/libusbmuxd { };
libusbsio = callPackage ../development/libraries/libusbsio { };
libutempter = callPackage ../development/libraries/libutempter { }; libutempter = callPackage ../development/libraries/libutempter { };
libuldaq = callPackage ../development/libraries/libuldaq { }; libuldaq = callPackage ../development/libraries/libuldaq { };

View File

@ -685,6 +685,8 @@ in {
argon2-cffi-bindings = callPackage ../development/python-modules/argon2-cffi-bindings { }; argon2-cffi-bindings = callPackage ../development/python-modules/argon2-cffi-bindings { };
argparse-addons = callPackage ../development/python-modules/argparse-addons { };
args = callPackage ../development/python-modules/args { }; args = callPackage ../development/python-modules/args { };
aria2p = callPackage ../development/python-modules/aria2p { }; aria2p = callPackage ../development/python-modules/aria2p { };
@ -1305,6 +1307,8 @@ in {
binaryornot = callPackage ../development/python-modules/binaryornot { }; binaryornot = callPackage ../development/python-modules/binaryornot { };
bincopy = callPackage ../development/python-modules/bincopy { };
binho-host-adapter = callPackage ../development/python-modules/binho-host-adapter { }; binho-host-adapter = callPackage ../development/python-modules/binho-host-adapter { };
binwalk = callPackage ../development/python-modules/binwalk { }; binwalk = callPackage ../development/python-modules/binwalk { };
@ -1882,6 +1886,10 @@ in {
inherit (pkgs) cmigemo; inherit (pkgs) cmigemo;
}; };
cmsis-pack-manager = callPackage ../development/python-modules/cmsis-pack-manager {
inherit (pkgs.darwin.apple_sdk.frameworks) Security;
};
cmsis-svd = callPackage ../development/python-modules/cmsis-svd { }; cmsis-svd = callPackage ../development/python-modules/cmsis-svd { };
cntk = callPackage ../development/python-modules/cntk { }; cntk = callPackage ../development/python-modules/cntk { };
@ -4081,6 +4089,8 @@ in {
hexbytes = callPackage ../development/python-modules/hexbytes { }; hexbytes = callPackage ../development/python-modules/hexbytes { };
hexdump = callPackage ../development/python-modules/hexdump { };
hg-commitsigs = callPackage ../development/python-modules/hg-commitsigs { }; hg-commitsigs = callPackage ../development/python-modules/hg-commitsigs { };
hg-evolve = callPackage ../development/python-modules/hg-evolve { }; hg-evolve = callPackage ../development/python-modules/hg-evolve { };
@ -5124,6 +5134,10 @@ in {
inherit (pkgs) libusb1; inherit (pkgs) libusb1;
}; };
libusbsio = callPackage ../development/python-modules/libusbsio {
inherit (pkgs) libusbsio;
};
libversion = callPackage ../development/python-modules/libversion { libversion = callPackage ../development/python-modules/libversion {
inherit (pkgs) libversion; inherit (pkgs) libversion;
}; };
@ -6645,6 +6659,8 @@ in {
psrpcore = callPackage ../development/python-modules/psrpcore { }; psrpcore = callPackage ../development/python-modules/psrpcore { };
pypemicro = callPackage ../development/python-modules/pypemicro { };
pyprecice = callPackage ../development/python-modules/pyprecice { }; pyprecice = callPackage ../development/python-modules/pyprecice { };
pypsrp = callPackage ../development/python-modules/pypsrp { }; pypsrp = callPackage ../development/python-modules/pypsrp { };
@ -10277,6 +10293,8 @@ in {
spotipy = callPackage ../development/python-modules/spotipy { }; spotipy = callPackage ../development/python-modules/spotipy { };
spsdk = callPackage ../development/python-modules/spsdk { };
spur = callPackage ../development/python-modules/spur { }; spur = callPackage ../development/python-modules/spur { };
spyder = callPackage ../development/python-modules/spyder { }; spyder = callPackage ../development/python-modules/spyder { };