arduino: use buildFHSUserEnv to support compilation of boards (#144772)
This commit is contained in:
parent
e6d91c74b0
commit
ad4b1eb161
5 changed files with 56 additions and 21 deletions
36
pkgs/development/embedded/arduino/arduino-core/chrootenv.nix
Normal file
36
pkgs/development/embedded/arduino/arduino-core/chrootenv.nix
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -69,17 +69,16 @@ let
|
||||||
xorg.libXxf86vm
|
xorg.libXxf86vm
|
||||||
zlib
|
zlib
|
||||||
];
|
];
|
||||||
teensy_architecture = if stdenv.hostPlatform.isx86_32 then "linux32"
|
teensy_architecture =
|
||||||
else if stdenv.hostPlatform.isx86_64 then "linux64"
|
if stdenv.hostPlatform.isx86_32 then "linux32"
|
||||||
else if stdenv.hostPlatform.isAarch64 then "linuxaarch64"
|
else if stdenv.hostPlatform.isx86_64 then "linux64"
|
||||||
else if stdenv.hostPlatform.isAarch32 then "linuxarm"
|
else if stdenv.hostPlatform.isAarch64 then "linuxaarch64"
|
||||||
else throw "${stdenv.hostPlatform.system} is not supported in teensy";
|
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
|
in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
inherit pname;
|
pname = (if withTeensyduino then "teensyduino" else "arduino") + lib.optionalString (!withGui) "-core";
|
||||||
version = "1.8.16";
|
version = "1.8.16";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
|
@ -195,8 +194,8 @@ stdenv.mkDerivation rec {
|
||||||
chmod +w ./TeensyduinoInstall.${teensy_architecture}
|
chmod +w ./TeensyduinoInstall.${teensy_architecture}
|
||||||
upx -d ./TeensyduinoInstall.${teensy_architecture}
|
upx -d ./TeensyduinoInstall.${teensy_architecture}
|
||||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||||
--set-rpath "${teensy_libpath}" \
|
--set-rpath "${teensy_libpath}" \
|
||||||
./TeensyduinoInstall.${teensy_architecture}
|
./TeensyduinoInstall.${teensy_architecture}
|
||||||
chmod +x ./TeensyduinoInstall.${teensy_architecture}
|
chmod +x ./TeensyduinoInstall.${teensy_architecture}
|
||||||
./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino
|
./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino
|
||||||
# Check for successful installation
|
# Check for successful installation
|
||||||
|
@ -213,8 +212,8 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
preFixup = ''
|
preFixup = ''
|
||||||
for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
|
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-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
|
||||||
patchelf --set-rpath ${rpath}:$out/lib $file || true
|
patchelf --set-rpath ${rpath}:$out/lib $file || true
|
||||||
done
|
done
|
||||||
|
|
||||||
${lib.concatMapStringsSep "\n"
|
${lib.concatMapStringsSep "\n"
|
||||||
|
@ -235,15 +234,15 @@ stdenv.mkDerivation rec {
|
||||||
${lib.optionalString withTeensyduino ''
|
${lib.optionalString withTeensyduino ''
|
||||||
# Patch the Teensy loader binary
|
# Patch the Teensy loader binary
|
||||||
patchelf --debug \
|
patchelf --debug \
|
||||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||||
--set-rpath "${teensy_libpath}" \
|
--set-rpath "${teensy_libpath}" \
|
||||||
$out/share/arduino/hardware/tools/teensy{,_ports,_reboot,_restart,_serialmon}
|
$out/share/arduino/hardware/tools/teensy{,_ports,_reboot,_restart,_serialmon}
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Open-source electronics prototyping platform";
|
description = "Open-source electronics prototyping platform";
|
||||||
homepage = "http://arduino.cc/";
|
homepage = "https://www.arduino.cc/";
|
||||||
license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2;
|
license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2;
|
||||||
platforms = platforms.linux;
|
platforms = platforms.linux;
|
||||||
maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ];
|
maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ];
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
, lib
|
, lib
|
||||||
, fetchurl
|
, fetchurl
|
||||||
, instrument-control
|
, instrument-control
|
||||||
, arduino
|
, arduino-core-unwrapped
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildOctavePackage rec {
|
buildOctavePackage rec {
|
||||||
|
@ -18,9 +18,8 @@ buildOctavePackage rec {
|
||||||
instrument-control
|
instrument-control
|
||||||
];
|
];
|
||||||
|
|
||||||
# Might be able to use pkgs.arduino-core
|
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = [
|
||||||
arduino
|
arduino-core-unwrapped
|
||||||
];
|
];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
|
|
@ -1273,7 +1273,8 @@ with pkgs;
|
||||||
|
|
||||||
arduino-cli = callPackage ../development/embedded/arduino/arduino-cli { };
|
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 {};
|
arduino-mk = callPackage ../development/embedded/arduino/arduino-mk {};
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ makeScope newScope (self:
|
||||||
writeRequiredOctavePackagesHook;
|
writeRequiredOctavePackagesHook;
|
||||||
|
|
||||||
arduino = callPackage ../development/octave-modules/arduino {
|
arduino = callPackage ../development/octave-modules/arduino {
|
||||||
inherit (pkgs) arduino;
|
inherit (pkgs) arduino-core-unwrapped;
|
||||||
};
|
};
|
||||||
|
|
||||||
audio = callPackage ../development/octave-modules/audio { };
|
audio = callPackage ../development/octave-modules/audio { };
|
||||||
|
|
Loading…
Reference in a new issue