about summary refs log tree commit diff
path: root/pkgs/tools/text/vale/default.nix
blob: a936eafbae82a87c6af61f41a8313f9d98c3947f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ lib
, buildGoModule
, fetchFromGitHub
, makeBinaryWrapper
, runCommand
, symlinkJoin
, vale
, valeStyles
}:

buildGoModule rec {
  pname = "vale";
  version = "3.4.1";

  subPackages = [ "cmd/vale" ];

  src = fetchFromGitHub {
    owner = "errata-ai";
    repo = "vale";
    rev = "v${version}";
    hash = "sha256-fD2KBKDfKTNYuzP/zKkAx9h/HMxOlAyiWtp9EsWxop8=";
  };

  vendorHash = "sha256-HMzFLSmO6sBDNU89UoIvHcPPd3ubpti2ii4sFMKUDmI=";

  ldflags = [ "-s" "-w" "-X main.version=${version}" ];

  # Tests require network access
  doCheck = false;

  passthru.withStyles = selector: symlinkJoin {
    name = "vale-with-styles-${vale.version}";
    paths = [ vale ] ++ selector valeStyles;
    nativeBuildInputs = [ makeBinaryWrapper ];
    postBuild = ''
      wrapProgram "$out/bin/vale" \
        --set VALE_STYLES_PATH "$out/share/vale/styles/"
    '';
    meta = {
      inherit (vale.meta) mainProgram;
    };
  };

  meta = with lib; {
    description = "A syntax-aware linter for prose built with speed and extensibility in mind";
    longDescription = ''
      Vale in Nixpkgs offers the helper `.withStyles` allow you to install it
      predefined styles:

          vale.withStyles (s: [ s.alex s.google ])
    '';
    homepage = "https://vale.sh/";
    changelog = "https://github.com/errata-ai/vale/releases/tag/v${version}";
    mainProgram = "vale";
    license = licenses.mit;
    maintainers = [ maintainers.pbsds ];
  };
}