-
Notifications
You must be signed in to change notification settings - Fork 41
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
modules/nixpkgs: Make customizable & support multiple evaluations #137
base: main
Are you sure you want to change the base?
Conversation
704ac53
to
c4ea0ad
Compare
I refactored the top-level A downside of this arrangement is that to set |
c4ea0ad
to
2f84b15
Compare
Short turnaround, but I changed the |
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.
This is a big module. That's not necessarily bad, but not good for everyone. Flake-parts is meant to be an unopinionated core, so this module should, as suggested in nixpkgs.nix
, not be merged. Instead, users should choose which module to use.
That said, of course I appreciate your effort, and I would like your module to be listed on flake.parts, so here's a review.
Also, would you mind if I merge just some of your maintenance-oriented commits?
lib.nix
Outdated
# Shorthand for `types.submoduleWith`. | ||
submoduleWithModules = | ||
{ ... }@attrs: | ||
modules: | ||
types.submoduleWith (attrs // { modules = toList modules; }); |
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.
This doesn't really do anything new, but it does make flake-parts a dialect of the module system. I would like to avoid that.
All functions in this library should either be polyfills of Nixpkgs lib, or domain-specific helpers (e.g. supporting perSystem).
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.
Done. I should submit this up to Nixpkgs for review soon, I think it fits in well as an alternative to submodule
/ deferredModule
that offers finer control. It's still defined as an internal local in nixpkgs.nix
because otherwise the indentation gets really intense.
modules/nixpkgs.nix
Outdated
options = { | ||
# mkSubmoduleOptions can't be used here due to `shorthandOnlyDefinesConfig`. | ||
settings = mkSubmoduleOptionsWithShorthand { | ||
crossSystem = mkOption { |
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 would recommend to switch to the new hostPlatform
+ optional buildPlatform
combination that NixOS provides. I haven't got around to propagating that to the Nixpkgs function arguments, but the user interface here would already benefit from it.
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.
Sure thing. I forgot that a system
double is exposed by platform.system
too. I'm imagining it's okay to apply = lib.systems.elaborate;
here, as with NixOS nixpkgs.hostPlatform
?
If that's the case, would the current Nixpkgs module be moved to
If you want to start merging maintenance comments now, go for it. I tacked on a few more commits extending the As a side question, when do you recommend manually specifying |
2f84b15
to
de9fa76
Compare
@roberth Reading divnix/call-flake@5828e08, it looks like both |
de9fa76
to
6838984
Compare
eb686c9
to
d695f1a
Compare
This infinite recursion first appeared in 2cde01e.
d695f1a
to
788b0bc
Compare
I would highly appreciate review & comments on this. My main concerns going in were, roughly in order of priority:
self.overlays.default
for use inpkgs
config.allowUnfree
for use in NixOS or packages that require unfreelocalSystem
)I feel like this patch's design addresses all of those concerns, with a relatively simple module to boot. I think the code is alright, but it could very well be better. I'm not confident.
Here's an example flake declaring its packages in a Nixpkgs overlay & consuming them via
pkgs
:All that was necessary to integrate
self.overlays.default
intopkgs
was a simple value for thenixpkgs.overlays
option, and these derivations frompkgs
can be directly used forperSystem.packages
.Let's say that the author also wants an easy way to test building their package against the latest NixOS stable, without switching
inputs.nixpkgs.url
or using--override-input nixpkgs <flake-url>
.Only 3 lines added and 1 line changed, which I'm pretty happy with.
nixpkgs.evals
has now been introduced, but the flake author knows that they're dealing with multiple Nixpkgs instantiations by this point, and they don't have to write Nixpkgs application boilerplate to do it. This example is contrived, but you can imagine this approach instead used so that a development NixOS machine can be using unstable Nixpkgs while a server is using stable Nixpkgs, maybe plucking a package or two from the same unstable as the development machine.I'm imagining a lot of
nixpkgs.config
usage will just look likeconfig.nixpkgs.config.allowUnstable = true;
. I haven't bothered replicating the Nixpkgs config module here because I think it'd be more bother than it's worth. As such, values ofnixpkgs.config
aretypes.raw
and they'll eagerly fail to merge. This may be annoying for flake authors but it prevents unintended merge behavior.By utilizing
perSystem
, all Nixpkgs evaluations can be shared between modules and thenixpkgs
andpkgs
module arguments won't force extra evaluations (to my knowledge). I don't know ifperSystem.nixpkgs.evals.<name>.output
should be hidden / internal, but I leaned towards public for now, partially so it's clear to flake authors what's going on. The documentation for this option should probably be improved to reflect that.I debated about using RFC 42–style
nixpkgs.settings
,nixpkgs.evals.<name>.settings
, &perSystem.nixpkgs.<eval>.settings
options, to be used likenixpkgs.settings.overlays
, but I don't know if the flexibility provided there justifies the extra verbosity. These options would likely be submodules withconfig._module.freeformType = types.lazyAttrsOf types.raw;
if they did exist, so that options likenixpkgs.settings.overlays
can be documented & specified to merge. This would also be more future-proof, but if Nixpkgs does accept this upstream, then that flexibility would not an issue.This patch does not configure
transposition
or otherwise expose any option config data underflake.<system>
. Sharing of values (e.g. via flake output) forconfig.nixpkgs.config
or any other option is left up to the user. I personally wouldn't mind placing some of this data in the output, but that's a larger proposal that I want to avoid here.I don't really know where
_file
is and is not inferred in flake-parts modules. Documentation on this for module authors somewhere would be nice.