diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:36 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:47 +0000 |
commit | 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch) | |
tree | b3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/arduino | |
parent | 4e31070265257dc67d120c27e0f75c2344fdfa9a (diff) | |
parent | abf060725d7614bd3b9f96764262dfbc2f9c2199 (diff) | |
download | nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2 nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip |
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/arduino')
7 files changed, 585 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/arduino/arduino-core/default.nix b/nixpkgs/pkgs/development/arduino/arduino-core/default.nix new file mode 100644 index 000000000000..269df6a07cd0 --- /dev/null +++ b/nixpkgs/pkgs/development/arduino/arduino-core/default.nix @@ -0,0 +1,223 @@ +{ stdenv, lib, fetchFromGitHub, fetchurl, jdk, ant +, libusb, libusb1, unzip, zlib, ncurses, readline +, withGui ? false, gtk2 ? null, withTeensyduino ? false + /* Packages needed for Teensyduino */ +, upx, fontconfig, xorg, gcc, xdotool, xvfb_run +, atk, glib, pango, gdk_pixbuf, libpng12, expat, freetype +}: + +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; + inherit (lib) optionalAttrs; + inherit (stdenv.hostPlatform) system; + }; + # 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-arduino1.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-arduino1.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 + expat + fontconfig + freetype + gcc.cc.lib + gdk_pixbuf + glib + gtk2 + libpng12 + libusb + pango + xorg.libSM + xorg.libX11 + xorg.libXext + xorg.libXft + xorg.libXinerama + 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"; + + flavor = (if withTeensyduino then "teensyduino" else "arduino") + + stdenv.lib.optionalString (!withGui) "-core"; +in +stdenv.mkDerivation rec { + version = "1.8.5"; + name = "${flavor}-${version}"; + + src = fetchFromGitHub { + owner = "arduino"; + repo = "Arduino"; + rev = "${version}"; + sha256 = "0ww72qfk7fyvprz15lc80i1axfdacb5fij4h5j5pakrg76mng2c3"; + }; + + teensyduino_src = fetchurl { + url = "https://www.pjrc.com/teensy/td_140/TeensyduinoInstall.${teensy_architecture}"; + sha256 = + lib.optionalString ("${teensy_architecture}" == "linux64") + "0127a1ak31252dbmr5niqa5mkvbm8dnz1cfcnmydzx9qn9rk00ir" + + lib.optionalString ("${teensy_architecture}" == "linux32") + "01mxj5xsr7gka652c9rp4szy5mkcka8mljk044v4agk3sxvx3v3i" + + lib.optionalString ("${teensy_architecture}" == "linuxarm") + "1dff3alhvk9x8qzy3n85qrg6rfmy6l9pj6fmrlzpli63lzykvv4i"; + }; + + buildInputs = [ jdk ant libusb libusb1 unzip zlib ncurses5 readline + ] ++ stdenv.lib.optionals withTeensyduino [ upx xvfb_run xdotool ]; + downloadSrcList = builtins.attrValues externalDownloads; + downloadDstList = builtins.attrNames externalDownloads; + + buildPhase = '' + # Copy pre-downloaded files to proper locations + download_src=($downloadSrcList) + download_dst=($downloadDstList) + while [[ "''${#download_src[@]}" -ne 0 ]]; do + file_src=''${download_src[0]} + file_dst=''${download_dst[0]} + mkdir -p $(dirname $file_dst) + download_src=(''${download_src[@]:1}) + download_dst=(''${download_dst[@]:1}) + cp -v $file_src $file_dst + done + + # 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" + + cd ./arduino-core && ant + cd ../build && ant + cd .. + ''; + + # 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]; + + # Everything else will be patched into rpath + rpath = (lib.makeLibraryPath [zlib libusb libusb1 readline ncurses5 stdenv.cc.cc]); + + installPhase = '' + mkdir -p $out/share/arduino + cp -r ./build/linux/work/* "$out/share/arduino/" #*/ + echo ${version} > $out/share/arduino/lib/version.txt + + ${stdenv.lib.optionalString withGui '' + mkdir -p $out/bin + substituteInPlace $out/share/arduino/arduino \ + --replace "JAVA=java" "JAVA=$javaPath/java" \ + --replace "LD_LIBRARY_PATH=" "LD_LIBRARY_PATH=$dynamicLibraryPath:" + ln -sr "$out/share/arduino/arduino" "$out/bin/arduino" + + cp -r build/shared/icons $out/share/arduino + mkdir -p $out/share/applications + cp build/linux/dist/desktop.template $out/share/applications/arduino.desktop + substituteInPlace $out/share/applications/arduino.desktop \ + --replace '<BINARY_LOCATION>' "$out/bin/arduino" \ + --replace '<ICON_NAME>' "$out/share/arduino/icons/128x128/apps/arduino.png" + ''} + + ${stdenv.lib.optionalString withTeensyduino '' + # Extract and patch the Teensyduino installer + cp ${teensyduino_src} ./TeensyduinoInstall.${teensy_architecture} + chmod +w ./TeensyduinoInstall.${teensy_architecture} + upx -d ./TeensyduinoInstall.${teensy_architecture} + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + --set-rpath "${teensy_libpath}" \ + ./TeensyduinoInstall.${teensy_architecture} + chmod +x ./TeensyduinoInstall.${teensy_architecture} + + # Run the GUI-only installer in a virtual X server + # Script thanks to AUR package. See: + # <https://aur.archlinux.org/packages/teensyduino/> + echo "Running Teensyduino installer..." + # Trick the GUI into using HOME as the install directory. + export HOME=$out/share/arduino + # Run the installer in a virtual X server in memory. + xvfb-run -n 99 ./TeensyduinoInstall.${teensy_architecture} & + sleep 4 + echo "Waiting for Teensyduino to install (about 1 minute)..." + # Control the installer GUI with xdotool. + DISPLAY=:99 xdotool search --class "teensyduino" \ + windowfocus \ + key space sleep 1 \ + key Tab sleep 0.4 \ + key Tab sleep 0.4 \ + key Tab sleep 0.4 \ + key Tab sleep 0.4 \ + key space sleep 1 \ + key Tab sleep 0.4 \ + key Tab sleep 0.4 \ + key Tab sleep 0.4 \ + key Tab sleep 0.4 \ + key space sleep 1 \ + key Tab sleep 0.4 \ + key space sleep 35 \ + key space sleep 2 & + # Wait for xdotool to terminate and swallow the inevitable XIO error + wait $! || true + + # Check for successful installation + [ -d $out/share/arduino/hardware/teensy ] || exit 1 + ''} + ''; + + # So we don't accidentally mess with firmware files + dontStrip = true; + dontPatchELF = true; + + preFixup = '' + for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true + patchelf --set-rpath ${rpath}:$out/lib $file || true + done + + ${lib.concatMapStringsSep "\n" + ({jar, file}: + '' + jar xvf $out/${jar} ${file} + patchelf --set-rpath $rpath ${file} + jar uvf $out/${jar} ${file} + rm -f ${file} + '' + ) + patchelfInJars} + + # avrdude_bin is linked against libtinfo.so.5 + mkdir $out/lib/ + ln -s ${lib.makeLibraryPath [ncurses5]}/libncursesw.so.5 $out/lib/libtinfo.so.5 + + ${stdenv.lib.optionalString withTeensyduino '' + # Patch the Teensy loader binary + patchelf --debug \ + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + --set-rpath "${teensy_libpath}" \ + $out/share/arduino/hardware/tools/teensy + ''} + ''; + + meta = with stdenv.lib; { + description = "Open-source electronics prototyping platform"; + homepage = http://arduino.cc/; + license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2; + platforms = platforms.linux; + maintainers = with maintainers; [ antono auntie robberer bjornfor ]; + }; +} diff --git a/nixpkgs/pkgs/development/arduino/arduino-core/downloads.nix b/nixpkgs/pkgs/development/arduino/arduino-core/downloads.nix new file mode 100644 index 000000000000..e71c898dd555 --- /dev/null +++ b/nixpkgs/pkgs/development/arduino/arduino-core/downloads.nix @@ -0,0 +1,159 @@ +{fetchurl, optionalAttrs, system}: +# This file preloads all the archives which Arduino's build/build.xml +# would otherwise try to download itself. When updating this for a new +# version of Arduino, check build.xml for version numbers and new +# urls. +{ + "build/shared/reference-1.6.6-3.zip" = fetchurl { + url = "https://downloads.arduino.cc/reference-1.6.6-3.zip"; + sha256 = "119nj1idz85l71fy6a6wwsx0mcd8y0ib1wy0l6j9kz88nkwvggy3"; + }; + "build/shared/Galileo_help_files-1.6.2.zip" = fetchurl { + url = "https://downloads.arduino.cc/Galileo_help_files-1.6.2.zip"; + sha256 = "0qda0xml353sfhjmx9my4mlcyzbf531k40dcr1cnsa438xp2fw0w"; + }; + "build/shared/Edison_help_files-1.6.2.zip" = fetchurl { + url = "https://downloads.arduino.cc/Edison_help_files-1.6.2.zip"; + sha256 = "1x25rivmh0zpa6lr8dafyxvim34wl3wnz3r9msfxg45hnbjqqwan"; + }; + "build/Firmata-2.5.6.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Firmata/archive/2.5.6.zip"; + sha256 = "117dd4pdlgv60gdlgm2ckjfq89i0dg1q8vszg6hxywdf701c1fk4"; + }; + "build/Bridge-1.6.3.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Bridge/archive/1.6.3.zip"; + sha256 = "1lha5wkzz63bgcn7bhx4rmgsh9ywa47lffycpyz6qjnl1pvm5mmj"; + }; + "build/Robot_Control-1.0.4.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Robot_Control/archive/1.0.4.zip"; + sha256 = "1pkabrghx3h8l60x571vwkbhfm02nhyn5x2vqz4vhx9cczr70zq7"; + }; + "build/Robot_Motor-1.0.3.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Robot_Motor/archive/1.0.3.zip"; + sha256 = "1pkvrimg77jrhdsz4l81y59hv50h6cl7hvhk9w8ac7ckg70lvxkw"; + }; + "build/RobotIRremote-2.0.0.zip" = fetchurl { + url = "https://github.com/arduino-libraries/RobotIRremote/archive/2.0.0.zip"; + sha256 = "0j5smap74j8p3wc6k0h73b1skj4gkr7r25jbjh1j1cg052dxri86"; + }; + "build/SpacebrewYun-1.0.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/SpacebrewYun/archive/1.0.1.zip"; + sha256 = "1zs6ymlzw66bglrm0x6d3cvr52q85c8rlm525x0wags111xx3s90"; + }; + "build/Temboo-1.2.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Temboo/archive/1.2.1.zip"; + sha256 = "1fyzfihsbcjpjasqbmbbfcall2zl48nzrp4xk9pslppal31mvl8x"; + }; + "build/Esplora-1.0.4.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Esplora/archive/1.0.4.zip"; + sha256 = "1dflfrg38f0312nxn6wkkgq1ql4hx3y9kplalix6mkqmzwrdvna4"; + }; + "build/Mouse-1.0.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Mouse/archive/1.0.1.zip"; + sha256 = "106jjqxzpf5lrs9akwvamqsblj5w2fb7vd0wafm9ihsikingiypr"; + }; + "build/Keyboard-1.0.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Keyboard/archive/1.0.1.zip"; + sha256 = "1spv73zhjbrb0vgpzjnh6wr3bddlbyzv78d21dbn8z2l0aqv2sac"; + }; + "build/SD-1.1.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/SD/archive/1.1.1.zip"; + sha256 = "0nackcf7yx5np1s24wnsrcjl8j0nlmqqir6316vqqkfayvb1247n"; + }; + "build/Servo-1.1.2.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Servo/archive/1.1.2.zip"; + sha256 = "14k1883qrx425wnm0r8kszzq32yvvs3jwxf3g7ybp7v0ga0q47l7"; + }; + "build/LiquidCrystal-1.0.7.zip" = fetchurl { + url = "https://github.com/arduino-libraries/LiquidCrystal/archive/1.0.7.zip"; + sha256 = "1wrxrqz3n4yrj9j1a2b7pdd7a1rlyi974ra7crv5amjng8817x9n"; + }; + "build/Adafruit_CircuitPlayground-1.6.8.zip" = fetchurl { + url = "https://github.com/Adafruit/Adafruit_CircuitPlayground/archive/1.6.8.zip"; + sha256 = "0zm667xiaygx8v1ygcls43s6qd5n7pf21n0998n1z7nf18s35j41"; + }; + "build/libastylej-2.05.1-3.zip" = fetchurl { + url = "https://downloads.arduino.cc/libastylej-2.05.1-3.zip"; + sha256 = "0a1xy2cdl0xls5r21vy5d2j1dapn1jsdw0vbimlwnzfx7r84mxa6"; + }; + "build/liblistSerials-1.4.0.zip" = fetchurl { + url = "https://downloads.arduino.cc/liblistSerials/liblistSerials-1.4.0.zip"; + sha256 = "129mfbyx7snq3znzhkfbdjiifdr85cwk6wjn8l9ia0wynszs5zyv"; + }; + "build/shared/WiFi101-Updater-ArduinoIDE-Plugin-0.9.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/WiFi101-FirmwareUpdater-Plugin/releases/download/v0.9.1/WiFi101-Updater-ArduinoIDE-Plugin-0.9.1.zip"; + sha256 = "15przp8z1dp6lamcvqdx4daq6fqi3c1algc3sbinyh25pm69pq74"; + }; +} +// optionalAttrs (system == "x86_64-linux") { + "build/arduino-builder-linux64-1.3.25.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-linux64-1.3.25.tar.bz2"; + sha256 = "15y80p255w2rg028vc8dq4hpqsmf770qigv3hgf78npb4qrjnqqf"; + }; + "build/linux/avr-gcc-4.9.2-atmel3.5.4-arduino2-x86_64-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-x86_64-pc-linux-gnu.tar.bz2"; + sha256 = "132qm8l6h50z4s9h0i5mfv6bp0iia0pp9kc3gd37hkajy4bh4j0r"; + }; + "build/linux/avrdude-6.3.0-arduino9-x86_64-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-x86_64-pc-linux-gnu.tar.bz2"; + sha256 = "0shz5ymnlsrbnaqcb13fwbd73hz9k45adw14gf1ywjgywa2cpk68"; + }; + "build/linux/arduinoOTA-1.1.1-linux_amd64.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.1.1-linux_amd64.tar.bz2"; + sha256 = "0xy25srvpz6d0yfnz8b17mkmary3k51lb1cvgw7n2zyxayjd0npb"; + }; +} +// optionalAttrs (system == "i686-linux") { + "build/arduino-builder-linux32-1.3.25.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-linux32-1.3.25.tar.bz2"; + sha256 = "0hjiqbf7xspdcr7lganqnl68qcmndc9pz06dghkrwzbzc5ki72qr"; + }; + "build/linux/avr-gcc-4.9.2-atmel3.5.4-arduino2-i686-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-i686-pc-linux-gnu.tar.bz2"; + sha256 = "1d81z5m4cklv29hgb5ywrmyq64ymlwmjx2plm1gzs1mcpg7d9ab3"; + }; + "build/linux/avrdude-6.3.0-arduino9-i686-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-i686-pc-linux-gnu.tar.bz2"; + sha256 = "12r1drjafxwzrvf1y1glxd46rv870mhz1ifn0g328ciwivas4da2"; + }; + "build/linux/arduinoOTA-1.1.1-linux_386.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.1.1-linux_386.tar.bz2"; + sha256 = "1vvilbbbvv68svxzyhjspacbavcqakph5glhnz7c0mxkspqixjbs"; + }; +} +// optionalAttrs (system == "x86_64-darwin") { + "build/arduino-builder-macosx-1.3.25.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-macosx-1.3.25.tar.bz2"; + sha256 = "0inkxjzdplb8b17j7lyam6v9gca25rxmsinrkgqnx3xxgkaxz2k0"; + }; + "build/macosx/avr-gcc-4.9.2-atmel3.5.4-arduino2-i386-apple-darwin11.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-i386-apple-darwin11.tar.bz2"; + sha256 = "0c27i3y4f5biinxjdpp43wbj00lz7dvl08pnqr7hpkzaalsyvcv7"; + }; + "build/macosx/avrdude-6.3.0-arduino9-i386-apple-darwin11.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-i386-apple-darwin11.tar.bz2"; + sha256 = "0rc4x8mcsva4v6j7ssfj8rdyg14l2pd9ivgdm39m5wnz8b06p85z11703f0r82aq3mmkiy7vwa4jfjhs9826qpp724hbng9dx74kk86r"; + }; + "build/macosx/appbundler/appbundler-1.0ea-arduino4.jar.zip" = fetchurl { + url = "https://downloads.arduino.cc/appbundler-1.0ea-arduino4.jar.zip"; + sha256 = "1vz0g98ancfqdf7yx5m3zrxmzb3fwp18zh5lkh2nyl5xlr9m368z"; + }; +} +// optionalAttrs (system == "armv6l-linux") { + "build/arduino-builder-linuxarm-1.3.25.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-linuxarm-1.3.25.tar.bz2"; + sha256 = "1jvlihpcbdv1sgq1wjdwp7dhznk7nd88zin6yj40kr80gcd2ykry"; + }; + "build/linux/avr-gcc-4.9.2-atmel3.5.4-arduino2-armhf-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-armhf-pc-linux-gnu.tar.bz2"; + sha256 = "033jb1vmspcxsv0w9pk73xv195xnbnmckjsiccgqs8xx36g00dpf"; + }; + "build/linux/avrdude-6.3.0-arduino9-armhf-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-armhf-pc-linux-gnu.tar.bz2"; + sha256 = "1kp1xry97385zbrs94j285h1gqlzyyhkchh26z7zq6c0wi5879i5"; + }; + "build/linux/arduinoOTA-1.1.1-linux_arm.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.1.1-linux_arm.tar.bz2"; + sha256 = "0k1pib8lmvk6c0y3m038fj3mc18ax1hy3kbvgd5nygrxvy1hv274"; + }; +} diff --git a/nixpkgs/pkgs/development/arduino/ino/default.nix b/nixpkgs/pkgs/development/arduino/ino/default.nix new file mode 100644 index 000000000000..83b72488bfd4 --- /dev/null +++ b/nixpkgs/pkgs/development/arduino/ino/default.nix @@ -0,0 +1,46 @@ +{ stdenv, fetchurl, python2Packages, picocom +, avrdude, arduino-core }: + +python2Packages.buildPythonApplication rec { + name = "ino-0.3.6"; + namePrefix = ""; + + src = fetchurl { + url = "mirror://pypi/i/ino/${name}.tar.gz"; + sha256 = "0k6lzfcn55favbj0w4afrvnmwyskf7bgzg9javv2ycvskp35srwv"; + }; + + # TODO: add avrgcclibc, it must be rebuild with C++ support + propagatedBuildInputs = with python2Packages; [ + arduino-core + avrdude + picocom + configobj + jinja2 + pyserial + six + ]; + + patchPhase = '' + echo "Patching Arduino distribution path" + sed -i 's@/usr/local/share/arduino@${arduino-core}/share/arduino@g' \ + ino/environment.py + sed -i -e 's@argparse@@' -e 's@ordereddict@@' \ + requirements.txt + sed -i -e 's@from ordereddict@from collections@' \ + ino/environment.py ino/utils.py + + # Patch the upload command so it uses the correct avrdude + substituteInPlace ino/commands/upload.py \ + --replace "self.e['avrdude']" "'${avrdude}/bin/avrdude'" \ + --replace "'-C', self.e['avrdude.conf']," "" + ''; + + meta = { + description = "Command line toolkit for working with Arduino hardware"; + homepage = http://inotool.org/; + license = stdenv.lib.licenses.mit; + maintainers = with stdenv.lib.maintainers; [ antono the-kenny ]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/arduino/platformio/chrootenv.nix b/nixpkgs/pkgs/development/arduino/platformio/chrootenv.nix new file mode 100644 index 000000000000..8f93a0b37721 --- /dev/null +++ b/nixpkgs/pkgs/development/arduino/platformio/chrootenv.nix @@ -0,0 +1,52 @@ +{ lib, buildFHSUserEnv }: + +let + pio-pkgs = pkgs: + let + python = pkgs.python.override { + packageOverrides = self: super: { + + # https://github.com/platformio/platformio-core/issues/349 + click = super.click.overridePythonAttrs (oldAttrs: rec { + version = "5.1"; + src = oldAttrs.src.override { + inherit version; + sha256 = "678c98275431fad324275dec63791e4a17558b40e5a110e20a82866139a85a5a"; + }; + patches = []; + }); + + platformio = self.callPackage ./core.nix { }; + }; + }; + in (with pkgs; [ + zlib + git + ]) ++ (with python.pkgs; [ + python + setuptools + pip + bottle + platformio + ]); + +in buildFHSUserEnv { + name = "platformio"; + + targetPkgs = pio-pkgs; + multiPkgs = pio-pkgs; + + meta = with lib; { + description = "An open source ecosystem for IoT development"; + homepage = http://platformio.org; + maintainers = with maintainers; [ mog ]; + license = licenses.asl20; + platforms = with platforms; linux; + }; + + extraInstallCommands = '' + ln -s $out/bin/platformio $out/bin/pio + ''; + + runScript = "platformio"; +} diff --git a/nixpkgs/pkgs/development/arduino/platformio/core.nix b/nixpkgs/pkgs/development/arduino/platformio/core.nix new file mode 100644 index 000000000000..bf0dd5229c68 --- /dev/null +++ b/nixpkgs/pkgs/development/arduino/platformio/core.nix @@ -0,0 +1,83 @@ +{ stdenv, lib, buildPythonApplication, fetchFromGitHub +, bottle, click, colorama +, lockfile, pyserial, requests +, pytest, semantic-version, tox +, git +}: + +let + args = lib.concatStringsSep " " ((map (e: "--deselect tests/${e}") [ + "commands/test_ci.py::test_ci_boards" + "commands/test_ci.py::test_ci_project_conf" + "commands/test_ci.py::test_ci_lib_and_board" + "commands/test_init.py::test_init_enable_auto_uploading" + "commands/test_init.py::test_init_custom_framework" + "commands/test_init.py::test_init_incorrect_board" + "commands/test_init.py::test_init_ide_atom" + "commands/test_init.py::test_init_ide_eclipse" + "commands/test_init.py::test_init_duplicated_boards" + "commands/test_init.py::test_init_special_board" + "commands/test_lib.py::test_search" + "commands/test_lib.py::test_install_duplicates" + "commands/test_lib.py::test_global_lib_update_check" + "commands/test_lib.py::test_global_lib_update" + "commands/test_lib.py::test_global_lib_uninstall" + "commands/test_lib.py::test_lib_show" + "commands/test_lib.py::test_lib_stats" + "commands/test_lib.py::test_global_install_registry" + "commands/test_lib.py::test_global_install_archive" + "commands/test_lib.py::test_global_install_repository" + "commands/test_lib.py::test_global_lib_list" + "commands/test_test.py::test_local_env" + "test_builder.py::test_build_flags" + "test_builder.py::test_build_unflags" + "test_misc.py::test_api_cache" + "test_misc.py::test_ping_internet_ips" + "test_pkgmanifest.py::test_packages" + ]) ++ (map (e: "--ignore=tests/${e}") [ + "commands/test_boards.py" + "commands/test_platform.py" + "commands/test_update.py" + "test_maintenance.py" + "test_ino2cpp.py" + ])); + +in buildPythonApplication rec { + pname = "platformio"; + version = "3.6.2"; + + # pypi tarballs don't contain tests - https://github.com/platformio/platformio-core/issues/1964 + src = fetchFromGitHub { + owner = "platformio"; + repo = "platformio-core"; + rev = "v${version}"; + sha256 = "1558adr73d7mgp0z92q9vzbgarddimadyk4467z8i3yp4g8k5irk"; + }; + + propagatedBuildInputs = [ + bottle click colorama git lockfile + pyserial requests semantic-version + ]; + + HOME = "/tmp"; + + checkInputs = [ pytest tox ]; + + checkPhase = '' + runHook preCheck + + py.test -v tests ${args} + + runHook postCheck + ''; + + patches = [ ./fix-searchpath.patch ]; + + meta = with stdenv.lib; { + broken = stdenv.isAarch64; + description = "An open source ecosystem for IoT development"; + homepage = http://platformio.org; + license = licenses.asl20; + maintainers = with maintainers; [ mog makefu ]; + }; +} diff --git a/nixpkgs/pkgs/development/arduino/platformio/default.nix b/nixpkgs/pkgs/development/arduino/platformio/default.nix new file mode 100644 index 000000000000..45186914604d --- /dev/null +++ b/nixpkgs/pkgs/development/arduino/platformio/default.nix @@ -0,0 +1,11 @@ + +{ newScope }: + +let + callPackage = newScope self; + + self = rec { + platformio-chrootenv = callPackage ./chrootenv.nix { }; + }; + +in self diff --git a/nixpkgs/pkgs/development/arduino/platformio/fix-searchpath.patch b/nixpkgs/pkgs/development/arduino/platformio/fix-searchpath.patch new file mode 100644 index 000000000000..a215ffc7d614 --- /dev/null +++ b/nixpkgs/pkgs/development/arduino/platformio/fix-searchpath.patch @@ -0,0 +1,11 @@ +--- ./platformio/util.py-old 2017-09-29 01:20:08.174548250 +0200 ++++ ./platformio/util.py 2017-09-29 01:19:48.410485308 +0200 +@@ -395,7 +395,7 @@ + isdir(join(p, "click")) or isdir(join(p, "platformio"))) + if all(conditions): + _PYTHONPATH.append(p) +- os.environ['PYTHONPATH'] = os.pathsep.join(_PYTHONPATH) ++ os.environ['PYTHONPATH'] = os.pathsep.join(sys.path) + + + def get_serialports(filter_hwid=False): |