16 # Allow selection the hardware targets (SBCs, JTAG Programmers, JTAG Adapters)
17 extraHardwareSupport ? [ ],
21 isWindows = stdenv.hostPlatform.isWindows;
22 notWindows = !isWindows;
25 stdenv.mkDerivation rec {
29 url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${pname}-${version}.tar.bz2";
30 sha256 = "sha256-ryVHiL6Yhh8r2RA/5uYKd07Jaow3R0Tu+Rl/YEMHWvo=";
40 ++ lib.optionals notWindows [
47 # tracking issue for v2 api changes https://sourceforge.net/p/openocd/tickets/306/
48 lib.optional stdenv.hostPlatform.isLinux libgpiod_1;
53 "--enable-remote-bitbang"
54 (lib.enableFeature notWindows "buspirate")
55 (lib.enableFeature (notWindows && enableFtdi) "ftdi")
56 (lib.enableFeature stdenv.hostPlatform.isLinux "linuxgpiod")
57 (lib.enableFeature stdenv.hostPlatform.isLinux "sysfsgpio")
58 (lib.enableFeature isWindows "internal-jimtcl")
59 (lib.enableFeature isWindows "internal-libjaylink")
60 ] ++ map (hardware: "--enable-${hardware}") extraHardwareSupport;
62 enableParallelBuilding = true;
64 env.NIX_CFLAGS_COMPILE = toString (
65 lib.optionals stdenv.cc.isGNU [
67 "-Wno-error=strict-prototypes" # fixes build failure with hidapi 0.10.0
71 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
72 mkdir -p "$out/etc/udev/rules.d"
73 rules="$out/share/openocd/contrib/60-openocd.rules"
74 if [ ! -f "$rules" ]; then
75 echo "$rules is missing, must update the Nix file."
78 ln -s "$rules" "$out/etc/udev/rules.d/"
82 description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing";
83 mainProgram = "openocd";
85 OpenOCD provides on-chip programming and debugging support with a layered
86 architecture of JTAG interface and TAP support, debug target support
87 (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several
88 network interfaces are available for interactiving with OpenOCD: HTTP,
89 telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a
90 "remote target" for source-level debugging of embedded systems using the
93 homepage = "https://openocd.sourceforge.net/";
94 license = licenses.gpl2Plus;
95 maintainers = with maintainers; [
99 platforms = platforms.unix ++ platforms.windows;