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
nix: Put config builder into pkgs #44322
Conversation
This is such that even people not using NixOS can use it to generate the nix.conf file. See NixOS#35662
, nix, lib | ||
}: | ||
|
||
{ cfg }: |
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 cfg
here a regular attrset, or a NixOS module style option variable?
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.
If this is intended to be used outside of the module system it currently means that all config options must be defined, unlike with the module system there are no default values in this case.
Using instead { extraOptions ? '', maxJobs }:
etc. makes the arguments explicit and simplifies usage outside of nixos for options that make sense without a value.
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.
For non-NixOS users it's nicest to have the options here, along with defaults. At the same time, we shouldn't duplicate work. However, because this derivation would fail to build if certain attributes in cfg
are missing, I am of the opinion they should be added directly as parameters of this function, and thus cfg
be dropped.
Frankly, I don't mind so much how it looks. Either way works for me.
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.
I could of course (and I'd like this to be more common in nixpkgs) put the module options right next to the Nix package, such that anybody using nixpkgs can use the nice options and what comes with them (type checking, defaults, overridability, merging, etc.), the package would evaluate its own small module system. Then there wouldn't be any duplicated work either, the NixOS module can get the options from the Nix package (as a submodule). This would also work for any other package having a configuration associated with it but the options currently only being usable from NixOS.
Let me know what you think, if people agree I can do this.
Success on aarch64-linux (full log) Attempted: nix Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: nix Partial log (click to expand)
|
, nix, lib | ||
}: | ||
|
||
{ cfg }: |
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.
If cfg
stays, make it a lambda instead?
Listing all the parameters with no defaults provided seems annoying and britle… maybe load option definitions from the module and use them to provide defaults? |
Not really in favor of this, since this kind of function has basically no discoverability: there is no way to discover or use this function without reading the source code. Also, we should really stop adding things that are not packages (such as functions) to |
People who want this should probably just use the nix-daemon module directly, e.g.
or if you want to avoid evaluating all of NixOS:
|
@edolstra Good point, that works for pretty much anything from NixOS. It is a bit more cumbersome, but oen doesn't need to generate such a nix config everyday anyways. |
This is such that even people not using NixOS can use it to generate the
nix.conf file. See #35662
This doesn't change the semantics in any way, and in fact,
config.system.build.etc
is exactly the same derivation before and after this change.Ping @FRidh @7c6f434c @matthewbauer
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)