Skip to content

Commit

Permalink
Merge pull request #288146 from maxbrunet/feat/regclient/shell-comple…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
SuperSandro2000 committed Mar 25, 2024
2 parents 5ee9432 + ef0ed76 commit 12600e8
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions pkgs/development/tools/regclient/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{ stdenv, lib, buildGoModule, fetchFromGitHub }:
{ stdenv
, lib
, buildGoModule
, fetchFromGitHub
, installShellFiles
, lndir
, testers
, regclient
}:

let bins = [ "regbot" "regctl" "regsync" ]; in

Expand All @@ -20,22 +28,48 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X main.VCSTag=${tag}"
"-X github.com/regclient/regclient/internal/version.vcsTag=${tag}"
];

postInstall =
lib.concatStringsSep "\n" (
map (bin: ''
mkdir -p ''$${bin}/bin &&
mv $out/bin/${bin} ''$${bin}/bin/ &&
ln -s ''$${bin}/bin/${bin} $out/bin/
'') bins
);
nativeBuildInputs = [ installShellFiles lndir ];

postInstall = lib.concatMapStringsSep "\n"
(bin: ''
export bin=''$${bin}
export outputBin=bin
mkdir -p $bin/bin
mv $out/bin/${bin} $bin/bin
installShellCompletion --cmd ${bin} \
--bash <($bin/bin/${bin} completion bash) \
--fish <($bin/bin/${bin} completion fish) \
--zsh <($bin/bin/${bin} completion zsh)
lndir -silent $bin $out
unset bin outputBin
'')
bins;

passthru.tests = lib.mergeAttrsList (
map
(bin: {
"${bin}Version" = testers.testVersion {
package = regclient;
command = "${bin} version";
version = tag;
};
})
bins
);

__darwinAllowLocalNetworking = true;

meta = with lib; {
description = "Docker and OCI Registry Client in Go and tooling using those libraries";
homepage = "https://github.com/regclient/regclient";
license = licenses.asl20;
maintainers = with maintainers; [ ];
maintainers = with maintainers; [ maxbrunet ];
};
}

0 comments on commit 12600e8

Please sign in to comment.