biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / embedded / arduino / arduino-cli / default.nix
blob0a15a1566fe34c8b90ae072a92c7737bf03559e4
1 { lib, stdenv, buildGoModule, fetchFromGitHub, buildFHSEnv, installShellFiles, go-task }:
3 let
5   pkg = buildGoModule rec {
6     pname = "arduino-cli";
7     version = "0.35.3";
9     src = fetchFromGitHub {
10       owner = "arduino";
11       repo = pname;
12       rev = "v${version}";
13       hash = "sha256-brWWoIOQhU/isd48VCx6tczAJnamBuOa6e/xezuHN7E=";
14     };
16     nativeBuildInputs = [
17       installShellFiles
18     ];
20     nativeCheckInputs = [
21       go-task
22     ];
24     subPackages = [ "." ];
26     vendorHash = "sha256-y7YxcBFjKcQK6ilCKOyoszq64/0xG5GgTehKrKThknU=";
28     postPatch = let
29       skipTests = [
30         # tries to "go install"
31         "TestDummyMonitor"
32         # try to Get "https://downloads.arduino.cc/libraries/library_index.tar.bz2"
33         "TestDownloadAndChecksums"
34         "TestParseArgs"
35         "TestParseReferenceCores"
36         "TestPlatformSearch"
37         "TestPlatformSearchSorting"
38       ];
39     in ''
40       substituteInPlace Taskfile.yml \
41         --replace-fail "go test" "go test -p $NIX_BUILD_CORES -skip '(${lib.concatStringsSep "|" skipTests})'"
42     '';
44     doCheck = stdenv.isLinux;
46     checkPhase = ''
47       runHook preCheck
48       task go:test
49       runHook postCheck
50     '';
52     ldflags = [
53       "-s" "-w" "-X github.com/arduino/arduino-cli/version.versionString=${version}" "-X github.com/arduino/arduino-cli/version.commit=unknown"
54     ] ++ lib.optionals stdenv.isLinux [ "-extldflags '-static'" ];
56     postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
57       export HOME="$(mktemp -d)"
58       installShellCompletion --cmd arduino-cli \
59         --bash <($out/bin/arduino-cli completion bash) \
60         --zsh <($out/bin/arduino-cli completion zsh) \
61         --fish <($out/bin/arduino-cli completion fish)
62       unset HOME
63     '';
65     meta = with lib; {
66       inherit (src.meta) homepage;
67       description = "Arduino from the command line";
68       mainProgram = "arduino-cli";
69       changelog = "https://github.com/arduino/arduino-cli/releases/tag/${version}";
70       license = licenses.gpl3Only;
71       maintainers = with maintainers; [ ryantm ];
72     };
74   };
77 if stdenv.isLinux then
78 # buildFHSEnv is needed because the arduino-cli downloads compiler
79 # toolchains from the internet that have their interpreters pointed at
80 # /lib64/ld-linux-x86-64.so.2
81   buildFHSEnv
82   {
83     inherit (pkg) name meta;
85     runScript = "${pkg.outPath}/bin/arduino-cli";
87     extraInstallCommands = ''
88       mv $out/bin/$name $out/bin/arduino-cli
89     '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
90       cp -r ${pkg.outPath}/share $out/share
91     '';
92     passthru.pureGoPkg = pkg;
94     targetPkgs = pkgs: with pkgs; [
95       zlib
96     ];
97   }
98 else
99   pkg