1{ buildGoModule, fetchFromGitHub, lib }:
2
3buildGoModule rec {
4 pname = "revive";
5 version = "1.3.2";
6
7 src = fetchFromGitHub {
8 owner = "mgechev";
9 repo = pname;
10 rev = "v${version}";
11 sha256 = "sha256-zv9N5Sw23SalP2keII/WC71uhGU+nr+DG3GJcbUwonQ=";
12 # populate values that require us to use git. By doing this in postFetch we
13 # can delete .git afterwards and maintain better reproducibility of the src.
14 leaveDotGit = true;
15 postFetch = ''
16 date -u -d "@$(git -C $out log -1 --pretty=%ct)" "+%Y-%m-%d %H:%M UTC" > $out/DATE
17 git -C $out rev-parse HEAD > $out/COMMIT
18 rm -rf $out/.git
19 '';
20 };
21 vendorHash = "sha256-7VZcZR04JyNa1a4CpLbE7ig+orML3fhdeBOZGTNACKc=";
22
23 ldflags = [
24 "-s"
25 "-w"
26 "-X github.com/mgechev/revive/cli.version=${version}"
27 "-X github.com/mgechev/revive/cli.builtBy=nix"
28 ];
29
30 # ldflags based on metadata from git and source
31 preBuild = ''
32 ldflags+=" -X github.com/mgechev/revive/cli.commit=$(cat COMMIT)"
33 ldflags+=" -X 'github.com/mgechev/revive/cli.date=$(cat DATE)'"
34 '';
35
36 # The following tests fail when built by nix:
37 #
38 # $ nix log /nix/store/build-revive.1.3.2.drv | grep FAIL
39 #
40 # --- FAIL: TestAll (0.01s)
41 # --- FAIL: TestTimeEqual (0.00s)
42 # --- FAIL: TestTimeNaming (0.00s)
43 # --- FAIL: TestUnhandledError (0.00s)
44 # --- FAIL: TestUnhandledErrorWithBlacklist (0.00s)
45 doCheck = false;
46
47 meta = with lib; {
48 description = "Fast, configurable, extensible, flexible, and beautiful linter for Go";
49 homepage = "https://revive.run";
50 license = licenses.mit;
51 maintainers = with maintainers; [ maaslalani ];
52 };
53}