arduino: use buildFHSUserEnv to support compilation of boards (#144772)

authored by Felix Bühler and committed by GitHub ad4b1eb1 e6d91c74

+56 -21
+36
pkgs/development/embedded/arduino/arduino-core/chrootenv.nix
··· 1 + { lib, buildFHSUserEnv, arduino-core-unwrapped, withGui ? false, withTeensyduino ? false }: 2 + let 3 + arduino-unwrapped = arduino-core-unwrapped.override { inherit withGui withTeensyduino; }; 4 + in 5 + buildFHSUserEnv { 6 + name = "arduino"; 7 + 8 + targetPkgs = 9 + pkgs: (with pkgs; [ 10 + ncurses 11 + arduino-unwrapped 12 + zlib 13 + (python3.withPackages (p: with p; [ 14 + pyserial 15 + ])) 16 + ]); 17 + multiPkgs = null; 18 + 19 + extraInstallCommands = '' 20 + ${lib.optionalString withGui '' 21 + # desktop file 22 + mkdir -p $out/share/applications 23 + cp ${arduino-core-unwrapped.src}/build/linux/dist/desktop.template $out/share/applications/arduino.desktop 24 + substituteInPlace $out/share/applications/arduino.desktop \ 25 + --replace '<BINARY_LOCATION>' "$out/bin/arduino" \ 26 + --replace '<ICON_NAME>' "$out/share/arduino/icons/128x128/apps/arduino.png" 27 + # icon file 28 + mkdir -p $out/share/arduino 29 + cp -r ${arduino-core-unwrapped.src}/build/shared/icons $out/share/arduino 30 + ''} 31 + ''; 32 + 33 + runScript = "arduino"; 34 + 35 + meta = arduino-core-unwrapped.meta; 36 + }
+15 -16
pkgs/development/embedded/arduino/arduino-core/default.nix
··· 69 69 xorg.libXxf86vm 70 70 zlib 71 71 ]; 72 - teensy_architecture = if stdenv.hostPlatform.isx86_32 then "linux32" 73 - else if stdenv.hostPlatform.isx86_64 then "linux64" 74 - else if stdenv.hostPlatform.isAarch64 then "linuxaarch64" 75 - else if stdenv.hostPlatform.isAarch32 then "linuxarm" 76 - else throw "${stdenv.hostPlatform.system} is not supported in teensy"; 72 + teensy_architecture = 73 + if stdenv.hostPlatform.isx86_32 then "linux32" 74 + else if stdenv.hostPlatform.isx86_64 then "linux64" 75 + else if stdenv.hostPlatform.isAarch64 then "linuxaarch64" 76 + else if stdenv.hostPlatform.isAarch32 then "linuxarm" 77 + else throw "${stdenv.hostPlatform.system} is not supported in teensy"; 77 78 78 - pname = (if withTeensyduino then "teensyduino" else "arduino") 79 - + lib.optionalString (!withGui) "-core"; 80 79 in 81 80 stdenv.mkDerivation rec { 82 - inherit pname; 81 + pname = (if withTeensyduino then "teensyduino" else "arduino") + lib.optionalString (!withGui) "-core"; 83 82 version = "1.8.16"; 84 83 85 84 src = fetchFromGitHub { ··· 195 194 chmod +w ./TeensyduinoInstall.${teensy_architecture} 196 195 upx -d ./TeensyduinoInstall.${teensy_architecture} 197 196 patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 198 - --set-rpath "${teensy_libpath}" \ 199 - ./TeensyduinoInstall.${teensy_architecture} 197 + --set-rpath "${teensy_libpath}" \ 198 + ./TeensyduinoInstall.${teensy_architecture} 200 199 chmod +x ./TeensyduinoInstall.${teensy_architecture} 201 200 ./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino 202 201 # Check for successful installation ··· 213 212 214 213 preFixup = '' 215 214 for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do 216 - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true 217 - patchelf --set-rpath ${rpath}:$out/lib $file || true 215 + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true 216 + patchelf --set-rpath ${rpath}:$out/lib $file || true 218 217 done 219 218 220 219 ${lib.concatMapStringsSep "\n" ··· 235 234 ${lib.optionalString withTeensyduino '' 236 235 # Patch the Teensy loader binary 237 236 patchelf --debug \ 238 - --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 239 - --set-rpath "${teensy_libpath}" \ 240 - $out/share/arduino/hardware/tools/teensy{,_ports,_reboot,_restart,_serialmon} 237 + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 238 + --set-rpath "${teensy_libpath}" \ 239 + $out/share/arduino/hardware/tools/teensy{,_ports,_reboot,_restart,_serialmon} 241 240 ''} 242 241 ''; 243 242 244 243 meta = with lib; { 245 244 description = "Open-source electronics prototyping platform"; 246 - homepage = "http://arduino.cc/"; 245 + homepage = "https://www.arduino.cc/"; 247 246 license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2; 248 247 platforms = platforms.linux; 249 248 maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ];
+2 -3
pkgs/development/octave-modules/arduino/default.nix
··· 2 2 , lib 3 3 , fetchurl 4 4 , instrument-control 5 - , arduino 5 + , arduino-core-unwrapped 6 6 }: 7 7 8 8 buildOctavePackage rec { ··· 18 18 instrument-control 19 19 ]; 20 20 21 - # Might be able to use pkgs.arduino-core 22 21 propagatedBuildInputs = [ 23 - arduino 22 + arduino-core-unwrapped 24 23 ]; 25 24 26 25 meta = with lib; {
+2 -1
pkgs/top-level/all-packages.nix
··· 1273 1273 1274 1274 arduino-cli = callPackage ../development/embedded/arduino/arduino-cli { }; 1275 1275 1276 - arduino-core = callPackage ../development/embedded/arduino/arduino-core { }; 1276 + arduino-core = callPackage ../development/embedded/arduino/arduino-core/chrootenv.nix { }; 1277 + arduino-core-unwrapped = callPackage ../development/embedded/arduino/arduino-core { }; 1277 1278 1278 1279 arduino-mk = callPackage ../development/embedded/arduino/arduino-mk {}; 1279 1280
+1 -1
pkgs/top-level/octave-packages.nix
··· 54 54 writeRequiredOctavePackagesHook; 55 55 56 56 arduino = callPackage ../development/octave-modules/arduino { 57 - inherit (pkgs) arduino; 57 + inherit (pkgs) arduino-core-unwrapped; 58 58 }; 59 59 60 60 audio = callPackage ../development/octave-modules/audio { };