diff --git a/pkgs/by-name/ar/arduino-cli/package.nix b/pkgs/by-name/ar/arduino-cli/package.nix new file mode 100644 index 000000000000..9d887c5f200b --- /dev/null +++ b/pkgs/by-name/ar/arduino-cli/package.nix @@ -0,0 +1,113 @@ +{ + lib, + stdenv, + buildGoModule, + fetchFromGitHub, + buildFHSEnv, + installShellFiles, + go-task, +}: + +let + + pkg = buildGoModule rec { + pname = "arduino-cli"; + version = "1.0.3"; + + src = fetchFromGitHub { + owner = "arduino"; + repo = pname; + rev = "v${version}"; + hash = "sha256-/2GtWiks/d8sTJ6slX2nQtFpGkqm4PSfgDd0uVG+qN8="; + }; + + nativeBuildInputs = [ installShellFiles ]; + + nativeCheckInputs = [ go-task ]; + + subPackages = [ "." ]; + + vendorHash = "sha256-OkilZMDTueHfn6T5Af8e+CVersSPDMcAUUB2o1ny6nc="; + + 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-fail "go test" "go test -p $NIX_BUILD_CORES -skip '(${lib.concatStringsSep "|" skipTests})'" + ''; + + doCheck = stdenv.isLinux; + + checkPhase = '' + runHook preCheck + task go:test + runHook postCheck + ''; + + ldflags = [ + "-s" + "-w" + "-X github.com/arduino/arduino-cli/version.versionString=${version}" + "-X github.com/arduino/arduino-cli/version.commit=unknown" + ] ++ lib.optionals stdenv.isLinux [ "-extldflags '-static'" ]; + + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + export HOME="$(mktemp -d)" + installShellCompletion --cmd arduino-cli \ + --bash <($out/bin/arduino-cli completion bash) \ + --zsh <($out/bin/arduino-cli completion zsh) \ + --fish <($out/bin/arduino-cli completion fish) + unset HOME + ''; + + meta = with lib; { + inherit (src.meta) homepage; + description = "Arduino from the command line"; + mainProgram = "arduino-cli"; + changelog = "https://github.com/arduino/arduino-cli/releases/tag/${version}"; + license = [ + licenses.gpl3Only + licenses.asl20 + ]; + maintainers = with maintainers; [ + ryantm + sfrijters + ]; + }; + + }; + +in +if stdenv.isLinux then + # buildFHSEnv is needed because the arduino-cli downloads compiler + # toolchains from the internet that have their interpreters pointed at + # /lib64/ld-linux-x86-64.so.2 + buildFHSEnv { + inherit (pkg) name meta; + + runScript = "${pkg.outPath}/bin/arduino-cli"; + + extraInstallCommands = + '' + mv $out/bin/$name $out/bin/arduino-cli + '' + + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + cp -r ${pkg.outPath}/share $out/share + ''; + passthru.pureGoPkg = pkg; + + targetPkgs = pkgs: with pkgs; [ zlib ]; + } +else + pkg diff --git a/pkgs/development/embedded/arduino/arduino-cli/default.nix b/pkgs/development/embedded/arduino/arduino-cli/default.nix deleted file mode 100644 index 9e1325a43457..000000000000 --- a/pkgs/development/embedded/arduino/arduino-cli/default.nix +++ /dev/null @@ -1,99 +0,0 @@ -{ lib, stdenv, buildGoModule, fetchFromGitHub, buildFHSEnv, installShellFiles, go-task }: - -let - - pkg = buildGoModule rec { - pname = "arduino-cli"; - version = "1.0.2"; - - src = fetchFromGitHub { - owner = "arduino"; - repo = pname; - rev = "v${version}"; - hash = "sha256-lRCkUF0BBX0nej/HxfV9u8NIuA5W0aBKP2xPR8C61NY="; - }; - - nativeBuildInputs = [ - installShellFiles - ]; - - nativeCheckInputs = [ - go-task - ]; - - subPackages = [ "." ]; - - vendorHash = "sha256-lB/PfUZFL5+YBcAhrMMV2ckAHPhtW2SL3/zM3L4XGVc="; - - 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-fail "go test" "go test -p $NIX_BUILD_CORES -skip '(${lib.concatStringsSep "|" skipTests})'" - ''; - - doCheck = stdenv.isLinux; - - checkPhase = '' - runHook preCheck - task go:test - runHook postCheck - ''; - - ldflags = [ - "-s" "-w" "-X github.com/arduino/arduino-cli/version.versionString=${version}" "-X github.com/arduino/arduino-cli/version.commit=unknown" - ] ++ lib.optionals stdenv.isLinux [ "-extldflags '-static'" ]; - - postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' - export HOME="$(mktemp -d)" - installShellCompletion --cmd arduino-cli \ - --bash <($out/bin/arduino-cli completion bash) \ - --zsh <($out/bin/arduino-cli completion zsh) \ - --fish <($out/bin/arduino-cli completion fish) - unset HOME - ''; - - meta = with lib; { - inherit (src.meta) homepage; - description = "Arduino from the command line"; - mainProgram = "arduino-cli"; - changelog = "https://github.com/arduino/arduino-cli/releases/tag/${version}"; - license = [ licenses.gpl3Only licenses.asl20 ]; - maintainers = with maintainers; [ ryantm sfrijters ]; - }; - - }; - -in -if stdenv.isLinux then -# buildFHSEnv is needed because the arduino-cli downloads compiler -# toolchains from the internet that have their interpreters pointed at -# /lib64/ld-linux-x86-64.so.2 - buildFHSEnv - { - inherit (pkg) name meta; - - runScript = "${pkg.outPath}/bin/arduino-cli"; - - extraInstallCommands = '' - mv $out/bin/$name $out/bin/arduino-cli - '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' - cp -r ${pkg.outPath}/share $out/share - ''; - passthru.pureGoPkg = pkg; - - targetPkgs = pkgs: with pkgs; [ - zlib - ]; - } -else - pkg diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7f810836380b..2dfe37a17da8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3167,8 +3167,6 @@ with pkgs; arduino-ci = callPackage ../development/embedded/arduino/arduino-ci { }; - arduino-cli = callPackage ../development/embedded/arduino/arduino-cli { }; - arduino-core = callPackage ../development/embedded/arduino/arduino-core/chrootenv.nix { }; arduino-core-unwrapped = callPackage ../development/embedded/arduino/arduino-core { };