Skip to content

Commit 72bc213

Browse files
committed
tests: don't test hooks with broken packages
1 parent 91b0d0f commit 72bc213

File tree

1 file changed

+43
-20
lines changed

1 file changed

+43
-20
lines changed

nix/default.nix

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22
, nixpkgs
33
, gitignore-nix-src
44
, isFlakes ? false
5+
,
56
}:
67
let
78
overlay =
89
self: pkgs:
910
let
1011
inherit (pkgs) lib;
1112
tools = import ./call-tools.nix pkgs;
12-
run = pkgs.callPackage ./run.nix { inherit pkgs tools isFlakes gitignore-nix-src; };
13+
run = pkgs.callPackage ./run.nix {
14+
inherit
15+
pkgs
16+
tools
17+
isFlakes
18+
gitignore-nix-src
19+
;
20+
};
1321
in
1422
{
1523
inherit tools run;
@@ -39,23 +47,35 @@ let
3947
specialArgs = { inherit pkgs; };
4048
};
4149
allHooks = config.config.hooks;
50+
51+
# Don't test broken or missing packages
52+
filterBrokenPackages =
53+
n: h:
54+
let
55+
inherit (h) package;
56+
in
57+
package != null && (package.meta.broken or false) != true;
58+
getEntry = n: v: v.entry;
59+
4260
allEntryPoints = lib.pipe allHooks [
43-
(lib.filterAttrs (_name: value: value.package != null))
44-
(lib.mapAttrsToList (_: value: value.entry))
61+
(lib.filterAttrs filterBrokenPackages)
62+
(lib.mapAttrsToList getEntry)
4563
];
4664
in
4765
pkgs.runCommand "all-tools-eval"
4866
{
4967
inherit allEntryPoints;
50-
} ''
51-
touch $out
52-
'';
68+
}
69+
''
70+
touch $out
71+
'';
5372
doc-check =
5473
let
5574
# We might add that it keeps rendering fast and robust,
5675
# and we want to teach `defaultText` which is more broadly applicable,
5776
# but the message is long enough.
58-
failPkgAttr = name: _v:
77+
failPkgAttr =
78+
name: _v:
5979
throw ''
6080
While generating documentation, we found that `pkgs` was used. To avoid rendering store paths in the documentation, this is forbidden.
6181
@@ -78,20 +98,21 @@ let
7898
_type = "pkgs";
7999
inherit lib;
80100
formats = lib.mapAttrs
81-
(formatName: formatFn:
82-
formatArgs:
83-
let
84-
result = formatFn formatArgs;
85-
stubs =
86-
lib.mapAttrs
87-
(name: _:
88-
throw "The attribute `(pkgs.formats.${lib.strings.escapeNixIdentifier formatName} x).${lib.strings.escapeNixIdentifier name}` is not supported during documentation generation. Please check with `--show-trace` to see which option leads to this `${lib.strings.escapeNixIdentifier name}` reference. Often it can be cut short with a `defaultText` argument to `lib.mkOption`, or by escaping an option `example` using `lib.literalExpression`."
101+
(
102+
formatName: formatFn: formatArgs:
103+
let
104+
result = formatFn formatArgs;
105+
stubs = lib.mapAttrs
106+
(
107+
name: _:
108+
throw "The attribute `(pkgs.formats.${lib.strings.escapeNixIdentifier formatName} x).${lib.strings.escapeNixIdentifier name}` is not supported during documentation generation. Please check with `--show-trace` to see which option leads to this `${lib.strings.escapeNixIdentifier name}` reference. Often it can be cut short with a `defaultText` argument to `lib.mkOption`, or by escaping an option `example` using `lib.literalExpression`."
89109
)
90110
result;
91-
in
92-
stubs // {
93-
inherit (result) type;
94-
}
111+
in
112+
stubs
113+
// {
114+
inherit (result) type;
115+
}
95116
)
96117
pkgs.formats;
97118
};
@@ -110,6 +131,8 @@ in
110131
import nixpkgs {
111132
overlays = [ overlay ];
112133
# broken is needed for hindent to build
113-
config = { allowBroken = true; };
134+
config = {
135+
allowBroken = true;
136+
};
114137
inherit system;
115138
}

0 commit comments

Comments
 (0)