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