diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix index f8abc15de57..181907a5544 100644 --- a/pkgs/development/misc/msp430/mspdebug.nix +++ b/pkgs/development/misc/msp430/mspdebug.nix @@ -3,8 +3,11 @@ , libusb-compat-0_1 , readline ? null , enableReadline ? true +, hidapi ? null +, pkg-config ? null }: +assert stdenv.isDarwin -> hidapi != null && pkg-config != null; assert enableReadline -> readline != null; stdenv.mkDerivation rec { @@ -17,11 +20,24 @@ stdenv.mkDerivation rec { sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"; }; - buildInputs = [ libusb-compat-0_1 ] - ++ stdenv.lib.optional enableReadline readline; - installFlags = [ "PREFIX=$(out)" "INSTALL=install" ]; - makeFlags = stdenv.lib.optional (!enableReadline) "WITHOUT_READLINE=1"; enableParallelBuilding = true; + nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin pkg-config; + buildInputs = [ libusb-compat-0_1 ] + ++ stdenv.lib.optional stdenv.isDarwin hidapi + ++ stdenv.lib.optional enableReadline readline; + + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + # TODO: remove once a new 0.26+ release is made + substituteInPlace drivers/tilib_api.c --replace .so ${stdenv.hostPlatform.extensions.sharedLibrary} + + # Makefile only uses pkg-config if it detects homebrew + substituteInPlace Makefile --replace brew true + ''; + + installFlags = [ "PREFIX=$(out)" "INSTALL=install" ]; + makeFlags = [ "UNAME_S=$(unameS)" ] ++ + stdenv.lib.optional (!enableReadline) "WITHOUT_READLINE=1"; + unameS = stdenv.lib.optionalString stdenv.isDarwin "Darwin"; meta = with stdenv.lib; { description = "A free programmer, debugger, and gdb proxy for MSP430 MCUs";