about summary refs log tree commit diff
path: root/pkgs/tools/text/vale/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/text/vale/default.nix')
-rw-r--r--pkgs/tools/text/vale/default.nix32
1 files changed, 25 insertions, 7 deletions
diff --git a/pkgs/tools/text/vale/default.nix b/pkgs/tools/text/vale/default.nix
index 9fa3c12ccc88a..5bb73a50f9e64 100644
--- a/pkgs/tools/text/vale/default.nix
+++ b/pkgs/tools/text/vale/default.nix
@@ -1,11 +1,18 @@
-{ lib, buildGoModule, fetchFromGitHub }:
+{ lib
+, buildGoModule
+, fetchFromGitHub
+, makeBinaryWrapper
+, runCommand
+, symlinkJoin
+, vale
+, valeStyles
+}:
 
 buildGoModule rec {
   pname = "vale";
   version = "3.4.1";
 
   subPackages = [ "cmd/vale" ];
-  outputs = [ "out" "data" ];
 
   src = fetchFromGitHub {
     owner = "errata-ai";
@@ -16,18 +23,29 @@ buildGoModule rec {
 
   vendorHash = "sha256-HMzFLSmO6sBDNU89UoIvHcPPd3ubpti2ii4sFMKUDmI=";
 
-  postInstall = ''
-    mkdir -p $data/share/vale
-    cp -r testdata/styles $data/share/vale
-  '';
-
   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 = 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";