-
Notifications
You must be signed in to change notification settings - Fork 280
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 support #183
Comments
Duplicate of #113 |
Is it really a duplicate? What was the authors intention? |
@adrian-gierakowski nope not a duplicate. |
Re-opened! |
Hi @stackoverflow , this is absolutely not a duplicate. I've been thinking about & need this use-case as well @alexthotse . I think this is where pkl could truly shine for large scale adoption, in addition to all other strong use-cases/migrations like k8s workflows. I would have liked to move my pkl-cli $ jpkl eval -f nix home.pkl So far based on my investigation, it could provide that as long as eval-ed pkl objects don't have "entries" that are public(maybe "hidden" entries could pass the output render checks). Objects with pkl entries also fail to be converted to json or yaml. A json/yaml can always be converted to pkl and nix however pkl environment will miss the possible pkl type declarations(as it could have for home-manager) during eval runtime unless certain nix renderer is used. Another option is to build a typed home-manager in pkl and interop will be challenging but earlier we start is better I think. Regardless a nix format is absolutely needed for I'm still learning/investigating Pkl, I already see |
@izelnakri You clearly have a bigger picture as to how Nix and Pkl can coexist with one another. This is what I had envisioned in a nutshell. Thank you for wording it out. @bioball Appreciate the re-open as this will help bring a new approach to future configuration of systems as a whole. So the question would be how can we join our efforts to make this a possibility? |
Can a pkl file export a function? |
very good question @adrian-gierakowski & I made it sort of work :) However as far as I know the current language design discourages "one-function-per-file" concept unless its generated. Pkl modules have a special function.pkl: output {
value: (n) -> n * 2 // our custom function
} main.pkl: my_function = import("function.pkl") // if you want this key ignored by output make it "hidden my_function = import()"
result = my_function.output.value.apply(22) jpkl eval -f json main.pkl
# json output will be { result: 44 } |
Functions are internal to Pkl; not exportable. I don't have any experience working with nix. But: you can write an in-language renderer to turn Pkl into nix. For example, here is a renderer that writes Pkl -> TOML: https://github.com/apple/pkl-pantry/blob/main/packages/pkl.toml/toml.pkl |
A (Edit: As @bioball said; I had choppy internet, so this posted late) |
Nix can import json (and toml) natively so if you generate, say k8s config in pkl you could import it into nix and manipulate further using nix language but things like configuration.nix or home manager config are usually functions. Not sure how one could use pkl for that and what’s the benefit over just using nix |
@adrian-gierakowski I think the benefit would be that Missing or impartial documentation for data structures has been my biggest DX issue with learning and doing anything advanced with nix/home-manager. I can see how Pkl could ease the learning curve of |
Is there gonna be nix configuration support??
The text was updated successfully, but these errors were encountered: