openocd: use upstream nixpkgs version if recent enough

This commit is contained in:
Sebastien Bourdeauducq 2021-07-26 17:06:05 +08:00
parent 988d411946
commit 2355ba148a

View File

@ -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