-
-
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: Allow passing {host,build}Platform
directly + Nixpkgs fn docs
#324614
base: master
Are you sure you want to change the base?
Conversation
doc/using/as-a-function.chapter.md
Outdated
@@ -0,0 +1,147 @@ | |||
# Nixpkgs as a Function {#sec-nixpkgs-function} | |||
|
|||
Depending on how you use Nixpkgs, you may interact with it as a [Nix function](https://nix.dev/manual/nix/2.23/language/constructs.html#functions). |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
hostPlatform
andbuildPlatform
as parameters to the Nixpkgs function.This new interface has already been applied successfully in NixOS.
nixos-generate-hardware
has been generating the "default" hostPlatform inhardware-configuration.nix
for over a year now without much trouble, and with the benefit of not having to specifysystem
(or similar) innixosSystem
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 tonixpkgs.crossSystem
, which is usually not even defined, andnixpkgs.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
... 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]ystem
options are removed.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-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.