Re: doubly quoted list in gnu-build

2022-12-06 Thread Wojtek Kosior via
> 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  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)
> 
> 




pgpokoOPYb9ah.pgp
Description: OpenPGP digital signature


doubly quoted list in gnu-build

2022-12-06 Thread jgart
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)