-
Notifications
You must be signed in to change notification settings - Fork 96
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
Serialize function(or any other thunk) to file for later evaluation #635
Comments
Hey, thank you for your request. If possible, could you please explain even quickly what exactly doesn't work about |
From what I understand, this issue arises in setups that match the following description:
This happens with NixOS:
This also happens with some GitOps Kubernetes setups:
In my opinion, it's a bit early to think about this issue, and I am not sure that Nickel can or should offer anything to make this easier: this is strictly dependent on the deployment method of the configurations, which should be out of scope of Nickel. |
Oh, thanks I forgot about this, way too much stuff happening. Anyway, @silverraven691 summarized it well. I think that if i was able to do something akin to (nix syntax) let
knownAtBuildTime = "hello";
val =
{
a = knownAtBuildTime;
b = password; # missing at build time, so the thunk right after `val` cant be evaluated without an error
};
in builtins.serialize val # which returns a serialized thunk with all available references already substituted in, those refs which are not yet known, are deferred to a second, runtime eval pass Thats the idea i had, but maybe it would be better handled with a specialized json thingie encoding these "holes" in json and mechanisms to get them. The downside is that you cant perform arbitrary nickel manipulation at runtime. |
I suppose that just like Dhall supports serializing functions to Nix, Nickel could support serializing functions to Nix, Dhall and even Nickel itself -- that may be impossible though. |
Thanks for the explanations. Then you probably need to serialize "closures", that is functions that capture some already partially evaluated environment. This may not be trivial to do efficiently, but possible I guess. But this serialization also sounds a bit like an XY problem. More precisely, I think effects would rather embody this notion of multi-stage evaluation in Nickel: at least, this is the reason why they were discussed to begin with. Here, I would see We discussed this kind of issues orally some time ago with @thufschmitt, and thought about having the interpreter handling partially evaluated terms with "holes" or "deferred" computations inside corresponding to effects like this, but this needs a lot more thinking and design to be turned into something concrete. |
Might be related: #948 |
Is your feature request related to a problem? Please describe.
In my opinion a substantial problem of Nix is that some parts of your configuration are rather runtime dependent. You may want to read a password from some file, at runtime. Or you may need to pull in the address of a webserver from a database.
Describe the solution you'd like
The ability to take any value, either a function with explicit arguments or a thunk (side effects) and serialize it into a file. Binary or not, doesnt really matter. Then to be able to evaluate it at a later date.
Describe alternatives you've considered
password
andpasswordFile
, it's clear that what we have in Nix doesn't work. And separating the "build" and "runtime" phases of evaluation more explicitly also poses issues as passing data from "build" to "runtime" is extremely cumbersome.The text was updated successfully, but these errors were encountered: