git.iko.soy/typeable/nixpkgs
on master help sign in
arduino: use buildFHSUserEnv to support compilation of boards (#144772)
commitad4b1eb16118e789c644f3d38d2ed9c7cd4b0e9f authorFelix Bühler <Stunkymonkey@users.noreply.github.com> dateMon 6 Dec 2021, 17:06 (5 years ago) parente6d91c7
5 files changed+57−22
pkgs/development/embedded/arduino/arduino-core/chrootenv.nix+36 pkgs/development/embedded/arduino/arduino-core/default.nix+16−17 pkgs/development/octave-modules/arduino/default.nix+2−3 pkgs/top-level/all-packages.nix+2−1 pkgs/top-level/octave-packages.nix+1−1
pkgs/development/embedded/arduino/arduino-core/chrootenv.nixnew file+36
@@ -0,0 +1,36 @@
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+}
pkgs/development/embedded/arduino/arduino-core/default.nix+16−17
@@ -69,17 +69,16 @@ let
6969 xorg.libXxf86vm
7070 zlib
7171 ];
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";
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+
8079in
8180stdenv.mkDerivation rec {
82− inherit pname;
81+ pname = (if withTeensyduino then "teensyduino" else "arduino") + lib.optionalString (!withGui) "-core";
8382 version = "1.8.16";
8483
8584 src = fetchFromGitHub {
@@ -195,8 +194,8 @@ stdenv.mkDerivation rec {
195194 chmod +w ./TeensyduinoInstall.${teensy_architecture}
196195 upx -d ./TeensyduinoInstall.${teensy_architecture}
197196 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}
200199 chmod +x ./TeensyduinoInstall.${teensy_architecture}
201200 ./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino
202201 # Check for successful installation
@@ -213,8 +212,8 @@ stdenv.mkDerivation rec {
213212
214213 preFixup = ''
215214 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
218217 done
219218
220219 ${lib.concatMapStringsSep "\n"
@@ -235,15 +234,15 @@ stdenv.mkDerivation rec {
235234 ${lib.optionalString withTeensyduino ''
236235 # Patch the Teensy loader binary
237236 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}
241240 ''}
242241 '';
243242
244243 meta = with lib; {
245244 description = "Open-source electronics prototyping platform";
246− homepage = "http://arduino.cc/";
245+ homepage = "https://www.arduino.cc/";
247246 license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2;
248247 platforms = platforms.linux;
249248 maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ];
pkgs/development/octave-modules/arduino/default.nix+2−3
@@ -2,7 +2,7 @@
22, lib
33, fetchurl
44, instrument-control
5−, arduino
5+, arduino-core-unwrapped
66}:
77
88buildOctavePackage rec {
@@ -18,9 +18,8 @@ buildOctavePackage rec {
1818 instrument-control
1919 ];
2020
21− # Might be able to use pkgs.arduino-core
2221 propagatedBuildInputs = [
23− arduino
22+ arduino-core-unwrapped
2423 ];
2524
2625 meta = with lib; {
pkgs/top-level/all-packages.nix+2−1
@@ -1273,7 +1273,8 @@ with pkgs;
12731273
12741274 arduino-cli = callPackage ../development/embedded/arduino/arduino-cli { };
12751275
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 { };
12771278
12781279 arduino-mk = callPackage ../development/embedded/arduino/arduino-mk {};
12791280
pkgs/top-level/octave-packages.nix+1−1
@@ -54,7 +54,7 @@ makeScope newScope (self:
5454 writeRequiredOctavePackagesHook;
5555
5656 arduino = callPackage ../development/octave-modules/arduino {
57− inherit (pkgs) arduino;
57+ inherit (pkgs) arduino-core-unwrapped;
5858 };
5959
6060 audio = callPackage ../development/octave-modules/audio { };