Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv 2, fetchFromGitHub 3, autoPatchelfHook 4, libusb-compat-0_1 5, readline ? null 6, enableReadline ? true 7, hidapi ? null 8, pkg-config ? null 9, mspds ? null 10, enableMspds ? false 11}: 12 13assert stdenv.isDarwin -> hidapi != null && pkg-config != null; 14assert enableReadline -> readline != null; 15assert enableMspds -> mspds != null; 16 17stdenv.mkDerivation rec { 18 version = "0.25"; 19 pname = "mspdebug"; 20 src = fetchFromGitHub { 21 owner = "dlbeer"; 22 repo = "mspdebug"; 23 rev = "v${version}"; 24 sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"; 25 }; 26 27 enableParallelBuilding = true; 28 nativeBuildInputs = lib.optional stdenv.isDarwin pkg-config 29 ++ lib.optional (enableMspds && stdenv.isLinux) autoPatchelfHook; 30 buildInputs = [ libusb-compat-0_1 ] 31 ++ lib.optional stdenv.isDarwin hidapi 32 ++ lib.optional enableReadline readline; 33 34 postPatch = lib.optionalString stdenv.isDarwin '' 35 # TODO: remove once a new 0.26+ release is made 36 substituteInPlace drivers/tilib_api.c --replace .so ${stdenv.hostPlatform.extensions.sharedLibrary} 37 38 # Makefile only uses pkg-config if it detects homebrew 39 substituteInPlace Makefile --replace brew true 40 ''; 41 42 # TODO: wrap with MSPDEBUG_TILIB_PATH env var instead of these rpath fixups in 0.26+ 43 runtimeDependencies = lib.optional enableMspds mspds; 44 postFixup = lib.optionalString (enableMspds && stdenv.isDarwin) '' 45 # autoPatchelfHook only works on linux so... 46 for dep in $runtimeDependencies; do 47 install_name_tool -add_rpath $dep/lib $out/bin/$pname 48 done 49 ''; 50 51 installFlags = [ "PREFIX=$(out)" "INSTALL=install" ]; 52 makeFlags = [ "UNAME_S=$(unameS)" ] ++ 53 lib.optional (!enableReadline) "WITHOUT_READLINE=1"; 54 unameS = lib.optionalString stdenv.isDarwin "Darwin"; 55 56 meta = with lib; { 57 description = "A free programmer, debugger, and gdb proxy for MSP430 MCUs"; 58 homepage = "https://dlbeer.co.nz/mspdebug/"; 59 license = licenses.gpl2; 60 platforms = platforms.all; 61 maintainers = with maintainers; [ aerialx ]; 62 }; 63}