Something went wrong. Try again.
Nix Packages collection & NixOS github.com/NixOS/nixpkgs
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130{ lib, fetchFromGitHub, buildPythonPackage, callPackage, python,
# gateware (FPGA toolchain) nextpnr, trellis, which, yosys,
# build-system setuptools,
# dependencies amaranth, apollo-fpga, libusb1, luna-soc, luna-usb, prompt-toolkit, pyfwup, pygreat, pyserial, pyusb, tabulate, tomli, tqdm,
# tests pytestCheckHook, udevCheckHook,}:let version = "0.2.5";
src = fetchFromGitHub { owner = "greatscottgadgets"; repo = "cynthion"; tag = version; hash = "sha256-Ju01eqBVZ7CD0pw4nIFML4LcCPXzC78dLpQru3a+5bU="; };
# Moondancer SoC firmware, required for `cynthion flash facedancer`. moondancer = callPackage ./moondancer.nix { inherit src version; };inbuildPythonPackage { pname = "cynthion"; inherit version src; pyproject = true;
sourceRoot = "${src.name}/cynthion/python";
postPatch = '' substituteInPlace pyproject.toml \ --replace-fail '"setuptools-git-versioning<2"' "" \ --replace-fail 'dynamic = ["version"]' 'version = "${version}"' '';
nativeBuildInputs = [ udevCheckHook
# Used by the gateware build in postInstall. nextpnr trellis which yosys ];
build-system = [ setuptools ];
pythonRelaxDeps = [ "pygreat" ]; pythonRemoveDeps = [ "future" ];
dependencies = [ amaranth apollo-fpga libusb1 luna-soc luna-usb prompt-toolkit pyfwup pygreat pyserial pyusb tabulate tomli tqdm ];
nativeCheckInputs = [ pytestCheckHook ];
# Build the per-revision FPGA bitstreams in parallel (see build_gateware.py). enableParallelBuilding = true;
pythonImportsCheck = [ "cynthion" ];
postInstall = let assets = "$out/${python.sitePackages}/cynthion/assets"; in '' # Build a bitstream set per hardware revision into assets/, where # `cynthion flash` looks for them. export BUILD_GATEWARE_MAX_WORKERS="''${NIX_BUILD_CORES:-1}" PYTHONPATH="$out/${python.sitePackages}''${PYTHONPATH:+:$PYTHONPATH}" \ python -P ${./build_gateware.py} "${assets}"
# Install the moondancer SoC firmware for `cynthion flash facedancer`. install -Dm444 ${moondancer}/bin/moondancer.bin "${assets}/moondancer.bin"
# Make udev rules available for NixOS option services.udev.packages install -Dm444 \ -t $out/lib/udev/rules.d \ build/lib/cynthion/assets/54-cynthion.rules '';
passthru = { inherit moondancer; };
meta = { description = "Python package and utilities for the Great Scott Gadgets Cynthion USB Test Instrument"; homepage = "https://github.com/greatscottgadgets/cynthion"; changelog = "https://github.com/greatscottgadgets/cynthion/releases/tag/${src.tag}"; license = lib.licenses.bsd3; maintainers = with lib.maintainers; [ karstx ]; };}