[Nix-dev] Dynamic Nix Expression Configuration
Luca Bruno
lethalman88 at gmail.com
Mon Jul 7 12:25:39 CEST 2014
On 04/07/2014 05:24, Roger Qiu wrote:
> Hello everybody,
>
> What's the best way to send configuration parameters to Nix expressions?
>
> Say I have a tool (a bash script) that dynamically generates nix
> expressions based on other runtime factors.
>
> I can use the sed tool to find/replace some properties inside the
> `x.nix` files. But this can become a mess of unmaintainable regular
> expressions.
>
> I would prefer to be able to instead write a config file with a standard
> schema, and then get Nix to import this, rather than using regular
> expressions.
>
> This could be JSON. But it could also just a be a file with a list
> inside it.
>
> I looked at the Nix Manual and found a few "builtins" functions. None of
> them seemed to be able to parse config or even a simple list in a static
> file.
>
> I saw there was a toJSON and toXML, why not fromXML or fromJSON, or even
> just fromFileList or some functions that can parse text.
>
> Barring that, perhaps is there a Nix expression parser that can be
> dynamically used?
>
What about generating a nix expression in a file instead of json in a file.
Unless you need the file to be read from another environment, just write
a nix expression.
Best regards,
More information about the nix-dev
mailing list