12 , enableFtdi ? true, libftdi1
14 # Allow selection the hardware targets (SBCs, JTAG Programmers, JTAG Adapters)
15 , extraHardwareSupport ? []
18 isWindows = stdenv.hostPlatform.isWindows;
19 notWindows = !isWindows;
22 stdenv.mkDerivation rec {
26 url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${pname}-${version}.tar.bz2";
27 sha256 = "sha256-ryVHiL6Yhh8r2RA/5uYKd07Jaow3R0Tu+Rl/YEMHWvo=";
30 nativeBuildInputs = [ pkg-config tcl ];
32 buildInputs = [ libusb1 ]
33 ++ lib.optionals notWindows [ hidapi jimtcl libftdi1 libjaylink ]
35 # tracking issue for v2 api changes https://sourceforge.net/p/openocd/tickets/306/
36 lib.optional stdenv.hostPlatform.isLinux libgpiod_1;
41 "--enable-remote-bitbang"
42 (lib.enableFeature notWindows "buspirate")
43 (lib.enableFeature (notWindows && enableFtdi) "ftdi")
44 (lib.enableFeature stdenv.hostPlatform.isLinux "linuxgpiod")
45 (lib.enableFeature stdenv.hostPlatform.isLinux "sysfsgpio")
46 (lib.enableFeature isWindows "internal-jimtcl")
47 (lib.enableFeature isWindows "internal-libjaylink")
49 map (hardware: "--enable-${hardware}") extraHardwareSupport
52 enableParallelBuilding = true;
54 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [
56 "-Wno-error=strict-prototypes" # fixes build failure with hidapi 0.10.0
59 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
60 mkdir -p "$out/etc/udev/rules.d"
61 rules="$out/share/openocd/contrib/60-openocd.rules"
62 if [ ! -f "$rules" ]; then
63 echo "$rules is missing, must update the Nix file."
66 ln -s "$rules" "$out/etc/udev/rules.d/"
70 description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing";
71 mainProgram = "openocd";
73 OpenOCD provides on-chip programming and debugging support with a layered
74 architecture of JTAG interface and TAP support, debug target support
75 (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several
76 network interfaces are available for interactiving with OpenOCD: HTTP,
77 telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a
78 "remote target" for source-level debugging of embedded systems using the
81 homepage = "https://openocd.sourceforge.net/";
82 license = licenses.gpl2Plus;
83 maintainers = with maintainers; [ bjornfor prusnak ];
84 platforms = platforms.unix ++ platforms.windows;