Issue description
Of course these options serve a purpose inside the nixpkgs.nix module, to set pkgs. 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 inspecting options.nixpkgs.localSystem and options.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 the nixpkgs.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 be pkgs.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 more
So we ask people to set
- nothing at all to use
builtins.currentSystem
nixpkgs.targetSystem to set the system of the resulting NixOS
nixpkgs.hostSystem to set the system to build it on
Boils 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 being null most of the time.
Issue description
Of course these options serve a purpose inside the
nixpkgs.nixmodule, 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
systemis a legacy option that will now tend to be set to its default, builtins.currentSystem.localSystemwill only consistently represent the system where stuff was built. This is typically not useful information, yet it is used erroneously in some modules.crossSystemis meaningful, but is not always set.What can we do
Maybe
systemcan be fixed by inspectingoptions.nixpkgs.localSystemandoptions.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.nixmodule.A better solution seems to be to just treat these options as write-only. Users will set them and no other module than
nixpkgs.nixcan 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.pkgscan 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
nixpkgsoptions once moreSo we ask people to set
builtins.currentSystemnixpkgs.targetSystemto set the system of the resulting NixOSnixpkgs.hostSystemto set the system to build it onBoils down to the same thing of course, but now we have a
nixpkgs.targetSystemoption that is actually useful.I don't know how the old
nixpkgs.systemfits 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.hostSystemwhich will then supposedly fail as it should by beingnullmost of the time.