Fix mender-cli

This commit is contained in:
muon 2025-10-08 13:54:34 +00:00
parent e6be2231bc
commit 3324cb9df5
2 changed files with 18 additions and 8 deletions

View file

@ -5,6 +5,7 @@
fetchFromGitHub,
makeWrapper,
installShellFiles,
xz,
go,
}:
buildGoModule rec {
@ -14,17 +15,21 @@ buildGoModule rec {
src = fetchFromGitHub {
owner = "mendersoftware";
repo = "mender-cli";
rev = "v${version}";
rev = version;
sha256 = "0i0lijlj82irc54l2ljgj5c4z7r0l8kywcf8c9kmjw6p670kpzrx";
};
vendorHash = lib.fakeHash;
vendorHash = "sha256-MqyBa+wsbuXqtM4DL/QGBUWuEYlG8BRxIXq7O1LJUyM=";
nativeBuildInputs = [
makeWrapper
installShellFiles
];
buildInputs = [
xz
];
allowGoReference = true;
postFixup = ''
@ -34,8 +39,15 @@ buildGoModule rec {
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd mender-cli \
--bash <($out/bin/mender-cli mender-cli --generate-autocomplete) \
--zsh <($out/bin/mender-cli mender-cli --generate-autocomplete) \
--bash <($out/bin/mender-cli completion bash) \
--fish <($out/bin/mender-cli completion fish) \
--zsh <($out/bin/mender-cli completion zsh) \
# Ironically, mender-cli still uses old, slightly buggy completion code
# This will correct the #compdef tag and add separate compdef line
# allowing direct sourcing to also activate the completion
substituteInPlace "$out/share/zsh/site-functions/_mender-cli" \
--replace-fail '#compdef _mender-cli mender-cli' "#compdef mender-cli''\ncompdef _mender-cli mender-cli"
'';
meta = {
@ -43,7 +55,6 @@ buildGoModule rec {
mainProgram = "mender-cli";
homepage = "https://github.com/mendersoftware/mender-cli/";
changelog = "https://github.com/mendersoftware/mender-cli/releases/tag/${version}";
license = lib.licenses.apache;
maintainers = [lib.maintainers.ivankovnatsky];
license = lib.licenses.asl20;
};
}