Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv 2, lib 3, fetchurl 4, pkg-config 5, hidapi 6, jimtcl 7, libjaylink 8, libusb1 9, libgpiod 10 11, enableFtdi ? true, libftdi1 12 13# Allow selection the hardware targets (SBCs, JTAG Programmers, JTAG Adapters) 14, extraHardwareSupport ? [] 15}: 16 17stdenv.mkDerivation rec { 18 pname = "openocd"; 19 version = "0.12.0"; 20 src = fetchurl { 21 url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${pname}-${version}.tar.bz2"; 22 sha256 = "sha256-ryVHiL6Yhh8r2RA/5uYKd07Jaow3R0Tu+Rl/YEMHWvo="; 23 }; 24 25 nativeBuildInputs = [ pkg-config ]; 26 27 buildInputs = [ hidapi jimtcl libftdi1 libjaylink libusb1 ] 28 ++ lib.optional stdenv.isLinux libgpiod; 29 30 configureFlags = [ 31 "--disable-werror" 32 "--disable-internal-jimtcl" 33 "--disable-internal-libjaylink" 34 "--enable-jtag_vpi" 35 "--enable-buspirate" 36 "--enable-remote-bitbang" 37 (lib.enableFeature enableFtdi "ftdi") 38 (lib.enableFeature stdenv.isLinux "linuxgpiod") 39 (lib.enableFeature stdenv.isLinux "sysfsgpio") 40 ] ++ 41 map (hardware: "--enable-${hardware}") extraHardwareSupport 42 ; 43 44 enableParallelBuilding = true; 45 46 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ 47 "-Wno-error=cpp" 48 "-Wno-error=strict-prototypes" # fixes build failure with hidapi 0.10.0 49 ]); 50 51 postInstall = lib.optionalString stdenv.isLinux '' 52 mkdir -p "$out/etc/udev/rules.d" 53 rules="$out/share/openocd/contrib/60-openocd.rules" 54 if [ ! -f "$rules" ]; then 55 echo "$rules is missing, must update the Nix file." 56 exit 1 57 fi 58 ln -s "$rules" "$out/etc/udev/rules.d/" 59 ''; 60 61 meta = with lib; { 62 description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing"; 63 longDescription = '' 64 OpenOCD provides on-chip programming and debugging support with a layered 65 architecture of JTAG interface and TAP support, debug target support 66 (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several 67 network interfaces are available for interactiving with OpenOCD: HTTP, 68 telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a 69 "remote target" for source-level debugging of embedded systems using the 70 GNU GDB program. 71 ''; 72 homepage = "https://openocd.sourceforge.net/"; 73 license = licenses.gpl2Plus; 74 maintainers = with maintainers; [ bjornfor prusnak ]; 75 platforms = platforms.unix; 76 }; 77}