"(" writes: > Heya, > > On Fri Nov 4, 2022 at 8:46 AM GMT, Taiju HIGASHI wrote: >> Sorry. I did not understand what you meant by making it a gexp-compiler >> instead. Is there anything reference documents or codes? > > Guix's file-like objects are compiled into derivations using gexp-compilers, > which may be defined using the ``define-gexp-compiler'' form. These two are > equivalent: > > ;;; with procedure > > (define (foo->file-like foo) > "Turns FOO into a derivation." > (plain-file "foo" > (foo-text foo))) > > ;; this way, you need to use foo->file-like whenever you want to use > ;; foo in place of a file-like object > > (foo->file-like (foo (text "hello"))) > > ;;; with gexp compiler > > (define-gexp-compiler (foo-compiler (foo ) system target) > ;; > (lower-object > (plain-file "foo" > (foo-text foo)))) > > ;; now, a ``foo'' can be treated as a lowerable file-like object! you > ;; can put it anywhere you'd put a file-like. > (foo (text "hello")) > > So, basically, define-gexp-compiler lets you make new kinds of file-like > object from records! This is actually how computed-file, file-append, et > al are defined; see guix/gexp.scm. (Many of the gexp-compilers define both > a compiler and an expander; the compiler is a derivation to build when > the object is built, and the expander is the string to return when it's > gexped. file-append [line 680 in my checkout] is a good, clear example of > this.) > > -- ( Thank you for your kindness. I think I understand a little more now, and I will read the surrounding source code to better understand it. Thanks to you, I may be able to understand what was suggested earlier in this thread! Thanks, -- Taiju