summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Buehler <account@buehler.rocks>2021-11-05 18:53:43 +0100
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2021-12-06 16:10:42 +0000
commit80708687e222944f87b1886227332e9beeabfc4f (patch)
tree5e3773411ad4865f08155d2db1a5e798e8a24ba4
parentMerge pull request #148447 from NixOS/backport-148302-to-release-21.11 (diff)
downloadnixpkgs-80708687e222944f87b1886227332e9beeabfc4f.tar.gz
arduino: use buildFHSUserEnv to support compilation of boards
(cherry picked from commit 5e4c4fe76ed641b2e2312f0c7318816b2cc3a6c7)
-rw-r--r--pkgs/development/embedded/arduino/arduino-core/chrootenv.nix36
-rw-r--r--pkgs/development/embedded/arduino/arduino-core/default.nix31
-rw-r--r--pkgs/development/octave-modules/arduino/default.nix5
-rw-r--r--pkgs/top-level/all-packages.nix3
-rw-r--r--pkgs/top-level/octave-packages.nix2
5 files changed, 56 insertions, 21 deletions
diff --git a/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix b/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix
new file mode 100644
index 000000000000..4c13b2493a9a
--- /dev/null
+++ b/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix
@@ -0,0 +1,36 @@
+{ lib, buildFHSUserEnv, arduino-core-unwrapped, withGui ? false, withTeensyduino ? false }:
+let
+ arduino-unwrapped = arduino-core-unwrapped.override { inherit withGui withTeensyduino; };
+in
+buildFHSUserEnv {
+ name = "arduino";
+
+ targetPkgs =
+ pkgs: (with pkgs; [
+ ncurses
+ arduino-unwrapped
+ zlib
+ (python3.withPackages (p: with p; [
+ pyserial
+ ]))
+ ]);
+ multiPkgs = null;
+
+ extraInstallCommands = ''
+ ${lib.optionalString withGui ''
+ # desktop file
+ mkdir -p $out/share/applications
+ cp ${arduino-core-unwrapped.src}/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"
+ # icon file
+ mkdir -p $out/share/arduino
+ cp -r ${arduino-core-unwrapped.src}/build/shared/icons $out/share/arduino
+ ''}
+ '';
+
+ runScript = "arduino";
+
+ meta = arduino-core-unwrapped.meta;
+}
diff --git a/pkgs/development/embedded/arduino/arduino-core/default.nix b/pkgs/development/embedded/arduino/arduino-core/default.nix
index 25d0301d032b..6b2c6203a392 100644
--- a/pkgs/development/embedded/arduino/arduino-core/default.nix
+++ b/pkgs/development/embedded/arduino/arduino-core/default.nix
@@ -69,17 +69,16 @@ let
xorg.libXxf86vm
zlib
];
- teensy_architecture = if stdenv.hostPlatform.isx86_32 then "linux32"
- else if stdenv.hostPlatform.isx86_64 then "linux64"
- else if stdenv.hostPlatform.isAarch64 then "linuxaarch64"
- else if stdenv.hostPlatform.isAarch32 then "linuxarm"
- else throw "${stdenv.hostPlatform.system} is not supported in teensy";
+ teensy_architecture =
+ if stdenv.hostPlatform.isx86_32 then "linux32"
+ else if stdenv.hostPlatform.isx86_64 then "linux64"
+ else if stdenv.hostPlatform.isAarch64 then "linuxaarch64"
+ else if stdenv.hostPlatform.isAarch32 then "linuxarm"
+ else throw "${stdenv.hostPlatform.system} is not supported in teensy";
- pname = (if withTeensyduino then "teensyduino" else "arduino")
- + lib.optionalString (!withGui) "-core";
in
stdenv.mkDerivation rec {
- inherit pname;
+ pname = (if withTeensyduino then "teensyduino" else "arduino") + lib.optionalString (!withGui) "-core";
version = "1.8.16";
src = fetchFromGitHub {
@@ -195,8 +194,8 @@ stdenv.mkDerivation rec {
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}
+ --set-rpath "${teensy_libpath}" \
+ ./TeensyduinoInstall.${teensy_architecture}
chmod +x ./TeensyduinoInstall.${teensy_architecture}
./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino
# Check for successful installation
@@ -213,8 +212,8 @@ stdenv.mkDerivation rec {
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
+ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
+ patchelf --set-rpath ${rpath}:$out/lib $file || true
done
${lib.concatMapStringsSep "\n"
@@ -235,15 +234,15 @@ stdenv.mkDerivation rec {
${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{,_ports,_reboot,_restart,_serialmon}
+ --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+ --set-rpath "${teensy_libpath}" \
+ $out/share/arduino/hardware/tools/teensy{,_ports,_reboot,_restart,_serialmon}
''}
'';
meta = with lib; {
description = "Open-source electronics prototyping platform";
- homepage = "http://arduino.cc/";
+ homepage = "https://www.arduino.cc/";
license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2;
platforms = platforms.linux;
maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ];
diff --git a/pkgs/development/octave-modules/arduino/default.nix b/pkgs/development/octave-modules/arduino/default.nix
index 77089827c4b7..fd97c55a40e9 100644
--- a/pkgs/development/octave-modules/arduino/default.nix
+++ b/pkgs/development/octave-modules/arduino/default.nix
@@ -2,7 +2,7 @@
, lib
, fetchurl
, instrument-control
-, arduino
+, arduino-core-unwrapped
}:
buildOctavePackage rec {
@@ -18,9 +18,8 @@ buildOctavePackage rec {
instrument-control
];
- # Might be able to use pkgs.arduino-core
propagatedBuildInputs = [
- arduino
+ arduino-core-unwrapped
];
meta = with lib; {
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 35af93f36fc9..4279fb4d8474 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1265,7 +1265,8 @@ with pkgs;
arduino-cli = callPackage ../development/embedded/arduino/arduino-cli { };
- arduino-core = callPackage ../development/embedded/arduino/arduino-core { };
+ arduino-core = callPackage ../development/embedded/arduino/arduino-core/chrootenv.nix { };
+ arduino-core-unwrapped = callPackage ../development/embedded/arduino/arduino-core { };
arduino-mk = callPackage ../development/embedded/arduino/arduino-mk {};
diff --git a/pkgs/top-level/octave-packages.nix b/pkgs/top-level/octave-packages.nix
index b4aeb905280d..3895d7871f91 100644
--- a/pkgs/top-level/octave-packages.nix
+++ b/pkgs/top-level/octave-packages.nix
@@ -54,7 +54,7 @@ makeScope newScope (self:
writeRequiredOctavePackagesHook;
arduino = callPackage ../development/octave-modules/arduino {
- inherit (pkgs) arduino;
+ inherit (pkgs) arduino-core-unwrapped;
};
audio = callPackage ../development/octave-modules/audio { };