summary refs log tree commit diff
path: root/pkgs/development/arduino/arduino-core/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/arduino/arduino-core/default.nix')
-rw-r--r--pkgs/development/arduino/arduino-core/default.nix124
1 files changed, 74 insertions, 50 deletions
diff --git a/pkgs/development/arduino/arduino-core/default.nix b/pkgs/development/arduino/arduino-core/default.nix
index 3512dcbd2bc..1c537edd0b4 100644
--- a/pkgs/development/arduino/arduino-core/default.nix
+++ b/pkgs/development/arduino/arduino-core/default.nix
@@ -1,22 +1,36 @@
-{ stdenv, lib, fetchFromGitHub, fetchurl, jdk, ant
-, libusb-compat-0_1, libusb1, unzip, zlib, ncurses, readline
-, withGui ? false, gtk2 ? null, withTeensyduino ? false
+{ stdenv
+, lib
+, fetchFromGitHub
+, fetchurl
+, jdk
+, ant
+, libusb-compat-0_1
+, libusb1
+, unzip
+, zlib
+, ncurses
+, readline
+, withGui ? false
+, gtk2 ? null
+, withTeensyduino ? false
   /* Packages needed for Teensyduino */
-, upx, fontconfig, xorg, gcc
-, atk, glib, pango, gdk-pixbuf, libpng12, expat, freetype
-, cairo, udev
+, upx
+, fontconfig
+, xorg
+, gcc
+, atk
+, glib
+, pango
+, gdk-pixbuf
+, libpng12
+, expat
+, freetype
+, cairo
+, udev
 }:
 
 assert withGui -> gtk2 != null;
 assert withTeensyduino -> withGui;
-
-# TODO: Teensyduino is disabled for i686-linux due to an indefinite hang in the
-# xdotool script; the cause of this hang is not yet known.
-# TODO: There is a fair chance that Teensyduino works with arm-linux, but it
-# has not yet been tested.
-if withTeensyduino && (stdenv.hostPlatform.system != "x86_64-linux") then throw
-  "Teensyduino is only supported on x86_64-linux at this time (patches welcome)."
-else
 let
   externalDownloads = import ./downloads.nix {
     inherit fetchurl;
@@ -25,12 +39,13 @@ let
   };
   # Some .so-files are later copied from .jar-s to $HOME, so patch them beforehand
   patchelfInJars =
-       lib.optional (stdenv.hostPlatform.system == "x86_64-linux") {jar = "share/arduino/lib/jssc-2.8.0-arduino3.jar"; file = "libs/linux/libjSSC-2.8_x86_64.so";}
-    ++ lib.optional (stdenv.hostPlatform.system == "i686-linux") {jar = "share/arduino/lib/jssc-2.8.0-arduino3.jar"; file = "libs/linux/libjSSC-2.8_x86.so";}
+    lib.optional (stdenv.hostPlatform.system == "aarch64-linux") { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_aarch64.so"; }
+    ++ lib.optional (builtins.match "armv[67]l-linux" stdenv.hostPlatform.system != null) { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_armhf.so"; }
+    ++ lib.optional (stdenv.hostPlatform.system == "x86_64-linux") { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_x86_64.so"; }
+    ++ lib.optional (stdenv.hostPlatform.system == "i686-linux") { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_x86.so"; }
   ;
   # abiVersion 6 is default, but we need 5 for `avrdude_bin` executable
   ncurses5 = ncurses.override { abiVersion = "5"; };
-
   teensy_libpath = stdenv.lib.makeLibraryPath [
     atk
     cairo
@@ -53,50 +68,58 @@ let
     xorg.libXxf86vm
     zlib
   ];
-  teensy_architecture =
-      lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "linux64"
-      + lib.optionalString (stdenv.hostPlatform.system == "i686-linux") "linux32"
-      + lib.optionalString (stdenv.hostPlatform.system == "arm-linux") "linuxarm";
+  teensy_architecture = if stdenv.hostPlatform.isx86_32 then "linux32"
+                        else if stdenv.hostPlatform.isx86_64 then "linux64"
+                        else if stdenv.hostPlatform.isAarch64 then "linuxaarch64"
+                        else if stdenv.hostPlatform.isAarch32 then "linuxarm"
+                        else throw "${stdenv.hostPlatform.system} is not supported in teensy";
 
   flavor = (if withTeensyduino then "teensyduino" else "arduino")
              + stdenv.lib.optionalString (!withGui) "-core";
 in
 stdenv.mkDerivation rec {
-  version = "1.8.9";
+  version = "1.8.12";
   name = "${flavor}-${version}";
 
   src = fetchFromGitHub {
     owner = "arduino";
     repo = "Arduino";
     rev = version;
-    sha256 = "0kblq0bqap2zzkflrj6rmdi8dvqxa28fcwwrc3lfmbz2893ni3w4";
+    sha256 = "0lxkyvsh55biz2q20ba4qabraind5cpxznl41zfq027vl22j6kd2";
   };
 
-  teensyduino_version = "147";
+  teensyduino_version = "151";
   teensyduino_src = fetchurl {
     url = "https://www.pjrc.com/teensy/td_${teensyduino_version}/TeensyduinoInstall.${teensy_architecture}";
-    sha256 =
-      lib.optionalString (teensy_architecture == "linux64")
-        "09ysanip5d2f5axzd81z2l74ayng60zqhjxmxs7xa5098fff46il"
-      + lib.optionalString (teensy_architecture == "linux32")
-        "1zw3cfv2p62dwg8838vh0gd1934b18cyx7c13azvwmrpj601l0xx"
-      + lib.optionalString (teensy_architecture == "linuxarm")
-        "12421z26ksx84aldw1pq0cakh8jhs33mwafgvfij0zfgn9x0i877";
-    };
+    sha256 = {
+      linux64 = "0q8mw9bm2vb5vwa98gwcs6ad164i98hc1qqh2qw029yhwm599pn0";
+      linux32 = "1rq6sx0048ab200jy0cz5vznwxi99avidngj42rjnh7kcfas5c4m";
+      linuxarm = "19j55bq36040rpdpfxcqimda76rkbx137q15bs8nvxj13wrbl4ip";
+      linuxaarch64 = "09k78dycn1vcpcx37c1dak8bgjv8gs34l89n9r9s0c3rqmv3pg4x";
+    }.${teensy_architecture} or (throw "No arduino binaries for ${teensy_architecture}");
+  };
   # Used because teensyduino requires jars be a specific size
   arduino_dist_src = fetchurl {
     url = "http://downloads.arduino.cc/arduino-${version}-${teensy_architecture}.tar.xz";
     sha256 =
-      lib.optionalString (teensy_architecture == "linux64")
-        "1lv4in9j0r8s0cis4zdvbk2637vlj12w69wdxgcxcrwvkcdahkpa"
-      + lib.optionalString (teensy_architecture == "linux32")
-        "0zla3a6gd9prclgrbbgsmhf8ds8zb221m65x21pvz0y1cwsdvjpm"
-      + lib.optionalString (teensy_architecture == "linuxarm")
-        "1w5m49wfd68zazli0lf3w4zykab8n7mzp3wnbjqfpx2vip80bqnz";
+      {
+        linux64 = "128f34kkxz7ab6ir5mqyr8d1mgxig8f9jygwxy44pdnq2rk6gmh9";
+        linux32 = "11n85lwsn1w4ysfacyw08v85s3f3zvl8j8ac7rld19yxgjslvisi";
+        linuxarm = "1k8yjivaydm6y16mplrjyblgx7l0wjzm3mjxh5saxrjq7drswmxx";
+        linuxaarch64 = "04v2nhyjhahml6nmz23bfb63c0an4a7zxgcgxqqq442i8vd304wa";
+      }.${teensy_architecture} or (throw "No arduino binaries for ${teensy_architecture}");
   };
 
 
-  buildInputs = [ jdk ant libusb-compat-0_1 libusb1 unzip zlib ncurses5 readline
+  buildInputs = [
+    jdk
+    ant
+    libusb-compat-0_1
+    libusb1
+    unzip
+    zlib
+    ncurses5
+    readline
   ] ++ stdenv.lib.optionals withTeensyduino [ upx ];
   downloadSrcList = builtins.attrValues externalDownloads;
   downloadDstList = builtins.attrNames externalDownloads;
@@ -116,7 +139,8 @@ stdenv.mkDerivation rec {
 
     # Deliberately break build.xml's download statement in order to cause
     # an error if anything needed is missing from download.nix.
-    substituteInPlace build/build.xml --replace "get src" "get error"
+    substituteInPlace build/build.xml \
+      --replace 'ignoreerrors="true"' 'ignoreerrors="false"'
 
     cd ./arduino-core && ant
     cd ../build && ant
@@ -125,11 +149,11 @@ stdenv.mkDerivation rec {
 
   # This will be patched into `arduino` wrapper script
   # Java loads gtk dynamically, so we need to provide it using LD_LIBRARY_PATH
-  dynamicLibraryPath = lib.makeLibraryPath [gtk2];
-  javaPath = lib.makeBinPath [jdk];
+  dynamicLibraryPath = lib.makeLibraryPath [ gtk2 ];
+  javaPath = lib.makeBinPath [ jdk ];
 
   # Everything else will be patched into rpath
-  rpath = (lib.makeLibraryPath [zlib libusb-compat-0_1 libusb1 readline ncurses5 stdenv.cc.cc]);
+  rpath = (lib.makeLibraryPath [ zlib libusb-compat-0_1 libusb1 readline ncurses5 stdenv.cc.cc ]);
 
   installPhase = ''
     mkdir -p $out/share/arduino
@@ -192,19 +216,19 @@ stdenv.mkDerivation rec {
     done
 
     ${lib.concatMapStringsSep "\n"
-        ({jar, file}:
+      ({ jar, file }:
           ''
-              jar xvf $out/${jar} ${file}
-              patchelf --set-rpath $rpath ${file}
-              jar uvf $out/${jar} ${file}
-              rm -f ${file}
+            jar xvf $out/${jar} ${file}
+            patchelf --set-rpath $rpath ${file}
+            jar uvf $out/${jar} ${file}
+            rm -f ${file}
           ''
         )
-        patchelfInJars}
+      patchelfInJars}
 
     # avrdude_bin is linked against libtinfo.so.5
     mkdir $out/lib/
-    ln -s ${lib.makeLibraryPath [ncurses5]}/libtinfo.so.5 $out/lib/libtinfo.so.5
+    ln -s ${lib.makeLibraryPath [ ncurses5 ]}/libtinfo.so.5 $out/lib/libtinfo.so.5
 
     ${stdenv.lib.optionalString withTeensyduino ''
       # Patch the Teensy loader binary