-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
pkgs/top-level: make package sets composable #303849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4e7cc47
3fcedef
0718512
b75355c
eec2100
01a02e4
ba6262f
69775e2
2acca93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,128 @@ | ||||||||||||||||||
| # run like this: | ||||||||||||||||||
| # nix-build pkgs/test/top-level/stage.nix | ||||||||||||||||||
| { | ||||||||||||||||||
| localSystem ? { | ||||||||||||||||||
| system = builtins.currentSystem; | ||||||||||||||||||
| }, | ||||||||||||||||||
| }: | ||||||||||||||||||
|
|
||||||||||||||||||
| with import ../../top-level { inherit localSystem; }; | ||||||||||||||||||
|
|
||||||||||||||||||
| let | ||||||||||||||||||
| # To silence platform specific evaluation errors | ||||||||||||||||||
| discardEvaluationErrors = e: (builtins.tryEval e).success -> e; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Basic test for idempotency of the package set, i.e: | ||||||||||||||||||
| # Applying the same package set twice should work and | ||||||||||||||||||
| # not change anything. | ||||||||||||||||||
| isIdempotent = set: discardEvaluationErrors (pkgs.${set}.stdenv == pkgs.${set}.${set}.stdenv); | ||||||||||||||||||
|
||||||||||||||||||
| isIdempotent = set: discardEvaluationErrors (pkgs.${set}.stdenv == pkgs.${set}.${set}.stdenv); | |
| isIdempotent = set: discardEvaluationErrors (pkgs.${set}.stdenv.outPath == pkgs.${set}.${set}.stdenv.outPath); |
However, I think you do want to check more:
| isIdempotent = set: discardEvaluationErrors (pkgs.${set}.stdenv == pkgs.${set}.${set}.stdenv); | |
| isIdempotent = set: discardEvaluationErrors (pkgs.${set}.stdenv.outPath == pkgs.${set}.${set}.stdenv.outPath | |
| && pkgs.${set}.stdenv.hostPlatform == pkgs.${set}.${set}.stdenv.hostPlatform | |
| && pkgs.${set}.stdenv.buildPlatform == pkgs.${set}.${set}.stdenv.buildPlatform | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.. according to the test failures I got during development, I assumed the outPath changes when host or build platform change. Is that not correct?
I tried adding the hostPlatform & buildPlatform checks. Instead of ==, I had to use lib.systems.equals. I didn't get any test failures this way. This doesn't mean I don't need those changes, but do you have any example where a change to hostPlatform / buildPlatform would not affect stdenv's outPath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to support the idea that those platforms should affect stdenv's outpath:
nixpkgs/pkgs/stdenv/generic/default.nix
Line 167 in 48d5c5f
| inherit buildPlatform hostPlatform targetPlatform; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I made the .outPath comparison explicit, but didn't add the platform checks, yet.
Edit: I reverted the change to use outPath, because nixfmt then requires it to be split across two lines awkwardly. This'd be a net-negative for readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extensive use of this makes the test less effective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without those, I have errors like this quickly:
Those are the errors thrown in
pkgs/top-level/stage.nix. Any idea how I could target those more specifically - without replicating the logic around those into the tests?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through the code again and I think
discardEvaluationErrorsdoes not necessarily make the test less effective. In fact it makes it more specific. The calls to this function are placed only around conditionals, so the evaluation errors can only come from evaluating those package sets.These tests are not meant to test the evaluation of each package set, but to test the composability of them, i.e. they are supposed to test the code in
stage.nix, not further downstream. Ifstdenvfor a certain package set is broken, this is not the place to test it, imho.