nixpkgs/pkgs/by-name/go/go-licenses/package.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

63 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 ];
};
}