1 { lib, callPackage, stdenv, fetchFromGitHub, cmake, bison, flex, libusb1, elfutils
2 , libftdi1, readline, hidapi, libserialport
3 # Documentation building doesn't work on Darwin. It fails with:
4 # Undefined subroutine &Locale::Messages::dgettext called in ... texi2html
6 # https://github.com/NixOS/nixpkgs/issues/224761
7 , docSupport ? (!stdenv.hostPlatform.isDarwin), texliveMedium, texinfo, texi2html, unixtools }:
10 useElfutils = lib.meta.availableOn stdenv.hostPlatform elfutils;
13 stdenv.mkDerivation (finalAttrs: {
17 src = fetchFromGitHub {
20 rev = "v${finalAttrs.version}";
21 sha256 = "sha256-JqW3AOMmAfcy+PQRcqviWlxA6GoMSEfzIFt1pRYY7Dw=";
24 nativeBuildInputs = [ cmake bison flex ] ++ lib.optionals docSupport [
32 (if useElfutils then elfutils else finalAttrs.finalPackage.passthru.libelf)
40 postPatch = lib.optionalString (!useElfutils) ''
41 # vendored libelf is a static library
42 sed -i "s/PREFERRED_LIBELF elf/PREFERRED_LIBELF libelf.a elf/" CMakeLists.txt
46 # -DHAVE_LINUXGPIO=ON because it's incompatible with libgpiod 2.x
47 cmakeFlags = lib.optionals docSupport [ "-DBUILD_DOC=ON" ]
48 ++ lib.optionals stdenv.hostPlatform.isLinux [ "-DHAVE_LINUXSPI=ON" "-DHAVE_PARPORT=ON" ];
50 # dvips output references texlive in comments, resulting in a huge closure
51 postInstall = lib.optionalString docSupport ''
52 rm $out/share/doc/avrdude/*.ps
56 # Vendored and mutated copy of libelf for avrdudes use.
57 # Produces a static library only.
58 libelf = callPackage ./libelf.nix { };
62 description = "Command-line tool for programming Atmel AVR microcontrollers";
63 mainProgram = "avrdude";
65 AVRDUDE (AVR Downloader/UploaDEr) is an utility to
66 download/upload/manipulate the ROM and EEPROM contents of AVR
67 microcontrollers using the in-system programming technique (ISP).
69 homepage = "https://www.nongnu.org/avrdude/";
70 license = licenses.gpl2Plus;
71 platforms = with platforms; linux ++ darwin;
72 maintainers = [ maintainers.bjornfor ];