2023-05-24 13:37:59 +00:00
|
|
|
{ lib, stdenv, buildGoModule, fetchFromGitHub, buildFHSEnv, installShellFiles, go-task }:
|
2020-08-20 17:08:02 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
pkg = buildGoModule rec {
|
|
|
|
pname = "arduino-cli";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "0.32.2";
|
2020-08-20 17:08:02 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "arduino";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2023-05-24 13:37:59 +00:00
|
|
|
hash = "sha256-Em8L2ZYS1rgW46/MP5hs/EBWGcb5GP3EDEzWi072F/I=";
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
go-task
|
|
|
|
];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
subPackages = [ "." ];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
vendorSha256 = "sha256-+5Cj6wdX25fK+Y9czTwRRqCdY+0iarvii9nD3QMDh+c=";
|
|
|
|
|
|
|
|
postPatch = let
|
|
|
|
skipTests = [
|
|
|
|
# tries to "go install"
|
|
|
|
"TestDummyMonitor"
|
|
|
|
# try to Get "https://downloads.arduino.cc/libraries/library_index.tar.bz2"
|
|
|
|
"TestDownloadAndChecksums"
|
|
|
|
"TestParseArgs"
|
|
|
|
"TestParseReferenceCores"
|
|
|
|
"TestPlatformSearch"
|
|
|
|
"TestPlatformSearchSorting"
|
|
|
|
];
|
|
|
|
in ''
|
|
|
|
substituteInPlace Taskfile.yml \
|
|
|
|
--replace "go test" "go test -p $NIX_BUILD_CORES -skip '(${lib.concatStringsSep "|" skipTests})'"
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = stdenv.isLinux;
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
task go:test
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2021-08-27 14:25:00 +00:00
|
|
|
ldflags = [
|
|
|
|
"-s" "-w" "-X github.com/arduino/arduino-cli/version.versionString=${version}" "-X github.com/arduino/arduino-cli/version.commit=unknown"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optionals stdenv.isLinux [ "-extldflags '-static'" ];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
postInstall = ''
|
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
for s in {bash,zsh,fish}; do
|
|
|
|
$out/bin/arduino-cli completion $s > completion.$s
|
|
|
|
installShellCompletion --cmd arduino-cli --$s completion.$s
|
|
|
|
done
|
|
|
|
unset HOME
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-08-20 17:08:02 +00:00
|
|
|
inherit (src.meta) homepage;
|
|
|
|
description = "Arduino from the command line";
|
2023-01-20 10:41:00 +00:00
|
|
|
changelog = "https://github.com/arduino/arduino-cli/releases/tag/${version}";
|
2020-08-20 17:08:02 +00:00
|
|
|
license = licenses.gpl3Only;
|
|
|
|
maintainers = with maintainers; [ ryantm ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
in
|
|
|
|
if stdenv.isLinux then
|
2023-04-29 16:46:19 +00:00
|
|
|
# buildFHSEnv is needed because the arduino-cli downloads compiler
|
2020-08-20 17:08:02 +00:00
|
|
|
# toolchains from the internet that have their interpreters pointed at
|
|
|
|
# /lib64/ld-linux-x86-64.so.2
|
2023-04-29 16:46:19 +00:00
|
|
|
buildFHSEnv
|
2021-05-20 23:08:51 +00:00
|
|
|
{
|
|
|
|
inherit (pkg) name meta;
|
|
|
|
|
|
|
|
runScript = "${pkg.outPath}/bin/arduino-cli";
|
|
|
|
|
|
|
|
extraInstallCommands = ''
|
|
|
|
mv $out/bin/$name $out/bin/arduino-cli
|
2023-02-09 11:40:11 +00:00
|
|
|
cp -r ${pkg.outPath}/share $out/share
|
2021-05-20 23:08:51 +00:00
|
|
|
'';
|
2023-02-09 11:40:11 +00:00
|
|
|
passthru.pureGoPkg = pkg;
|
2021-07-03 03:11:41 +00:00
|
|
|
|
|
|
|
targetPkgs = pkgs: with pkgs; [
|
|
|
|
zlib
|
|
|
|
];
|
2021-05-20 23:08:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pkg
|