-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
top-level: simplify stdenv calling of top-level: fewer inferred and re-inferring arguments #15043
Conversation
By analyzing the blame information on this pull request, we identified @nbp, @edolstra and @gridaphobe to be potential reviewers |
83de0e1
to
a064847
Compare
If we keep improving top-level functions (which I fully support), we should also document the flow so that we can reason about the improvements. It's really hard to evaluate and follow the logic without spending considerable amount of time on it. |
Yeah I fully agree. I tried to add some documentation as I went along, but it would be good to move things into saner locations and add more. |
- defaultStdenv = allStdenvs.stdenv; | ||
+ defaultStdenv = traceDrvLicenses allStdenvs.stdenv; | ||
- defaultStdenv = vanillaStdenv; | ||
+ defaultStdenv = traceDrvLicenses avanillaStdenv; | ||
" |
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.
Could this script be changed to use nix-instantiate -E
? Then this message would not be necessary.
Also, @nbp, is this script still useful?
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.
Technically, I didn't even fix the error message to be a real diff. I was mainly interested in making sure my allStdenvs
grep came clean before I removed it :).
As far as the locations, I think |
@@ -19,83 +25,25 @@ | |||
&& system != "x86_64-solaris" | |||
&& system != "x86_64-kfreebsd-gnu") | |||
|
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.
noSysDirs
should be in stdenv (true in stdenvNative and false elsewhere), rather than being a top-level argument.
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 like that idea, but I see it less as something that should have been done already than something that's good to do in addition---I haven't messed with any parameters that actual packages receive yet.
That said, I'm fine just making it an additional commit that's part of this rather than a separate PR.
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 have a similar idea for crossSystem
. Now that crossStdenv
is properly staged, we can give each stdenv a host
and target
system+platform, and set them accordingly in the cross stages.
crossStdenv
would remain as a entry-point argument, but all-packages.nix
would not have that argument as just look at stdenv.host
and stdenv.target
.
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.
But that, if not the noSysDirs
change, will probably be more contentious and deserving of its own PR.
@Mathnerd314 How about (edit wrote wrong things):
which, like yours, keeps the "entry point" in the same location. I do like the idea of just sticking the impure stuff in |
I like it! Part of me is still partial to a |
Anybody else else want to review this (and @Mathnerd314's additions) soon? In some cases I imagine it might make sense to interleave/squash our commits---let me know where and I'll be happy to do it. |
@@ -6,4 +6,4 @@ if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins. | |||
|
|||
else | |||
|
|||
import ./pkgs/top-level | |||
import ./pkgs/impure.nix |
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'm not sure about the location and name of this-one but don't have a better recommendation at the moment. Actually it should probably stay in the top-level folder. After reading the rest of the diff is actually makes more sense to be there.
Looking like a good cleanup |
Hello reviewers! :)
I rebased on top of latest channels/nixpkgs-unstable, did that rename I proposed, and added @Mathnerd314's commits to make it easier to review everything. |
I always wondered, why is that folder called top-level when it's not the top level? Having all the packages listed in |
@zimbatm I agree. I tried to conservatively keep things in the same place for now. But nixpkgs is overdue for a big sorting. |
topLevelArguments = { | ||
inherit system bootStdenv noSysDirs config crossSystem platform lib; | ||
}; | ||
# A few packages make make a new package set to draw their dependencies from. |
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.
"make make" => "make"
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.
Fixed, thanks!
@Ericson2314 agreed not in this PR. Speaking of which, is it ready to be merged? |
@zimbatm Well, the first n commits are ready, the question is what n is :). I am quite confident that everything through my penultimate commit is a good idea. But I'm a bit unsure whether the last commit makes things more or less convoluted. And I am still triaging @Mathnerd314's commits: the guaranteed good ones I should probably rebase on top of my guaranteed good ones. |
Some decisions like "should |
let | ||
toPath = builtins.toPath; | ||
getEnv = x: if builtins ? getEnv then builtins.getEnv x else ""; | ||
pathExists = name: |
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.
toPath, getEnv and pathExists are available since nix 0.10
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.
Fixed, thanks!
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.
Also see bec28d7 in master
f5c3716
to
e870a4a
Compare
20f2911
to
a17fdb2
Compare
…vel/stage.nix` This is preparation for the latter just building a single stage, and the former building a package set with the bootstrapped stdenv.
This commit changes the dependencies of stdenv, and clean-up the stdenv story by removing the `defaultStdenv` attribute as well as the `bootStdenv` parameter. Before, the final bootstrapping stage's stdenv was provided by all-packages, which was iterating multiple times over the top-level/default.nix expression, and non-final bootstrapping stages' stdenvs were explicitly specified with the `bootStdenv` parameter. Now, all stages' stdenvs are specified with the `stdenv` parameter. For non-final bootstrapping stages, this is a small change---basically just rename the parameter. For the final stage, top-level/default.nix takes the chosen stdenv and makes the final stage with it. `allPackages` is used to make all bootstrapping stages, final and non-final alike. It's basically the expression of `stage.nix` (along with a few partially-applied default arguments) Note, the make-bootstrap-tools scripts are temporarily broken
This makes the flow of data easier to understand. There's little downside because the args in question are already inspected by the stdenvs. cross-compiling in particular is simpler because we don't need to worry about overriding the config closed over by `allPackages`.
@nbp Do you have time to re-review? Basically I went the opposite course of stripping the all the debugging hand-holds. Differences are roughly:
If you want to diff, github.com/Ericson2314/nixpkgs/tree/cross-debug is the old version, and |
This mirrors stdenv/default.nix
- Non-cross stdenvs are honest and assert that `crossSystem` is null - `crossSystem` is a mandatory argument to top-level/stage.nix, just like `system` and `platform` - Broken default arguments on stdenvs for testing are gone. - All stdenvs (but little-used stdenvNix) take the same arguments for easy testing.
ffd1f8d
to
e23afa6
Compare
- The darwin test can now force the use of the freshly-booted darwin stdenv - The linux test now passes enough dummy arguments This may make debugging harder, if so, check out NixOS#20889
OK, so its been many months. @nbp told me he doesn't have time to review again for a while, but this is now exactly in the spirit of his last review. There was only one part of his review I had reservations about, pertaining to my last commit. While removing the debugging aids (default arguments never used normally) does reduce complexity, it also may make debugging harder, and stdenvs are already pain enough. To alleviate that, I rebased my old final commit on top of this and opened #20889 with it. I really want to see this merged, so my hope is that other PR can be merged by anyone who is adversely impacted by the removal of debugging aids in this. So, my plan is to wait a day or two and then merge this myself. Speak now, or |
New summery
Ok, this is last general purpose cleanup from me before going into the nitty-gritty details of cross compiling. The basic issue is despite my changes so far almost but not quite break the top-level stdenv cycle. This breaks the cycle, and cuts down on the partial application magic that can make it hard to figure out where an argument comes from.
This PR has been tested with my usual gist
nix-instantiate --eval -E 'import (builtins.fetchTarball https://gist.github.com/Ericson2314/fc745290db68b20235bdc457961b3658/archive/master.tar.gz) {}' -A testsPass
now extended to also check ghc's linux and darwin hashes in addition to cross + custom stdenv stuff. It should also pass travis--I ran the nox script locally.
In the process of cleaning up the default args used for testing, I added a builtins trace as they should never be triggered in production.
Original Post
This grew out of the, ahem, tamer of my ideas in #10874. The basic idea is that
top-level/default.nix
is now only responsible for building a single bootstrapping phase, and since stdenvs control the bootstrapping, they are solely responsible for callingtop-level/default.nix
(well, with the exception of the final phase, since that isn't composed in a stdenv-specific manner). Additionally config'sreplaceStdenv
and the cross stdenv are now composed more like other stdenvs than the ad-hoc way they were before.While this doesn't really solve any problem on its own, it should lay a better foundation for feature work. See the comments in #14965 for how the phasing for the cross stdenv helps for example. Also, some of the more ambitious proposals of #10874 should similarly be assisted.
I tested (a few arbitrary) package paths stayed the same on Nixos. I verified the same for cross-compiling before I rebased onto the newly-bumped nixos-unstable, but post-rebase, cross-compiling seems to be broken for reasons unrelated to this.
The biggest problem with this is now the pkg hierarchy makes less sense:
top-level
isn't really the top-level and theirs a few more wrapper files. I'd gladly move things around (phase-top-level
?) but not sure what the best way forward is.I view this the spiritual successor of #14000, and as such, I tried to mimic @nbp's method of breaking this up into little commits to make it easier to review.
CC @vcunat @Mathnerd314 @nbp
[PS: @nbp while you weren't involved in the #10874 discussion, this (hopefully just syntactically) conflicts a fair amount with @10874 hence the CC.]