summary refs log tree commit diff
path: root/pkgs/development/misc
diff options
context:
space:
mode:
authorAaron Lindsay <aerialx@users.noreply.github.com>2019-07-02 13:46:54 -0700
committerAaron Lindsay <aerialx@users.noreply.github.com>2020-06-01 16:53:43 -0700
commitceef1d2f27b4e1be6d6e3a49ed72c4c7501087df (patch)
tree8a8e10e4cd227102a7defec0a692a28e57ca6ddc /pkgs/development/misc
parent1436bb9968fd14f2b992b2150c83d9b671d3a75e (diff)
downloadnixpkgs-ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df.tar
nixpkgs-ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df.tar.gz
nixpkgs-ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df.tar.bz2
nixpkgs-ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df.tar.lz
nixpkgs-ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df.tar.xz
nixpkgs-ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df.tar.zst
nixpkgs-ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df.zip
mspdebug: fix darwin build
Diffstat (limited to 'pkgs/development/misc')
-rw-r--r--pkgs/development/misc/msp430/mspdebug.nix20
1 files changed, 18 insertions, 2 deletions
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";
   };
 
+  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 = stdenv.lib.optional (!enableReadline) "WITHOUT_READLINE=1";
-  enableParallelBuilding = true;
+  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";