2015-02-04 21:23:18 +00:00
|
|
|
{ stdenv, fetchFromGitHub, jdk, jre, ant, coreutils, gnugrep, file, libusb
|
2016-05-08 05:14:39 +01:00
|
|
|
, unzip, zlib, readline, ncurses, withGui ? false, gtk2 ? null }:
|
2015-02-04 21:23:18 +00:00
|
|
|
|
|
|
|
assert withGui -> gtk2 != null;
|
2012-11-28 01:55:24 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
2016-05-08 05:14:39 +01:00
|
|
|
version = "1.6.6";
|
2015-05-14 16:18:17 +01:00
|
|
|
name = "arduino${stdenv.lib.optionalString (withGui == false) "-core"}-${version}";
|
2012-11-28 01:55:24 +00:00
|
|
|
|
2014-10-10 07:03:02 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "arduino";
|
|
|
|
repo = "Arduino";
|
|
|
|
rev = "${version}";
|
2016-05-08 05:14:39 +01:00
|
|
|
sha256 = "1gm3sjjs149r2d82ynx25qlg31bbird1zr4x01qi4ybk3gp0268v";
|
2012-11-28 01:55:24 +00:00
|
|
|
};
|
|
|
|
|
2016-05-08 05:14:39 +01:00
|
|
|
buildInputs = [ jdk ant file unzip ];
|
2012-11-28 01:55:24 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2016-05-08 05:14:39 +01:00
|
|
|
cd ./arduino-core && ant
|
2012-11-28 01:55:24 +00:00
|
|
|
cd ../build && ant
|
|
|
|
cd ..
|
|
|
|
'';
|
|
|
|
|
2016-05-08 05:14:39 +01:00
|
|
|
libPath = stdenv.lib.makeLibraryPath (builtins.filter (l: l != null) [
|
|
|
|
gtk2 stdenv.cc.cc zlib readline libusb ncurses]) + ":$out/lib";
|
|
|
|
|
2012-11-28 01:55:24 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share/arduino
|
2015-02-04 21:23:18 +00:00
|
|
|
cp -r ./build/linux/work/* "$out/share/arduino/"
|
2012-11-28 01:55:24 +00:00
|
|
|
echo ${version} > $out/share/arduino/lib/version.txt
|
2014-10-27 21:02:23 +00:00
|
|
|
|
2016-05-08 05:14:39 +01:00
|
|
|
# Hack around lack of libtinfo in NixOS
|
|
|
|
mkdir -p $out/lib
|
|
|
|
ln -s ${ncurses.out}/lib/libncursesw.so.5 $out/lib/libtinfo.so.5
|
|
|
|
|
2015-02-04 21:23:18 +00:00
|
|
|
${stdenv.lib.optionalString withGui ''
|
|
|
|
mkdir -p "$out/bin"
|
2016-05-08 05:14:39 +01:00
|
|
|
sed -i -e "s|^JAVA=.*|JAVA=${jdk}/bin/java|" "$out/share/arduino/arduino"
|
|
|
|
sed -i -e "s|^LD_LIBRARY_PATH=|LD_LIBRARY_PATH=${libPath}:|" "$out/share/arduino/arduino"
|
2015-02-04 21:23:18 +00:00
|
|
|
ln -sr "$out/share/arduino/arduino" "$out/bin/arduino"
|
|
|
|
''}
|
|
|
|
|
2014-10-27 21:02:23 +00:00
|
|
|
# Fixup "/lib64/ld-linux-x86-64.so.2" like references in ELF executables.
|
|
|
|
echo "running patchelf on prebuilt binaries:"
|
|
|
|
find "$out" | while read filepath; do
|
2016-05-08 05:14:39 +01:00
|
|
|
if file "$filepath" | grep -q "ELF.*executable.*dynamic"; then
|
2014-10-27 21:02:23 +00:00
|
|
|
# skip target firmware files
|
|
|
|
if echo "$filepath" | grep -q "\.elf$"; then
|
|
|
|
continue
|
|
|
|
fi
|
2014-12-17 18:11:30 +00:00
|
|
|
echo "setting interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) in $filepath"
|
|
|
|
patchelf --set-interpreter "$(cat "$NIX_CC"/nix-support/dynamic-linker)" "$filepath"
|
2014-10-27 21:02:23 +00:00
|
|
|
test $? -eq 0 || { echo "patchelf failed to process $filepath"; exit 1; }
|
|
|
|
fi
|
|
|
|
done
|
2015-02-04 21:23:18 +00:00
|
|
|
|
2016-05-08 05:14:39 +01:00
|
|
|
patchelf --set-rpath ${libPath} \
|
|
|
|
"$out/share/arduino/hardware/tools/avr/bin/avrdude_bin"
|
2012-11-28 01:55:24 +00:00
|
|
|
'';
|
|
|
|
|
2015-02-07 09:29:31 +00:00
|
|
|
meta = with stdenv.lib; {
|
2015-02-04 21:23:18 +00:00
|
|
|
description = "Open-source electronics prototyping platform";
|
2012-11-28 01:55:24 +00:00
|
|
|
homepage = http://arduino.cc/;
|
2014-10-10 07:03:02 +01:00
|
|
|
license = stdenv.lib.licenses.gpl2;
|
2015-02-07 09:29:31 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ antono robberer bjornfor ];
|
2012-11-28 01:55:24 +00:00
|
|
|
};
|
|
|
|
}
|