Skip to content

Commit 08cc7ad

Browse files
committed
ci/eval: Catch non-top-level internally disallowed problems
Before, something like nativeBuildInputs = [ (runCommand "dep" { meta.description = "Dep"; } "") ]; would cause an eval warning without failing CI After this change, CI ensures that when evaluating the set of packages that don't have internally disallowed problem kinds, no such problem kinds are present.
1 parent c932159 commit 08cc7ad

3 files changed

Lines changed: 29 additions & 13 deletions

File tree

ci/eval/chunk.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
myChunk,
99
includeBroken,
1010
systems,
11+
defaultProblemHandler,
1112
extraNixpkgsConfigJson,
1213
}:
1314

@@ -17,7 +18,7 @@ let
1718

1819
unfiltered = import ./outpaths.nix {
1920
inherit path;
20-
inherit includeBroken systems;
21+
inherit includeBroken systems defaultProblemHandler;
2122
inherit (preEvalResult) attrPathsDisallowedForInternalUse;
2223
extraNixpkgsConfig = builtins.fromJSON extraNixpkgsConfigJson;
2324
};

ci/eval/default.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ let
101101
system=$3
102102
outputDir=$4
103103
preEvalFile=$5
104+
defaultProblemHandler=$6
104105
105106
# Default is 5, higher values effectively disable the warning.
106107
# This randomly breaks Eval.
@@ -124,6 +125,7 @@ let
124125
--arg myChunk "$myChunk" \
125126
--arg preEvalFile "$preEvalFile" \
126127
--arg systems "[ \"$system\" ]" \
128+
--argstr defaultProblemHandler "$defaultProblemHandler" \
127129
--arg includeBroken ${lib.boolToString includeBroken} \
128130
--argstr extraNixpkgsConfigJson ${lib.escapeShellArg (builtins.toJSON extraNixpkgsConfig)} \
129131
-I ${nixpkgs} \
@@ -188,6 +190,7 @@ let
188190
chunkedEval() {
189191
local chunkOutputDir=$1
190192
local preEvalFile=$2
193+
local defaultProblemHandler=$3
191194
192195
local attrCount=$(jq '.paths | length' "$preEvalFile")
193196
echo "Attribute count: $attrCount"
@@ -205,7 +208,7 @@ let
205208
206209
seq -w 0 "$seq_end" |
207210
xargs -I{} -P"$cores" \
208-
${singleChunk} "$chunkSize" {} "$evalSystem" "$chunkOutputDir" "$preEvalFile"
211+
${singleChunk} "$chunkSize" {} "$evalSystem" "$chunkOutputDir" "$preEvalFile" "$defaultProblemHandler"
209212
210213
if (( chunkSize * chunkCount != attrCount )); then
211214
# A final incomplete chunk would mess up the stats, don't include it
@@ -225,13 +228,15 @@ let
225228
startEpoch=$(date +%s)
226229
227230
# The first eval evaluates only attributes that are not disallowed for internal Nixpkgs use, ensuring that they don't depend on disallowed attributes
228-
# Because the first eval doesn't evaluate the disallowed attributes themselves, but we still want to check that they don't fail evaluation, we evaluate them separately in a second eval
231+
# It also uses "warn" as the default problem handler for internally disallowed problem kinds, which ensures no such warnings are thrown at all, because any stderr output fails CI.
232+
# Because the first eval doesn't evaluate the disallowed attributes themselves, but we still want to check that they don't fail evaluation, we evaluate them separately in a second eval.
233+
# The second eval uses "ignore" as the default problem handler for internally disallowed problem kinds, because we don't care about transitive warnings then.
229234
# The reason we need two evals is because we want disallowed attributes to be able to depend on other disallowed attributes, which inherently needs a separate Nixpkgs instantiation
230235
# And while we could interleave that instantiation into a single eval, that would ~double memory usage for all chunks, while doing it separately doesn't
231236
echo "Evaluating the internally allowed attributes"
232-
chunkedEval "$chunkOutputDirs"/allowed ${preEvalFile}
237+
chunkedEval "$chunkOutputDirs"/allowed ${preEvalFile} warn
233238
echo "Evaluating the internally disallowed attributes"
234-
chunkedEval "$chunkOutputDirs"/disallowed "$disallowedAttributesPreEvalFile"
239+
chunkedEval "$chunkOutputDirs"/disallowed "$disallowedAttributesPreEvalFile" ignore
235240
236241
echo $(( $(date +%s) - startEpoch )) > "$out/${evalSystem}/total-time"
237242

ci/eval/outpaths.nix

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
attrPathsDisallowedForInternalUse ? [ ],
1818

19+
defaultProblemHandler ? "ignore",
20+
1921
# Customize the config used to evaluate nixpkgs
2022
extraNixpkgsConfig ? { },
2123
}:
@@ -37,19 +39,27 @@ let
3739
allowVariants = !attrNamesOnly;
3840
checkMeta = true;
3941

40-
# We don't need to care about problems being caught using the
41-
# standard mechanism, because any problems whose kind is not
42-
# nixpkgsInternalUseAllowed cause the corresponding attributes to
43-
# be disallowed entirely for internal use with
44-
# attrPathsDisallowedForInternalUse, see also ./pre-eval.nix
42+
# TODO: This should be synchronised with the problem kinds nixpkgsInternalUseAllowed:
43+
# If allowed -> "error" (traditional default for broken) or "ignore"
44+
# If not allowed -> defaultProblemHandler
4545
problems.matchers = lib.mkForce [
46-
# We only need to set the broken handler to error, so that CI
47-
# doesn't evaluate those. No reason it couldn't evaluate them
48-
# afaik, but this is how it's been before.
4946
{
5047
kind = "broken";
5148
handler = "error";
5249
}
50+
{
51+
kind = "maintainerless";
52+
handler = defaultProblemHandler;
53+
}
54+
{
55+
kind = "removal";
56+
handler = defaultProblemHandler;
57+
}
58+
# TODO: What to do about this? Doesn't currently give even a warning
59+
#{
60+
# kind = "deprecated";
61+
# handler = defaultProblemHandler;
62+
#}
5363
];
5464
inherit attrPathsDisallowedForInternalUse;
5565

0 commit comments

Comments
 (0)