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 xorg.libXxf86vm 70 zlib 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"; 77 78 - pname = (if withTeensyduino then "teensyduino" else "arduino") 79 - + lib.optionalString (!withGui) "-core"; 80 in 81 stdenv.mkDerivation rec { 82 - inherit pname; 83 version = "1.8.16"; 84 85 src = fetchFromGitHub { ··· 195 chmod +w ./TeensyduinoInstall.${teensy_architecture} 196 upx -d ./TeensyduinoInstall.${teensy_architecture} 197 patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 198 - --set-rpath "${teensy_libpath}" \ 199 - ./TeensyduinoInstall.${teensy_architecture} 200 chmod +x ./TeensyduinoInstall.${teensy_architecture} 201 ./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino 202 # Check for successful installation ··· 213 214 preFixup = '' 215 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 218 done 219 220 ${lib.concatMapStringsSep "\n" ··· 235 ${lib.optionalString withTeensyduino '' 236 # Patch the Teensy loader binary 237 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} 241 ''} 242 ''; 243 244 meta = with lib; { 245 description = "Open-source electronics prototyping platform"; 246 - homepage = "http://arduino.cc/"; 247 license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2; 248 platforms = platforms.linux; 249 maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ];
··· 69 xorg.libXxf86vm 70 zlib 71 ]; 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"; 78 79 in 80 stdenv.mkDerivation rec { 81 + pname = (if withTeensyduino then "teensyduino" else "arduino") + lib.optionalString (!withGui) "-core"; 82 version = "1.8.16"; 83 84 src = fetchFromGitHub { ··· 194 chmod +w ./TeensyduinoInstall.${teensy_architecture} 195 upx -d ./TeensyduinoInstall.${teensy_architecture} 196 patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 197 + --set-rpath "${teensy_libpath}" \ 198 + ./TeensyduinoInstall.${teensy_architecture} 199 chmod +x ./TeensyduinoInstall.${teensy_architecture} 200 ./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino 201 # Check for successful installation ··· 212 213 preFixup = '' 214 for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do 215 + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true 216 + patchelf --set-rpath ${rpath}:$out/lib $file || true 217 done 218 219 ${lib.concatMapStringsSep "\n" ··· 234 ${lib.optionalString withTeensyduino '' 235 # Patch the Teensy loader binary 236 patchelf --debug \ 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} 240 ''} 241 ''; 242 243 meta = with lib; { 244 description = "Open-source electronics prototyping platform"; 245 + homepage = "https://www.arduino.cc/"; 246 license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2; 247 platforms = platforms.linux; 248 maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ];
+2 -3
pkgs/development/octave-modules/arduino/default.nix
··· 2 , lib 3 , fetchurl 4 , instrument-control 5 - , arduino 6 }: 7 8 buildOctavePackage rec { ··· 18 instrument-control 19 ]; 20 21 - # Might be able to use pkgs.arduino-core 22 propagatedBuildInputs = [ 23 - arduino 24 ]; 25 26 meta = with lib; {
··· 2 , lib 3 , fetchurl 4 , instrument-control 5 + , arduino-core-unwrapped 6 }: 7 8 buildOctavePackage rec { ··· 18 instrument-control 19 ]; 20 21 propagatedBuildInputs = [ 22 + arduino-core-unwrapped 23 ]; 24 25 meta = with lib; {
+2 -1
pkgs/top-level/all-packages.nix
··· 1273 1274 arduino-cli = callPackage ../development/embedded/arduino/arduino-cli { }; 1275 1276 - arduino-core = callPackage ../development/embedded/arduino/arduino-core { }; 1277 1278 arduino-mk = callPackage ../development/embedded/arduino/arduino-mk {}; 1279
··· 1273 1274 arduino-cli = callPackage ../development/embedded/arduino/arduino-cli { }; 1275 1276 + arduino-core = callPackage ../development/embedded/arduino/arduino-core/chrootenv.nix { }; 1277 + arduino-core-unwrapped = callPackage ../development/embedded/arduino/arduino-core { }; 1278 1279 arduino-mk = callPackage ../development/embedded/arduino/arduino-mk {}; 1280
+1 -1
pkgs/top-level/octave-packages.nix
··· 54 writeRequiredOctavePackagesHook; 55 56 arduino = callPackage ../development/octave-modules/arduino { 57 - inherit (pkgs) arduino; 58 }; 59 60 audio = callPackage ../development/octave-modules/audio { };
··· 54 writeRequiredOctavePackagesHook; 55 56 arduino = callPackage ../development/octave-modules/arduino { 57 + inherit (pkgs) arduino-core-unwrapped; 58 }; 59 60 audio = callPackage ../development/octave-modules/audio { };