nixpkgs: Allow passing {host,build}Platform directly + Nixpkgs fn docs#324614
nixpkgs: Allow passing {host,build}Platform directly + Nixpkgs fn docs#324614
{host,build}Platform directly + Nixpkgs fn docs#324614Conversation
doc/using/as-a-function.chapter.md
Outdated
There was a problem hiding this comment.
Is it intended that this manual link directly targets a version whilst all others in this document target latest? That kind of looks like being unintentional on first view.
There was a problem hiding this comment.
Good catch!
I've changed it to latest and gathered up the remaining URLs.
de0c0b6 to
d159fca
Compare
|
I am not sure where the inconsistency comes from here directly, but possibly its something that could be addressed. when defining the hostPlatform in the configuration one has to do like nixpkgs.hostPlatform.system = "x86_64-linux";But one can also be more specific like nixpkgs.hostPlatform = { system = "x86_64-linux"; gcc.arch = "x86-64-v3"; }; (edit: or is that no longer a thing? havent used it for a while?) whilst we are here passing And we should possibly try to avoid to use the same "word" for different things/types to no increase the already confusing situation about Might it be reasonable to pass the same type that is used when defining it in the config itself? |
|
A string is shorthand for a Shorthand notations do add complexity, I agree, but most users the string notation is more than sufficient.
What do you mean by "the config", the NixOS config? I think it already does that. |
edit: okay i saw in the tests, that there is also a |
|
Don't worry about it. Sometimes we don't know what we don't know. Can't overthink all the time. |
…ystem
This new interface has already been applied successfully in NixOS.
`nixos-generate-hardware` has been generating the "default" hostPlatform
in `hardware-configuration.nix` for over a year now [without much trouble],
and with the benefit of not having to specify `system` (or similar) in
`nixosSystem` anymore.
Furthermore, the `hostPlatform` option is always defined and reliably
produces the host platform for users who don't use the legacy options.
This is in contrast to `nixpkgs.crossSystem`, which is usually not
even defined, and `nixpkgs.localSystem` which is usually the wrong
platform to refer to in a config file.
Ideally we'd clean up the `nixpkgs.{system,localSystem,crossSystem}`
options to reduce complexity and confusion. But the interface in
Nixpkgs is still based on the old terminology and behavior.
By introducing these parameters also in Nixpkgs, the users' experience
with NixOS carries over to Nixpkgs as well.
Further simplifications in the code base are now possible, specifically
- stage.nix and related files still work with {local,cross}System,
and have logic like
${if stdenv.hostPlatform == stdenv.buildPlatform
then "localSystem" else "crossSystem"} = <...>
... which is really just
hostPlatform = <...>
This can now be simplified by refactoring this code to work with
{host,build}Platform variables instead.
- NixOS can forward its platform options directly to its Nixpkgs call.
This pays off when the `*[sS]ystem` options are removed.
[without much trouble]: #237218
d8c80cb to
4fd048a
Compare
Description of changes
hostPlatformandbuildPlatformas parameters to the Nixpkgs function.This new interface has already been applied successfully in NixOS.
nixos-generate-hardwarehas been generating the "default" hostPlatform inhardware-configuration.nixfor over a year now without much trouble, and with the benefit of not having to specifysystem(or similar) innixosSystemanymore.Furthermore, the
hostPlatformoption is always defined and reliably produces the host platform for users who don't use the legacy options. This is in contrast tonixpkgs.crossSystem, which is usually not even defined, andnixpkgs.localSystemwhich is usually the wrong platform to refer to in a config file.Ideally we'd clean up the
nixpkgs.{system,localSystem,crossSystem}options to reduce complexity and confusion. But the interface in Nixpkgs is still based on the old terminology and behavior. By introducing these parameters also in Nixpkgs, the users' experience with NixOS carries over to Nixpkgs as well.Further simplifications in the code base are now possible, specifically
stage.nix and related files still work with {local,cross}System, and have logic like
... which is really just
This can now be simplified by refactoring this code to work with {host,build}Platform variables instead.
NixOS can forward its platform options directly to its Nixpkgs call. This pays off when the
*[sS]ystemoptions are removed.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.