Skip to content

Commit 06e7288

Browse files
authored
vale{,Styles}: move to by-name, cleanup, format, refactor (#344862)
2 parents 1c0f094 + 6787161 commit 06e7288

File tree

3 files changed

+67
-49
lines changed

3 files changed

+67
-49
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
{ lib
2-
, buildGoModule
3-
, fetchFromGitHub
4-
, makeBinaryWrapper
5-
, runCommand
6-
, symlinkJoin
7-
, vale
8-
, valeStyles
1+
{
2+
lib,
3+
buildGoModule,
4+
fetchFromGitHub,
5+
makeBinaryWrapper,
6+
symlinkJoin,
7+
vale,
8+
valeStyles,
99
}:
1010

1111
buildGoModule rec {
@@ -23,36 +23,43 @@ buildGoModule rec {
2323

2424
vendorHash = "sha256-0AeG0/ALU/mkXxVKzqGhxXLqq2XYmnF/ZRaZkJ5eQxU=";
2525

26-
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
26+
ldflags = [
27+
"-s"
28+
"-X main.version=${version}"
29+
];
2730

2831
# Tests require network access
2932
doCheck = false;
3033

31-
passthru.withStyles = selector: symlinkJoin {
32-
name = "vale-with-styles-${vale.version}";
33-
paths = [ vale ] ++ selector valeStyles;
34-
nativeBuildInputs = [ makeBinaryWrapper ];
35-
postBuild = ''
36-
wrapProgram "$out/bin/vale" \
37-
--set VALE_STYLES_PATH "$out/share/vale/styles/"
38-
'';
39-
meta = {
40-
inherit (vale.meta) mainProgram;
34+
passthru.withStyles =
35+
selector:
36+
symlinkJoin {
37+
name = "vale-with-styles-${vale.version}";
38+
paths = [ vale ] ++ selector valeStyles;
39+
nativeBuildInputs = [ makeBinaryWrapper ];
40+
postBuild = ''
41+
wrapProgram "$out/bin/vale" \
42+
--set VALE_STYLES_PATH "$out/share/vale/styles/"
43+
'';
44+
meta = {
45+
inherit (vale.meta) mainProgram;
46+
};
4147
};
42-
};
4348

44-
meta = with lib; {
49+
meta = {
4550
description = "Syntax-aware linter for prose built with speed and extensibility in mind";
4651
longDescription = ''
4752
Vale in Nixpkgs offers the helper `.withStyles` allow you to install it
4853
predefined styles:
4954
50-
vale.withStyles (s: [ s.alex s.google ])
55+
```nix
56+
vale.withStyles (s: [ s.alex s.google ])
57+
```
5158
'';
5259
homepage = "https://vale.sh/";
5360
changelog = "https://github.com/errata-ai/vale/releases/tag/v${version}";
5461
mainProgram = "vale";
55-
license = licenses.mit;
56-
maintainers = [ maintainers.pbsds ];
62+
license = lib.licenses.mit;
63+
maintainers = with lib.maintainers; [ pbsds ];
5764
};
5865
}
Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,47 @@
1-
{ lib, stdenvNoCC, fetchFromGitHub, fetchzip, nix-update-script }:
1+
{
2+
lib,
3+
stdenvNoCC,
4+
fetchFromGitHub,
5+
nix-update-script,
6+
}:
27

38
let
49
buildStyle =
5-
{ name
6-
, stylePath ? name
7-
, ...
10+
{
11+
name,
12+
stylePath ? name,
13+
...
814
}@args:
9-
stdenvNoCC.mkDerivation ({
10-
pname = "vale-style-${lib.toLower name}";
15+
stdenvNoCC.mkDerivation (
16+
{
17+
pname = "vale-style-${lib.toLower name}";
1118

12-
dontConfigure = true;
13-
dontBuild = true;
14-
doCheck = false;
15-
dontFixup = true;
19+
dontConfigure = true;
20+
dontBuild = true;
21+
doCheck = false;
22+
dontFixup = true;
1623

17-
installPhase = ''
18-
runHook preInstall
19-
mkdir -p $out/share/vale/styles
20-
cp -R ${stylePath} "$out/share/vale/styles/${name}"
21-
runHook postInstall
22-
'';
24+
installPhase = ''
25+
runHook preInstall
26+
mkdir -p $out/share/vale/styles
27+
cp -R ${stylePath} "$out/share/vale/styles/${name}"
28+
runHook postInstall
29+
'';
2330

24-
passthru.updateScript = nix-update-script { };
31+
passthru.updateScript = nix-update-script { };
2532

26-
meta = {
27-
platforms = lib.platforms.all;
28-
maintainers = with lib.maintainers; [ katexochen ];
29-
} // (args.meta or { });
30-
} // removeAttrs args [ "meta" "name" ]);
33+
meta = {
34+
platforms = lib.platforms.all;
35+
maintainers = with lib.maintainers; [ katexochen ];
36+
} // (args.meta or { });
37+
}
38+
// removeAttrs args [
39+
"meta"
40+
"name"
41+
]
42+
);
3143
in
44+
3245
{
3346
alex = buildStyle rec {
3447
name = "alex";

pkgs/top-level/all-packages.nix

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23620,9 +23620,7 @@ with pkgs;
2362023620

2362123621
libva-vdpau-driver = callPackage ../development/libraries/libva-vdpau-driver { };
2362223622

23623-
vale = callPackage ../tools/text/vale { };
23624-
23625-
valeStyles = recurseIntoAttrs (callPackages ../tools/text/vale/styles.nix { });
23623+
valeStyles = recurseIntoAttrs (callPackages ../by-name/va/vale/styles.nix { });
2362623624

2362723625
valhalla = callPackage ../development/libraries/valhalla {
2362823626
boost = boost.override { enablePython = true; python = python3; };

0 commit comments

Comments
 (0)