nixpkgs/pkgs/by-name/re/revive/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.5 KiB
Nix

{ buildGoModule, fetchFromGitHub, go, lib, makeWrapper }:
buildGoModule rec {
pname = "revive";
version = "1.4.0";
src = fetchFromGitHub {
owner = "mgechev";
repo = pname;
rev = "v${version}";
hash = "sha256-ViYNXZXvlOOpBjQuMAQXwcDtu1HoF+NstrOZzQcBOuQ=";
# populate values that require us to use git. By doing this in postFetch we
# can delete .git afterwards and maintain better reproducibility of the src.
leaveDotGit = true;
postFetch = ''
date -u -d "@$(git -C $out log -1 --pretty=%ct)" "+%Y-%m-%d %H:%M UTC" > $out/DATE
git -C $out rev-parse HEAD > $out/COMMIT
rm -rf $out/.git
'';
};
vendorHash = "sha256-btuAXaJL8URkJvzPy+9tci5gOAqSkkNZn3mN2ox1Vfk=";
ldflags = [
"-s"
"-w"
"-X github.com/mgechev/revive/cli.version=${version}"
"-X github.com/mgechev/revive/cli.builtBy=nix"
];
# ldflags based on metadata from git and source
preBuild = ''
ldflags+=" -X github.com/mgechev/revive/cli.commit=$(cat COMMIT)"
ldflags+=" -X 'github.com/mgechev/revive/cli.date=$(cat DATE)'"
'';
allowGoReference = true;
nativeBuildInputs = [ makeWrapper ];
postFixup = ''
wrapProgram $out/bin/revive \
--prefix PATH : ${lib.makeBinPath [ go ]}
'';
meta = with lib; {
description = "Fast, configurable, extensible, flexible, and beautiful linter for Go";
mainProgram = "revive";
homepage = "https://revive.run";
license = licenses.mit;
maintainers = with maintainers; [ maaslalani ];
};
}