diff --git a/artiq-fast/pkgs/openocd.nix b/artiq-fast/pkgs/openocd.nix index 9d32c24..0d56cac 100644 --- a/artiq-fast/pkgs/openocd.nix +++ b/artiq-fast/pkgs/openocd.nix @@ -1,6 +1,13 @@ -{ stdenv, lib, fetchFromGitHub, autoreconfHook, libftdi, libusb1, pkgconfig, hidapi }: +{ stdenv, buildEnv, lib, fetchFromGitHub, autoreconfHook, libftdi, libusb1, pkgconfig, hidapi, openocd }: +let +bscan_spi_bitstreams = fetchFromGitHub { + owner = "quartiq"; + repo = "bscan_spi_bitstreams"; + rev = "01d8f819f15baf9a8cc5d96945a51e4d267ff564"; + sha256 = "1zqv47kzgvbn4c8cr019a6wcja7gn5h1z4kvw5bhpc72fyhagal9"; +}; -stdenv.mkDerivation rec { +openocd-mlabs = stdenv.mkDerivation rec { pname = "openocd-mlabs"; version = "0.10.0"; @@ -11,12 +18,7 @@ stdenv.mkDerivation rec { rev = "c383a57adcff332b2c5cf8d55a84626285b42c2c"; sha256 = "0xlj9cs72acx3zqagvr7f1c0v6lnqhl8fgrlhgmhmvk5n9knk492"; }; - bscan_spi_bitstreams = fetchFromGitHub { - owner = "quartiq"; - repo = "bscan_spi_bitstreams"; - rev = "01d8f819f15baf9a8cc5d96945a51e4d267ff564"; - sha256 = "1zqv47kzgvbn4c8cr019a6wcja7gn5h1z4kvw5bhpc72fyhagal9"; - }; + nativeBuildInputs = [ pkgconfig ]; buildInputs = [ autoreconfHook libftdi libusb1 hidapi ]; @@ -71,4 +73,23 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ sb0 ]; platforms = platforms.linux; }; -} +}; + +bscan_spi_bitstreams-pkg = stdenv.mkDerivation { + name = "bscan_spi_bitstreams"; + src = bscan_spi_bitstreams; + phases = ["installPhase"]; + installPhase = + '' + mkdir -p $out/share/bscan-spi-bitstreams + cp $src/*.bit $out/share/bscan-spi-bitstreams + ''; +}; + +openocd-upstream = buildEnv { + name = "openocd-bscanspi"; + paths = [ openocd bscan_spi_bitstreams-pkg ]; +}; + +in + if lib.versionAtLeast openocd.version "0.11" then openocd-upstream else openocd-mlabs