Repository navigation
stdenv/problems: use generated problems for legacy field values - #557381
Conversation
|
Quick diff check: the call to genAutomaticProblems in the first commit could partially apply the filter on |
efabfd2 to
28ef688
Compare
How do you mean? Wouldn't that just be wrapping the actual function with yet another thunk? I don't see how we can access problems without passing a concrete For the sake of completeness I've rebased and pushed a new commit that removes the old |
I didn't explain myself very well. We can change diff --git a/pkgs/stdenv/generic/problems.nix b/pkgs/stdenv/generic/problems.nix
index 887242e53684..9ae0b5d7b6d3 100644
--- a/pkgs/stdenv/generic/problems.nix
+++ b/pkgs/stdenv/generic/problems.nix
@@ -149,10 +149,17 @@ rec {
);
genAutomaticProblems =
- config: attrs:
+ config:
+ let
+ # only perform the logic that requires config once
+ automaticProblems' = map (
+ problem: problem // { condition = problem.condition config; }
+ ) automaticProblems;
+ in
+ attrs:
listToAttrs (
map (problem: lib.nameValuePair problem.kindName problem.value) (
- filter (problem: problem.condition config attrs) automaticProblems
+ filter (problem: problem.condition attrs) automaticProblems'
)
);
This is meaningful for automatic problems like |
|
Running stats diff with {
"attrset": {
"lookups": "-0.03%",
"merges": "+0%",
"mergeCopies": null
},
"list": {
"concats": null
},
"parser": {
"expressions": "+0%"
},
"memoryBytes": {
"envs": "+0.09%",
"list": "+0.01%",
"sets": "+0%",
"symbols": "+0.01%",
"values": "+0.06%",
"total": "+0.02%"
},
"speed": {
"primops": "+0.2%",
"functionCalls": "+0.04%",
"thunksMade": "+0.12%",
"thunksAvoided": "+0.07%"
}
}I'm surprised by the fact that there's a diff at all. I guess it's caused by the places wherethe final result of |
I'm almost certain the typechecking for meta is whats causing this. Normally nothing should care about the right hand side of the meta attributes unless used in an expression. Since the typechecking probably does some |
If you apply this does that change the numbers for you? index 724e8b8ccac4..4abef94a27cd 100644
--- a/pkgs/stdenv/generic/check-meta.nix
+++ b/pkgs/stdenv/generic/check-meta.nix
@@ -351,7 +351,7 @@ let
else
# Check meta attribute types first, to make sure it is always called even when there are other issues
# Note that this is not a full type check and functions below still need to by careful about their inputs!
- if checkMeta && !metaType.verify attrs.meta then
+ if checkMeta /* && !metaType.verify attrs.meta */ then
{
reason = "unknown-meta";
msg = "has an invalid meta attrset:${ |
But ❯ lix repl
Lix 2.95.2
Type :? for help.
Loading 'repl-overlays'...
Added 119 variables.
nix-repl> pkgs.config.checkMeta
falseSo that patch wouldn't affect it. |
Mhm, forcing an error by passing in a invalid |
This makes it a bit cheaper to call the completeMetaProblems function as the automatic problems are only generated once (per `config` instance).
This is similar to how we use the genCheckProblems function for the generic problem generation. Accessing multiple `meta.problems` fields should become slightly cheaper now.
This pulls in the brokenness information from the meta.problems fields. This decouples the both implementation from each other (slightly). Whatever the metric for brokenness in meta.problems is now carries over to old meta.broken attribute. Right now there is no difference in the value of meta.broken since the both implementations are almost identical. As future work we could now drop the logic from `check-meta.nix` and rely solely on the problems code to do the brokenness detection without abandoning `meta.broken` as value to query.
For some time we've had the meta.problems automatic problems detect brokenness of a package (same logic; looking at meta.broken) but also kept the "legacy" code to propagate the information into the final meta attrset. Since we already have the problems information as part of the commonMeta implementation we can make use of that to propagate the field. We now only have one implementation for the broken attribute. Yay.
fbd9044 to
2ff9e84
Compare
I think I know how to work around that, but it requires a bit more refactoring than I'd really like to do in this PR. The PR has been rebased again and I'd like to land it as is unless there are still concerns. |
I think that is something I'll do in a follow-up as that'll be inline with the changes required to avoid the double problems eval that we are currently having. It also touches a point that I discussed with @infinisil a few weeks ago: The code filtering / throwing the errors shouldn't be as tangled to the problem gathering as it is now. |
llakala
left a comment
There was a problem hiding this comment.
I think that is something I'll do in a follow-up as that'll be inline with the changes required to avoid the double problems eval that we are currently having.
Sounds good. I'll merge this in a day or two if no other committers complain (remind me if I forget).
Ping :-) I can also hit the merge button if you are fine with that. |
|
Somehow, this causes |
NixOS#557381 changed the semantics of config.allowBroken in a way which broke our override to ignore brokenness of packages. It has now two problems: 1. allowBroken now (sometimes) affects the meta.broken flag of a package which breaks our logic. 2. It behaves inconsistent depending on how a package was marked broken. This commit works around this by not using allowBroken. Instead it overrides the logic which converts broken packages to eval errors thus sidestepping both above problems.
NixOS#557381 changed the semantics of config.allowBroken in a way which broke our override to ignore brokenness of packages. It has now two problems: 1. allowBroken now (sometimes) affects the meta.broken flag of a package which breaks our logic. 2. It behaves inconsistent depending on how a package was marked broken. This commit works around this by not using allowBroken. Instead it overrides the logic which converts broken packages to eval errors thus sidestepping both above problems.
Continuing my work on porting RFC127 defined problems from the old attrs.meta world. This is a follow-up to #556367 and lays some groundwork to continue #545234.
The idea is to have the
metaattributes in the final derivation always reflect what has been determined (either by automatic problems or by manually setting a field). Right now we have two implementations ofmeta.brokenchecks. One of them is in thecheck-meta.nixfile and the other is in theproblems.niximplementation. By leaning onto theproblems.niximplementation as part of thecommonMetafunction we can reduce the duplication back to one canonical implementation. IMO this is an approach that should also be taken for further checks that get moved as we don't want a drift in that logic.While talking through this idea it became apparent that
problems.nixshould probably only be the data layer for all the problems and the handler code should take care of the escape hatches (e.g. checking env vars).Opening as a draft for now as this will require some further work and testing before I'm confident.
The other PRs (notably #545234) will be rebased/rewritten to match the outcome of this.
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.