On 2024-05-16 17:57, Giovanni Biscuolo wrote: > Hello, > > sorry for the very guile-absolute-beginner question, but I'd like to use > a declared variable in a plain-file object, so I can write something > like in this pseudo-code snippet: > > --8<---------------cut here---------------start------------->8--- > > (define variable1 "var1-value") > (define variable2 "var2-value") > > [...] > > (define %my-file-object > ,(plain-file "something.conf" " > # This is an example configuration file > > attribute1 =" variable1 " > > attribute2 =" variable2 " > > ")) > > --8<---------------cut here---------------end--------------->8--- > > and obtain a "something.conf" file like this: > > --8<---------------cut here---------------start------------->8--- > # This is an example configuration file > > attribute1 = var1-value > > attribute2 = var2-value > > --8<---------------cut here---------------end--------------->8--- > > how can I do, please? > > Thanks, Gio'
You probably want a G-expression. Short untested example: (define name "Giovanni") (define greeting-gexp #~(begin (with-output-to-file #$output (lambda _ (write (string-append "Hello, " #$name "!")))))) You should be able to use greeting-gexp in place of %my-file-object. I highly recommend reading the relevant docs in Guix's info pages. Online version: https://guix.gnu.org/manual/en/html_node/G_002dExpressions.html Related blog post: https://guix.gnu.org/en/blog/2023/dissecting-guix-part-3-g-expressions/