diff --git a/pkgs/development/python-modules/greatfet/default.nix b/pkgs/development/python-modules/greatfet/default.nix index 7883daea7aa7..226e9d40d756 100644 --- a/pkgs/development/python-modules/greatfet/default.nix +++ b/pkgs/development/python-modules/greatfet/default.nix @@ -2,7 +2,7 @@ buildPythonPackage, cmsis-svd, fetchFromGitHub, - future, + fetchPypi, ipython, lib, prompt-toolkit, @@ -12,26 +12,51 @@ setuptools, tabulate, tqdm, + unzip, }: buildPythonPackage rec { pname = "greatfet"; - version = "2025.0.0"; + version = "2026.0.0"; pyproject = true; src = fetchFromGitHub { owner = "greatscottgadgets"; repo = "greatfet"; tag = "v${version}"; - hash = "sha256-tY1ZUtjCeb0+EmmbzKbIcPQrjHc3JzgA/6yDuFwwHu4="; + hash = "sha256-qXPNatakMVtvl26FG1bx+ngCeqRpg1So6qFamKK8WWk="; + }; + + # The prebuilt LPC firmware image (greatfet_usb.bin) and the DFU recovery + # stub (flash_stub.bin) are release artifacts cross-compiled from firmware/. + # They are absent from the git checkout (their build inputs are now-empty + # submodules) but are shipped in the upstream wheel. Without them + # `greatfet_firmware --autoflash` and DFU-mode firmware recovery are + # unavailable, so vendor them from the wheel to match `pip install greatfet`. + firmwareAssets = fetchPypi { + inherit pname version; + format = "wheel"; + dist = "py3"; + python = "py3"; + hash = "sha256-sH1FAkfdC0HxRLZjfx7b2AYWMh4rtSijFgsU/YnVKq0="; }; sourceRoot = "${src.name}/host"; + nativeBuildInputs = [ unzip ]; + postPatch = '' substituteInPlace pyproject.toml \ --replace-fail ', "setuptools-git-versioning<2"' "" \ --replace-fail 'dynamic = ["version"]' 'version = "${version}"' + + # Restore the prebuilt firmware images shipped in the upstream wheel; the + # existing MANIFEST.in (recursive-include greatfet/assets *) then packages + # them into greatfet/assets/ where find_greatfet_asset() looks at runtime. + unzip -j -o ${firmwareAssets} \ + 'greatfet/assets/greatfet_usb.bin' \ + 'greatfet/assets/flash_stub.bin' \ + -d greatfet/assets/ ''; build-system = [ setuptools ]; @@ -40,7 +65,6 @@ buildPythonPackage rec { dependencies = [ cmsis-svd - future ipython prompt-toolkit pyfwup