41 lines
1 KiB
Text
41 lines
1 KiB
Text
= Nix expression support
|
|
|
|
When `(nix reader)` is imported, it is possible to execute Nix code inline with
|
|
Scheme code. Simply wrap your Nix code in curly brackets:
|
|
|
|
[,scheme]
|
|
----
|
|
(write
|
|
(string-append
|
|
"Hello, Nix version"
|
|
{ builtins.nixVersion }))
|
|
----
|
|
|
|
The following values can be translated:
|
|
|
|
|===
|
|
| Nix | Scheme | Notes
|
|
|
|
| string | string | (Loses string context.)
|
|
| integer | number |
|
|
| float | number |
|
|
| boolean | boolean |
|
|
| lambda | procedure | (with single argument)
|
|
| list | vector or list | Depends on the status of `\*translate-list-as-vector*`
|
|
| attrset | alist |
|
|
| builtin | procedure |
|
|
| external value | symbol, other unknown objects |
|
|
|===
|
|
|
|
If a value in Nix is preceded with a comma, it is unquoted, similar to
|
|
`(unquote)` in a Scheme quasiquotation. If prefixed with a single quote, it is
|
|
`(quote)`-d.
|
|
|
|
[,scheme]
|
|
----
|
|
(define
|
|
(test-append foo)
|
|
(string-append "Hello, " foo))
|
|
(write
|
|
{ ,test-append "world!") })
|
|
----
|