nixpkgs/pkgs/by-name/go/go-containerregistry/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

53 lines
1.4 KiB
Nix

{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
let bins = [ "crane" "gcrane" ]; in
buildGoModule rec {
pname = "go-containerregistry";
version = "0.20.2";
src = fetchFromGitHub {
owner = "google";
repo = pname;
rev = "v${version}";
sha256 = "sha256-5f5zheFPSKmpUaVmcAfeZgFSDu3rvdtQh8mau9jdqz4=";
};
vendorHash = null;
nativeBuildInputs = [ installShellFiles ];
subPackages = [ "cmd/crane" "cmd/gcrane" ];
outputs = [ "out" ] ++ bins;
ldflags =
let t = "github.com/google/go-containerregistry"; in
[ "-s" "-w" "-X ${t}/cmd/crane/cmd.Version=v${version}" "-X ${t}/pkg/v1/remote/transport.Version=${version}" ];
postInstall =
lib.concatStringsSep "\n" (
map (bin: ''
mkdir -p ''$${bin}/bin &&
mv $out/bin/${bin} ''$${bin}/bin/ &&
ln -s ''$${bin}/bin/${bin} $out/bin/
'') bins
) + ''
for cmd in crane gcrane; do
installShellCompletion --cmd "$cmd" \
--bash <($GOPATH/bin/$cmd completion bash) \
--fish <($GOPATH/bin/$cmd completion fish) \
--zsh <($GOPATH/bin/$cmd completion zsh)
done
'';
# NOTE: no tests
doCheck = false;
meta = with lib; {
description = "Tools for interacting with remote images and registries including crane and gcrane";
homepage = "https://github.com/google/go-containerregistry";
license = licenses.asl20;
maintainers = with maintainers; [ yurrriq ];
};
}