Subject: Re: [bug#30355] [PATCH] services: agetty: Make tty optional and add agetty instance to base services.

From: [email-masked] (Ludovic Courtès)
Date: Tue, 13 Feb 2018 23:04:10 +0100

Heya,

Danny Milosavljevic <[email-masked]> skribis:

> I tried this now:
>
> (define (default-serial-port)
>  "Return a gexp that determines a reasonable default serial port
> to use as the tty.  This is primarily useful for headless systems."
>   #~(begin
>       ;; console=device,options
>       ;; device: can be tty0, ttyS0, lp0, ttyUSB0 (serial).
>       ;; options: BBBBPNF. P n|o|e, N number of bits,
>       ;; F flow control (r RTS)
>       (use-modules (gnu build linux-boot) (ice-9 match))

[...]

>         (match specs
>          (() #f)
>          ((spec _ ...)
>           ;; Extract device name from first spec.
>           (match (string-tokenize spec not-comma)
>            ((device-name _ ...)
>             device-name)))))))
>
> I get 
>
> $ ./pre-inst-env guix system reconfigure /etc/config.scm --fallback
> ...
> guix system: error: exception caught while executing 'eval' on service 'root':
> ERROR: Syntax error:
> unknown location: unexpected syntax in form ()

That’s a sign that the outermost ‘match’ wasn’t macro-expanded, hence
the error about ().

I got it: that’s because this gexp is spliced in a non-top-level
context.  The end result is something like:

  (let ((foo bar)
        (baz (begin (use-modules …) …)))
    …)

and the ‘use-modules’ there doesn’t have the desired effect.

The fix is to remove this ‘use-modules’ form and instead to pass the
modules as the ‘modules’ field of ‘shepherd-service’:

  (shepherd-service
    (modules '((ice-9 match) …))
    ;; …
    )

Does that work for you?

Sorry for overlooking this before!

Ludo’.