-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
nixos/nixpkgs: use type-checking to enforce buildPlatform & hostPlatform restrictions & restore hostPlatform == buildPlatform support
#379411
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
While technically this does not hurt, it does invite reading from
config.nixpkgs.xxxPlatform, which I think should be discouraged... or maybe not? I don't really knowIt just needs to be clear that only user input can be read here, nothing else.
Uh oh!
There was an error while loading. Please reload this page.
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.
IMO, so long as these options remain readable, this
applyshould remain.If we prefer to make the options write-only, then we would have something like:
Or we could silently apply
pkgs.stdenv.*Platformhere:Or we could do that, but
lib.warnabout it:With any of these approaches, we would need to manually merge
opt.buildPlatform's definitions for our internal usage, as per #376988 (comment).Uh oh!
There was an error while loading. Please reload this page.
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.
Isn't that essentially what I tried in eec2100 ?
This didn't work out.
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.
Very similar yes. The
applywould be different, but we'd still need something likerawValueor manually merging the option defs to get the un-applied value.What was the issue with that approach? I'm trying to work out if the same issues would apply to my suggestion here.
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 future reference, if anyone ever comes back to this PR.
It's not so much that the approach was wrong.. it just wasn't enough - and lead to my later change naturally.
To be able to follow through on my first try, you'd need to make sure that nobody passes elaborated systems into those options - otherwise it doesn't matter whether you apply or not, pass the rawValue on or not. If you don't add an assertion to guard against that, you will end up with really hard to debug, obscure errors in entirely different places, though.
Once you add asserts against passing elaborated systems.. you suddenly can't pass
config.nixpkgs.hostPlatformetc. onwards. But this is not only done in the nixos/nixpkgs module itself - it's done by random consumers, too. So you can't really use an undocumented, internal interface (the one I added with rawValue) to do that. You need access to the original values - and they are there, if we don'tapply. Which we don't really need to, for any reason.Uh oh!
There was an error while loading. Please reload this page.
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.
If it's helpful, I could implement this as a standalone PR without your wider changes?
That could either be merged before you re-apply your changes or it could be cherry-picked into your changes, as appropriate.
Otherwise, I can just review whatever you come up with.
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.
If you'd like to follow up on this, that would be great.
I won't push this myself for now, because as outlined in #376988 (comment)... I never really intended to work on the NixOS modules :D. I was dragged into this by accident.
The pkgs/top-level is on hold for now, because:
I would love to come back to this once the NixOS modules are ready for it - and if you can push this side, I'm more than happy to help you whereever I can.
Uh oh!
There was an error while loading. Please reload this page.
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 think it would also be great to have some kind of readonly
config.nixpkgs.<something>, which bundles all thesystem,localSystem,crossSystem,hostPlatformandbuildPlatforminputs in one place. This can then be easily passed on instead of accessingrawValuefor everything manually. This would make the linux-builder case discussed in #376988 (comment) much easier to handle (and there are quite a few more cases like that).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.
Awesome 😎
As outlined in #376988 (comment), I think this is better handled in pkgs/top-level rather than the nixpkgs module. The reason being when we want to "pass on" platform input, we usually want to do so for whichever
pkgsis actually in use; not necessarily the one being configured by the nixpkgs module.Perhaps internal un-elaborated options could be useful for avoiding the
applywithout hacks though, but still I'm uneasy about them being used externally to "pass on" the input values, for the reasons outlined above.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.
Yes, I start to see this, after you made multiple comments in various places all along the same line... ;)
This is an interesting thought, which I will have to think about a bit more!