Skip to content

nixpkgs.{system,localSystem,crossSystem} *values* are useless #49765

@roberth

Description

@roberth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: enhancementAdd something new or improve an existing system.2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions