-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Configurable derivations #6583
base: master
Are you sure you want to change the base?
Configurable derivations #6583
Conversation
Intriguing :) Mutually exclusive or mix-in?I think the usability would be better of configurability was a mix-in interface rather than an entirely different Overriding other parts of the flakeIt'd also be more powerful to have this at the level of the flake fixpoint. This would allow the user to override a package in A bonus feature would be to make these configurations first class, so they can be interpreted by the frameworks that build on Flakes, allowing the configuration of framework-specific concepts. This could be done by adding, say,
|
A bit off-topic, but I feel that
I think this would require a change to the flakes spec, since it would mean that the flake |
In this case it is slightly better. It exists on a rather cheap value that does not require any options to be computed; not even imports to be resolved. Now this is going to look like a party trick, but it actually demonstrates that this extension mechanism is lazier than the usual
The reason why this mechanism is lazy is that unlike most overrides, the returned set off attribute names does not depend on the actual values. It is always At first, I only intended
While backcompat is generally nice, this should be no issue as flakes are experimental. I'm all for it though. OT: A solution for #3843 can probably also be backwards compatible, but after accumulating a bunch of backcompat, it seems like a good idea to clear most of that out, before finalizing the RFC that specifies the first non-experimental flakes release. |
We've talked about generalizing this from output attributes to all outputs, but it could be generalized further to encompass the inputs as well. Doing so will solve NixOS/nixpkgs#166220, or I guess this PR already does that, but only for the specific case of the At that point, we might consider setting |
Flake configurability is more of a flakes 2.0 feature. It shouldn't delay Nix 3.0. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-31/19481/1 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nixos-configuration-nix-with-argument/19653/4 |
It would be cool if it accepted a JSON, as a file or a string. |
|
||
auto type = cursor->getAttr(state->sType)->getString(); | ||
|
||
if (type != "configurable") |
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.
Maybe it's overloading the concept, but it seems like you might expect nix describe
to also work on flakes.
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.
Overall looks pretty good! The one big picture question I have, referenced in a few of my comments: Why limit configurability to derivations? Why not configurable apps, configurable NixOS configurations, etc.?
I may pick this PR up and open a PR against your repo bringing it up to date with master and completing the work (documentation, testing, etc.)
for (const auto & [n, s] : enumerate(ss)) { | ||
if (n + 1 == ss.size()) { | ||
if (pos->children.find(s) != pos->children.end()) | ||
throw Error("definition of '%s' clashes with a previous definition", state->symbols[attr.name]); |
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.
Many tools with non-repeatable flags have the convention that the later can be used to override the former. Is there a reason we went with this approach instead?
} | ||
} | ||
|
||
std::function<Value * (const ValueTree & tree)> buildAttrs; |
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.
Might be worth a comment that this declared here for recursive calling, it surprised me.
|
||
ValueTree tree; | ||
|
||
if (cmd) { |
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 we want other things besides drvs/installables to be configurable, we should probably extract everything from here to line 713 into a separate function that can be used for other interfaces.
auto vArgs = buildAttrs(tree); | ||
|
||
auto vRes = state->allocValue(); | ||
state->callFunction(build, *vArgs, *vRes, noPos); |
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.
Shouldn't the pos
be wherever we found attr
?
} | ||
|
||
if (outputsToInstall.empty()) | ||
outputsToInstall.insert("out"); | ||
else if (type == "configurable") { |
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 we want other things besides drvs/installables to be configurable, should we allow type
to be some kind of structured value? E.g. [ "configurable" "derivation" ]
or { configurable = true; configured = "derivation"; }
or something?
The alternative is to dynamically resolve this, i.e. check type
after resolving the configurable
.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
WIP
To show all the options of a configuration:
To build a configuration:
To override the host name from the command line:
To override the system type from the command line: