* What is wrong with these few lines of guile code?
@ 2017-10-31 13:41 Hartmut Goebel
2017-10-31 14:02 ` Mike
2017-10-31 17:50 ` Christopher Baines
0 siblings, 2 replies; 6+ messages in thread
From: Hartmut Goebel @ 2017-10-31 13:41 UTC (permalink / raw)
To: guix-devel
Hallo,
i replaced the code of gnu/system/install.scm(make-cow-store target) [1]
with the code below. Now when running this code (which is triggered by
"herd start cow-store /mnt" in the installation-os)|I get this error:
|
herd: exception caught while executing 'start' on service 'cow-store':
ERROR: Unbound variable: gexp
What is wrong with this code? (Parentheses are matching, of course :-)
[1]
https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/install.scm#n70
(define (make-cow-store target)
"Return a gexp that makes the store copy-on-write, using TARGET as the
backing store. This is useful when TARGET is on a hard disk, whereas the
current store is on a RAM disk."
(define (set-store-permissions directory)
;; Set the right perms on DIRECTORY to use it as the store.
#~(begin
(chown #$directory 0 30000) ;use the fixed
'guixbuild' GID
(chmod #$directory #o1775)))
#~(begin
;; Bind-mount TARGET's /tmp in case we need space to build things.
(let ((tmpdir (string-append #$target "/tmp")))
(mkdir-p tmpdir)
(mount tmpdir "/tmp" "none" MS_BIND))
(let* ((rw-dir (string-append target #$%backing-directory))
;; FIXME: calculate work-dir from backing-directory:
;; normpath(backing-directory + "../.overlayfs-workdir")
(work-dir (string-append target "/tmp/.overlayfs-workdir")))
(mkdir-p rw-dir)
(mkdir-p work-dir)
(mkdir-p "/.rw-store")
#$(set-store-permissions #~rw-dir)
#$(set-store-permissions "/.rw-store")
;; Mount the overlay, then atomically make it the store.
(mount "none" "/.rw-store" "overlay"
(string-append "lowerdir=" #$(%store-prefix)
"upperdir=" #~rw-dir ","
"workdir=" #~work-dir))
(mount "/.rw-store" #$(%store-prefix) "" MS_MOVE)
(rmdir "/.rw-store"))))
--
Regards
Hartmut Goebel
| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is wrong with these few lines of guile code?
2017-10-31 13:41 What is wrong with these few lines of guile code? Hartmut Goebel
@ 2017-10-31 14:02 ` Mike
2017-10-31 17:50 ` Christopher Baines
1 sibling, 0 replies; 6+ messages in thread
From: Mike @ 2017-10-31 14:02 UTC (permalink / raw)
To: guix-devel
On 10/31/2017 09:41 AM, Hartmut Goebel wrote:
> Hallo,
>
> i replaced the code of gnu/system/install.scm(make-cow-store target) [1]
> with the code below. Now when running this code (which is triggered by
> "herd start cow-store /mnt" in the installation-os)|I get this error:
> |
>
> herd: exception caught while executing 'start' on service 'cow-store':
> ERROR: Unbound variable: gexp
>
> What is wrong with this code? (Parentheses are matching, of course :-)
I'm a Scheme novice, but is your use of 'target' instead of '#$target'
further down the definition body a problem? Or is that a proper use of
Guile macros?
-Mike
> [1]
> https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/install.scm#n70
>
> (define (make-cow-store target)
> "Return a gexp that makes the store copy-on-write, using TARGET as the
> backing store. This is useful when TARGET is on a hard disk, whereas the
> current store is on a RAM disk."
>
> (define (set-store-permissions directory)
> ;; Set the right perms on DIRECTORY to use it as the store.
> #~(begin
> (chown #$directory 0 30000) ;use the fixed
> 'guixbuild' GID
> (chmod #$directory #o1775)))
>
> #~(begin
> ;; Bind-mount TARGET's /tmp in case we need space to build things.
> (let ((tmpdir (string-append #$target "/tmp")))
> (mkdir-p tmpdir)
> (mount tmpdir "/tmp" "none" MS_BIND))
>
> (let* ((rw-dir (string-append target #$%backing-directory))
> ;; FIXME: calculate work-dir from backing-directory:
> ;; normpath(backing-directory + "../.overlayfs-workdir")
> (work-dir (string-append target "/tmp/.overlayfs-workdir")))
> (mkdir-p rw-dir)
> (mkdir-p work-dir)
> (mkdir-p "/.rw-store")
> #$(set-store-permissions #~rw-dir)
> #$(set-store-permissions "/.rw-store")
>
> ;; Mount the overlay, then atomically make it the store.
> (mount "none" "/.rw-store" "overlay"
> (string-append "lowerdir=" #$(%store-prefix)
> "upperdir=" #~rw-dir ","
> "workdir=" #~work-dir))
> (mount "/.rw-store" #$(%store-prefix) "" MS_MOVE)
> (rmdir "/.rw-store"))))
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is wrong with these few lines of guile code?
2017-10-31 13:41 What is wrong with these few lines of guile code? Hartmut Goebel
2017-10-31 14:02 ` Mike
@ 2017-10-31 17:50 ` Christopher Baines
2017-11-03 14:34 ` Hartmut Goebel
1 sibling, 1 reply; 6+ messages in thread
From: Christopher Baines @ 2017-10-31 17:50 UTC (permalink / raw)
To: Hartmut Goebel; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]
On Tue, 31 Oct 2017 14:41:46 +0100
Hartmut Goebel <h.goebel@crazy-compilers.com> wrote:
> Hallo,
>
> i replaced the code of gnu/system/install.scm(make-cow-store target) [1]
> with the code below. Now when running this code (which is triggered by
> "herd start cow-store /mnt" in the installation-os)|I get this error:
> |
>
> herd: exception caught while executing 'start' on service 'cow-store':
> ERROR: Unbound variable: gexp
>
> What is wrong with this code? (Parentheses are matching, of course :-)
...
> ;; Mount the overlay, then atomically make it the store.
> (mount "none" "/.rw-store" "overlay"
> (string-append "lowerdir=" #$(%store-prefix)
> "upperdir=" #~rw-dir ","
> "workdir=" #~work-dir))
Here, as rw-dir and work-dir are just inside the gexp, you don't need
to ungexp, or gexp them (as is being done here), so I'd remove the #~.
This matches the error you're getting, as #~ is short for (gexp ...) as
I understand it.
> (mount "/.rw-store" #$(%store-prefix) "" MS_MOVE)
> (rmdir "/.rw-store"))))
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 963 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is wrong with these few lines of guile code?
2017-10-31 17:50 ` Christopher Baines
@ 2017-11-03 14:34 ` Hartmut Goebel
2017-11-03 16:09 ` Ricardo Wurmus
2017-11-04 11:46 ` Pjotr Prins
0 siblings, 2 replies; 6+ messages in thread
From: Hartmut Goebel @ 2017-11-03 14:34 UTC (permalink / raw)
To: Christopher Baines; +Cc: guix-devel
Am 31.10.2017 um 18:50 schrieb Christopher Baines:
> This matches the error you're getting, as #~ is short for (gexp ...) as
> I understand it.
Thanks you, this did the trick :-) Although this reminds my on the magic
signs in perl :-(
From the "Zen of Python":
Explicit is better than implicit.
Readability counts.
--
Regards
Hartmut Goebel
| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is wrong with these few lines of guile code?
2017-11-03 14:34 ` Hartmut Goebel
@ 2017-11-03 16:09 ` Ricardo Wurmus
2017-11-04 11:46 ` Pjotr Prins
1 sibling, 0 replies; 6+ messages in thread
From: Ricardo Wurmus @ 2017-11-03 16:09 UTC (permalink / raw)
To: Hartmut Goebel; +Cc: guix-devel
Hartmut Goebel <h.goebel@crazy-compilers.com> writes:
> Am 31.10.2017 um 18:50 schrieb Christopher Baines:
>> This matches the error you're getting, as #~ is short for (gexp ...) as
>> I understand it.
>
> Thanks you, this did the trick :-) Although this reminds my on the magic
> signs in perl :-(
It’s a reader macro. They all start with # and are followed by a
character. You can install a reader macro to transform the expression
as it is read. For example, I used a reader macro in earlier versions
of my operating system configuration so that I can avoid wrapping file
contents in string quotes.
Reader macros are frowned upon when they are added for no good reason.
A reader macro is used here, because to Schemers it comes natural to use
syntax like “`” (quasiquote), “'” (quote), “,” (unquote), and “,@”
(unquote-splicing). Gexps are analogous to quoted S-expressions, so
(gexp …) “quotes” and (ungexp …) unquotes, etc. The reader extensions
positively affect readability as they strip off one layer of
parenthetical expressions, at the cost of extra syntax.
For more information on the thinking behind Gexps and their relation to
quasiquotation see Ludo’s excellent paper “Code Staging in GNU Guix”,
available at <https://hal.inria.fr/hal-01580582/en>.
--
Ricardo
GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
https://elephly.net
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is wrong with these few lines of guile code?
2017-11-03 14:34 ` Hartmut Goebel
2017-11-03 16:09 ` Ricardo Wurmus
@ 2017-11-04 11:46 ` Pjotr Prins
1 sibling, 0 replies; 6+ messages in thread
From: Pjotr Prins @ 2017-11-04 11:46 UTC (permalink / raw)
To: Hartmut Goebel; +Cc: guix-devel
On Fri, Nov 03, 2017 at 03:34:23PM +0100, Hartmut Goebel wrote:
> Am 31.10.2017 um 18:50 schrieb Christopher Baines:
> > This matches the error you're getting, as #~ is short for (gexp ...) as
> > I understand it.
>
> Thanks you, this did the trick :-) Although this reminds my on the magic
> signs in perl :-(
It is not magic (unlike Perl). In Guile you can use almost any
character to give something a name. This does not come natural to us
non-Lisp programmers. The #~ is merely an agreed convention to name
certain macros. And macros, essentially, are syntax expansions. No
magic. Though macros can do magic, but that is a different story ;)
Pj.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-11-04 11:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-31 13:41 What is wrong with these few lines of guile code? Hartmut Goebel
2017-10-31 14:02 ` Mike
2017-10-31 17:50 ` Christopher Baines
2017-11-03 14:34 ` Hartmut Goebel
2017-11-03 16:09 ` Ricardo Wurmus
2017-11-04 11:46 ` Pjotr Prins
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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).