anchor.diff:            --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
  -
  +      ./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino
         # Check for successful installation
         [ -d $out/share/arduino/hardware/teensy ] || exit 1
  +      # After the install, copy the built jars back
  +      mv $out/share/arduino/lib/arduino-core.jar.bak $out/share/arduino/lib/arduino-core.jar
  +      mv $out/share/arduino/lib/pde.jar.bak $out/share/arduino/lib/pde.jar
       ''}
     '';
   
  
positive.code: 
    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
  
negative.code:     ''}
  
      ${stdenv.lib.optionalString withTeensyduino ''
        # Back up the original jars
        mv $out/share/arduino/lib/arduino-core.jar $out/share/arduino/lib/arduino-core.jar.bak
        mv $out/share/arduino/lib/pde.jar $out/share/arduino/lib/pde.jar.bak
        # Extract jars from the arduino distributable package
        mkdir arduino_dist
        cd arduino_dist
        tar xfJ ${arduino_dist_src} arduino-${version}/lib/arduino-core.jar arduino-${version}/lib/pde.jar
        cd ..
        # Replace the built jars with the official arduino jars
        mv arduino_dist/arduino-${version}/lib/{arduino-core,pde}.jar $out/share/arduino/lib/
        # Delete the directory now that the jars are copied out
        rm -r arduino_dist
        # Extract and patch the Teensyduino installer
        cp ${teensyduino_src} ./TeensyduinoInstall.${teensy_architecture}
        chmod +w ./TeensyduinoInstall.${teensy_architecture}
  