From 617158eaf6ad8f79e5789b0e184ab03a770e1804 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 3 Feb 2023 18:02:16 +0200 Subject: [PATCH] arduino-cli: Install shell completion files Also add the pure Go package to passthru. --- .../embedded/arduino/arduino-cli/default.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkgs/development/embedded/arduino/arduino-cli/default.nix b/pkgs/development/embedded/arduino/arduino-cli/default.nix index 3fbeaab38739..99f1f6e78407 100644 --- a/pkgs/development/embedded/arduino/arduino-cli/default.nix +++ b/pkgs/development/embedded/arduino/arduino-cli/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, buildGoModule, fetchFromGitHub, buildFHSUserEnv }: +{ lib, stdenv, buildGoModule, fetchFromGitHub, buildFHSUserEnv, installShellFiles }: let @@ -13,6 +13,10 @@ let sha256 = "sha256-jew4KLpOOXE9N/h4qFqof8y26DQrvm78E/ARbbwocD4="; }; + nativeBuildInputs = [ + installShellFiles + ]; + subPackages = [ "." ]; vendorSha256 = "sha256-BunonnjzGnpcmGJXxEQXvjJLGvdSXUOK9zAhXoAemHY="; @@ -23,6 +27,15 @@ let "-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 = '' + 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 + ''; + meta = with lib; { inherit (src.meta) homepage; description = "Arduino from the command line"; @@ -46,7 +59,9 @@ if stdenv.isLinux then extraInstallCommands = '' mv $out/bin/$name $out/bin/arduino-cli + cp -r ${pkg.outPath}/share $out/share ''; + passthru.pureGoPkg = pkg; targetPkgs = pkgs: with pkgs; [ zlib