-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
nixpkgs.{system,localSystem,crossSystem} *values* are useless #49765
Comments
Take two of #40708 (4fe2898). That PR attempted to bidirectionally default `config.nixpkgs.system` and `config.nixpkgs.localSystem.system` to each be updated by the other. But this is not possible with the way the module system works. Divergence in certain cases in inevitable. This PR is more conservative and just has `system` default `localSystem` and `localSystem` make the final call as-is. This solves a number of issues. - `localSystem` completely overrides `system`, just like with nixpkgs proper. There is no need to specify `localSystem.system` to clobber the old system. - `config.nixpkgs.localSystem` is exactly what is passed to nixpkgs. No spooky steps. - `config.nixpkgs.localSystem` is elaborated just as nixpkgs would so that all attributes are available, not just the ones the user specified. The remaining issue is just that `config.nixpkgs.system` doesn't update based on `config.nixpkgs.localSystem.system`. It should never be referred to lest it is a bogus stale value because `config.nixpkgs.localSystem` overwrites it. Fixes #46320
I think the best move is to just replace theae usages with pkgs.buildPlatform and pkgs.hostPlatform. It would be niceto have a way to forbid these usages but i don’t know if it’s that useful for any other options. |
I think the amount of time invested in the development of this feature (cross-compilation) along with the confusion it has created related to the documentation that comes with it is too high myself. If you invest a few hundred hours in a feature, documenting it for at least 5 hours seems appropriate to me. |
Hey coretemp. I too had to look up how to use the cross compilation and I understand your frustration. In particular I find the documentation for the distinction between a system string and { system : string, config : ? } and such lacking. That said I do appreciate the amount of effort that it takes to work on a such a complicated project. I have been working on some improving some of the glue, like adding I am glad to see that you filed an issue, #49510. If there's anything else you think must be improved, please file another issue. |
@roberth yes the @coretemp I did not invent such a thing. Also, keep in mind that most of the work gone into cross compilation by me at least was reading undocumented interfaces, and then consolidating/deduplicating them. So we went from one internally inconsistent state with very little documentation to one mostly internally consistent state with some more documentation. Some things I kind of only want to document thoroughly once they are in a good enough state to not spill copious amounts of ink on a shitty interface I want flexibility to fix. All that said, I think the solution is to change the arguments to Nixpkgs itself (with some sort of back compat provision) and then change the NixOS interface accordingly. |
@matthewbauer I recall using |
It shouldn't in NixOS modules unless something very weird is going on. You have to use the final "pkgs" - not config.nipkgs.pkgs though. I've found a couple usages of localSystem but it seems pretty rare (dysnomia and containers). Were there any others? |
Oh, ok. Well that would be great to use |
@Ericson2314 OK, thank you for that clarification. |
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
We still pass around |
just dropping a thought that was floating around in my brain: |
I marked this as stale due to inactivity. → More info |
Still important |
I marked this as stale due to inactivity. → More info |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/enabling-march-and-mtune-for-kernel-builds/20395/1 |
Done in while the This should become the new way of doing things in NixOS, but I'm taking a very conservative approach so as to validate the solution and to avoid any unnecessary disruption. Nixpkgs would also benefit from such a change, allowing |
I'm kind of confused why we started using |
Fwiw, Nonetheless your criticism applies. In retrospect, I should have started with Nixpkgs' parameters first, and make the NixOS change after. |
Thanks for the context! I think i'll add a note in the code just to clarify! |
Ready for review: This lets us further diminish the role of these mediocre variables and nudges users towards the consistently available ones. |
Issue description
Of course these options serve a purpose inside the
nixpkgs.nix
module, to setpkgs
. However, these options tend to be used elsewhere, even though they are hard to use, leading to problems with cross compiled NixOS.For this reason, I suggest that we make these config values unusable by providing an appropriate error message showing what else to do.
Why aren't they useful
system
is a legacy option that will now tend to be set to its default, builtins.currentSystem.localSystem
will only consistently represent the system where stuff was built. This is typically not useful information, yet it is used erroneously in some modules.crossSystem
is meaningful, but is not always set.What can we do
Maybe
system
can be fixed by inspectingoptions.nixpkgs.localSystem
andoptions.nixpkgs.crossSystem
. However, it is hard to reason about all possible uses of the module system and this feels like laying down a minefield for further changes to thenixpkgs.nix
module.A better solution seems to be to just treat these options as write-only. Users will set them and no other module than
nixpkgs.nix
can use its value. We can then, by means of an error message, direct module authors to the right value. This should probably bepkgs.targetPlatform
. I don't think NixOS needs to provide its own way to determine its platform.pkgs
can do that for NixOS just fine.How to implement
Simply set all three options to
private
...The module system does not yet have that option option, but it's almost there in #49766
Alternatives
Overhaul the
nixpkgs
options once moreSo we ask people to set
builtins.currentSystem
nixpkgs.targetSystem
to set the system of the resulting NixOSnixpkgs.hostSystem
to set the system to build it onBoils down to the same thing of course, but now we have a
nixpkgs.targetSystem
option that is actually useful.I don't know how the old
nixpkgs.system
fits into this.This means we'll need to reevaluate all the corner cases once more.
It will probably still confuse people and cause them to use
nixpkgs.hostSystem
which will then supposedly fail as it should by beingnull
most of the time.The text was updated successfully, but these errors were encountered: