* doubly quoted list in gnu-build
@ 2022-12-07 6:14 jgart
2022-12-07 7:10 ` Wojtek Kosior via
0 siblings, 1 reply; 2+ messages in thread
From: jgart @ 2022-12-07 6:14 UTC (permalink / raw)
To: Guix Help
hi,
why do the configure-flags and make-flags need to be doubly quote in the gnu-build procedure?
(define* (gnu-build name inputs
#:key
guile source
(outputs '("out"))
(search-paths '())
(bootstrap-scripts %bootstrap-scripts)
(configure-flags ''()) ; here
(make-flags ''()) ; here
(out-of-source? #f)
(tests? #t)
(test-target "check")
(parallel-build? #t)
(parallel-tests? #t)
(patch-shebangs? #t)
(strip-binaries? #t)
(strip-flags %strip-flags)
(strip-directories %strip-directories)
(validate-runpath? #t)
(make-dynamic-linker-cache? #t)
(license-file-regexp %license-file-regexp)
(phases '%standard-phases)
(locale "en_US.utf8")
(system (%current-system))
(build (nix-system->gnu-triplet system))
(imported-modules %gnu-build-system-modules)
(modules %default-modules)
(substitutable? #t)
allowed-references
disallowed-references)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: doubly quoted list in gnu-build
2022-12-07 6:14 doubly quoted list in gnu-build jgart
@ 2022-12-07 7:10 ` Wojtek Kosior via
0 siblings, 0 replies; 2+ messages in thread
From: Wojtek Kosior via @ 2022-12-07 7:10 UTC (permalink / raw)
To: jgart; +Cc: Guix Help
[-- Attachment #1: Type: text/plain, Size: 3782 bytes --]
> hi,
>
> why do the configure-flags and make-flags need to be doubly quote in the gnu-build procedure?
Because later in that function they get unquoted inside a gexp using
`#$` (i.e. `ungexp`).
If you write a gexp like
> (let ((somelist '("a" "b" "c")))
> #~(display #$somelist))
on the build side it will resolve to
> (display ("a" "b" "c"))
which will of course fail because `"a"` is not a proper function. You
instead want to get this
> (display '("a" "b" "c"))
which can be achieved by e.g. double-quoting the value that gets
ungexp'd, e.g. with
> (let ((somelist ''("a" "b" "c")))
> #~(display #$somelist))
The following should also work for this list
> (let ((somelist '("a" "b" "c")))
> #~(display '#$somelist))
In many places in Guix code a function `sexp->gexp` is also used
together with `'#$`. I suspect it does some extra stuff. I don't know
what exactly.
The relevant part where those double-quoted lists are used is
> #:locale #$locale
> #:bootstrap-scripts #$bootstrap-scripts
> #:configure-flags #$(if (pair? configure-flags)
> (sexp->gexp configure-flags) ; here
> configure-flags)
> #:make-flags #$(if (pair? make-flags)
> (sexp->gexp make-flags) ; here
> make-flags)
> #:out-of-source? #$out-of-source?
> #:tests? #$tests?
> #:test-target #$test-target
When a double-quoted list is used, the "true" expression of each `if`
clause is used :)
Wojtek
-- (sig_start)
website: https://koszko.org/koszko.html
PGP: https://koszko.org/key.gpg
fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A
Meet Kraków saints! #46: saint Stanisław Papczyński
Poznaj świętych krakowskich! #46: święty Stanisław Papczyński
https://pl.wikipedia.org/wiki/Stanisław_Papczyński
-- (sig_end)
On Wed, 7 Dec 2022 00:14:51 -0600
jgart <jgart@dismail.de> wrote:
> hi,
>
> why do the configure-flags and make-flags need to be doubly quote in the gnu-build procedure?
>
> (define* (gnu-build name inputs
> #:key
> guile source
> (outputs '("out"))
> (search-paths '())
> (bootstrap-scripts %bootstrap-scripts)
> (configure-flags ''()) ; here
> (make-flags ''()) ; here
> (out-of-source? #f)
> (tests? #t)
> (test-target "check")
> (parallel-build? #t)
> (parallel-tests? #t)
> (patch-shebangs? #t)
> (strip-binaries? #t)
> (strip-flags %strip-flags)
> (strip-directories %strip-directories)
> (validate-runpath? #t)
> (make-dynamic-linker-cache? #t)
> (license-file-regexp %license-file-regexp)
> (phases '%standard-phases)
> (locale "en_US.utf8")
> (system (%current-system))
> (build (nix-system->gnu-triplet system))
> (imported-modules %gnu-build-system-modules)
> (modules %default-modules)
> (substitutable? #t)
> allowed-references
> disallowed-references)
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-07 7:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 6:14 doubly quoted list in gnu-build jgart
2022-12-07 7:10 ` Wojtek Kosior via
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).