nixpkgs/pkgs/by-name/go/go-licenses/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

62 lines
1.7 KiB
Nix

{ lib
, buildGoModule
, fetchFromGitHub
, go
, installShellFiles
, makeWrapper
}:
buildGoModule rec {
pname = "go-licenses";
version = "1.6.0";
src = fetchFromGitHub {
owner = "google";
repo = "go-licenses";
rev = "refs/tags/v${version}";
hash = "sha256-GAlwTVoVA+n9+EfhybmpKm16FoY9kFzrxy1ZQxS6A8E=";
};
vendorHash = "sha256-ToRn2wj7Yi+UDJwvAhV0ACEhqlcQjt4bRpz7abNRt9A=";
patches = [
# Without this, we get error messages like:
# vendor/golang.org/x/sys/unix/syscall.go:83:16: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
# The patch was generated by changing "go 1.16" to "go 1.17" and executing `go mod tidy`.
./fix-go-version-error.patch
];
nativeBuildInputs = [
installShellFiles
makeWrapper
];
subPackages = [ "." ];
allowGoReference = true;
postInstall = ''
installShellCompletion --cmd go-licenses \
--bash <("$out/bin/go-licenses" completion bash) \
--fish <("$out/bin/go-licenses" completion fish) \
--zsh <("$out/bin/go-licenses" completion zsh)
# workaround empty output when GOROOT differs from built environment
# see https://github.com/google/go-licenses/issues/149
wrapProgram "$out/bin/go-licenses" \
--set GOROOT '${go}/share/go'
'';
# Tests require internet connection
doCheck = false;
meta = with lib; {
changelog = "https://github.com/google/go-licenses/releases/tag/v${version}";
description = "Reports on the licenses used by a Go package and its dependencies";
mainProgram = "go-licenses";
homepage = "https://github.com/google/go-licenses";
license = with licenses; [ asl20 ];
maintainers = with maintainers; [ Luflosi ];
};
}