Skip to content

Commit b4cd36f

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

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

nix/default.nix

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,30 @@
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+
};
21+
22+
# Filter out any broken or missing packages from our tests.
23+
filterBrokenPackages = n: package: package != null && !(package.meta.broken or false);
1324
in
1425
{
1526
inherit tools run;
1627
# Flake style attributes
17-
packages = (lib.filterAttrs (_name: value: value != null) tools) // {
28+
packages = (lib.filterAttrs filterBrokenPackages tools) // {
1829
inherit (pkgs) pre-commit;
1930
};
2031
checks = self.packages // {
@@ -39,23 +50,31 @@ let
3950
specialArgs = { inherit pkgs; };
4051
};
4152
allHooks = config.config.hooks;
53+
54+
getEntry = n: v: v.entry;
55+
getPackage =
56+
f: n: h:
57+
f n h.package;
58+
4259
allEntryPoints = lib.pipe allHooks [
43-
(lib.filterAttrs (_name: value: value.package != null))
44-
(lib.mapAttrsToList (_: value: value.entry))
60+
(lib.filterAttrs (getPackage filterBrokenPackages))
61+
(lib.mapAttrsToList getEntry)
4562
];
4663
in
4764
pkgs.runCommand "all-tools-eval"
4865
{
4966
inherit allEntryPoints;
50-
} ''
51-
touch $out
52-
'';
67+
}
68+
''
69+
touch $out
70+
'';
5371
doc-check =
5472
let
5573
# We might add that it keeps rendering fast and robust,
5674
# and we want to teach `defaultText` which is more broadly applicable,
5775
# but the message is long enough.
58-
failPkgAttr = name: _v:
76+
failPkgAttr =
77+
name: _v:
5978
throw ''
6079
While generating documentation, we found that `pkgs` was used. To avoid rendering store paths in the documentation, this is forbidden.
6180
@@ -78,20 +97,21 @@ let
7897
_type = "pkgs";
7998
inherit lib;
8099
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`."
100+
(
101+
formatName: formatFn: formatArgs:
102+
let
103+
result = formatFn formatArgs;
104+
stubs = lib.mapAttrs
105+
(
106+
name: _:
107+
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`."
89108
)
90109
result;
91-
in
92-
stubs // {
93-
inherit (result) type;
94-
}
110+
in
111+
stubs
112+
// {
113+
inherit (result) type;
114+
}
95115
)
96116
pkgs.formats;
97117
};
@@ -110,6 +130,8 @@ in
110130
import nixpkgs {
111131
overlays = [ overlay ];
112132
# broken is needed for hindent to build
113-
config = { allowBroken = true; };
133+
config = {
134+
allowBroken = true;
135+
};
114136
inherit system;
115137
}

0 commit comments

Comments
 (0)