unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Tropin <andrew@trop.in>
To: "Maxime Devos" <maximedevos@telenet.be>,
	"Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org, Xinglu Chen <public@yoctocell.xyz>,
	guix-maintainers@gnu.org
Subject: Re: Return back original implementation for text-config serialization
Date: Sun, 13 Feb 2022 17:09:37 +0300	[thread overview]
Message-ID: <87k0dyoo2m.fsf@trop.in> (raw)
In-Reply-To: <95f26136ec9babaf6b6544ca169495eb70953249.camel@telenet.be>

[-- Attachment #1: Type: text/plain, Size: 6383 bytes --]

On 2022-02-05 12:34, Maxime Devos wrote:

> Andrew Tropin schreef op wo 26-01-2022 om 11:36 [+0300]:
>> In addition to the problems I mentioned above:
>> 
>> 1. Mixed usage of two configuration languages (nginx-conf and lisp).
>> 2. Having a string, which should be properly escaped (luckily for
>> this
>> example it's not a problem).
>
> Mixing two configuration languages can be avoided by supporting
> everything with records.
>

I suppose it will lead to a huge maintenance burden, but it's just a
guess.

>> 
>> we also:
>> 
>> 3. Have to implement our own templating engine (using format function
>> in this case) to share the values from guile with the config.
>
> This seems to be the same for this list based configuration system
> and record based configuraiton system; for the nginx example you gave,
> all these lists with parentheses need to turned into something with
> brackets that nginx understands anyway.
>
>> 4.1. Don't know where extra-content goes. (It goes to http section
>> not the
>> end of the file, so we have to start with "}" to get a correct
>> configuration).
>
> Can be solved by adding missing options to the Guix service definition
> (and documentation) when the need arises.
>
>> 4.2. Don't control where it must be placed. (Can be important in
>> other
>> use cases, which I can share if needed).
>
> Likewise.
>
>> 5. Have inconsistent implementation of extra-config, extra-content,
>> raw-lines
>> and other escape hatches (We need to learn it everytime we write a
>> new
>> service configuration).
>
> Likewise.
>
> Also, the mapping of upstream configuration files to lists in Guix
> seems far from obvious to me: in https://issues.guix.gnu.org/52698,
> how am I supposed to know that 'us,ru' must be a symbol, why isn't
> it a string?

It's quite obvious.  ((layout us,ru)) will be translated to
`layout us,ru` and this is what expected by man 5 sway-input.

Strings and their purpose are covered below.

> If one of the strings for some property includes a special character
> from the configuration language (say, '$'), should it be escaped in
> Guix ((bindsym ... "[class=\"$100 dollars\"]" ...) or (bindsym
> ... "[class=\"\\$100 dollars\""]""))?

Not sure about this question.  If this character have to be escaped in
the target configuration, "[class=\"\\$100 dollars\"]" will produce what
you need: [class="\$100 dollars"].

According to string serialization: In first iteration I made a soft
escape hatch (all strings are serialized to its values), it made it
possible to express this CRITERIA (man 5 sway) statement you menshioned
above.

I added a proper gexp support a little later, but the example with
string already was in use.  Currently it should be done this way:

`((bindsym ... ,#~"[class=\"$100 dollars\"]" ...))

And probably strings must be serialized to quoted values now, if I
make home-sway v2 it will be done this way.

I didn't make a CRITERIA to be a part of a grammar because:

1. I needed a working prototype fast to move forward on Guix Home
itself.
2. I encountered a bug in guile compiler and already spend a lot of time
on home-sway service, after I finally localized it and it was fixed by
Andy.  I decided to postpone further improvements of sway service for
later times.

> Why (bindsym ... "[class=\"foo\"]") instead of
> (bindsym ... (= class "foo"))?

This one is good.  As you see I didn't made a CRITERIA a part of the
grammar, so there is no proper way to express it without escape hatch,
however home-sway v2 can be done slightly different, more on that in the
reply to lists and vectors question.

>
> Why (bindsym ... exec emacsclient ...) and not
> (bindsym ... exec (file-append emacs "/bin/emacsclient) ...)?
> How am I supposed to know whether emacs is in the path or not,
> and if it is, is this merely an implementation detail?

In most cases it should be
`((bindsym ... exec ,(file-append emacs "/bin/emacsclient") ...))

You are right.

>
> How would  I know if it's (bindsym ... exec emacsclient -c --eval
> "'(eshell)'") or (bindsym ... "exec emacsclient -c --eval
> \"'(eshell)'\"")?  Since the idea is to keep as close to the
> configuration language as possible, shouldn't it be the second?

exec is a part of configuration grammar and it should not be quoted.
Command itself doesn't have to be quoted too, but probably can be if you
want:

`((bindsym ... exec ,#~"'emacsclient -c --eval \"\\'(eshell)\\'\"'"))

>
> Why lists and not vectors?

This one is good as well, back in the day I was implmenting home-sway
service I didn't have much experience with guile vectors.  I tried not
to be any fancy and used lists for both sequential and associative data
structures.

Vectors can be a good match, also it will be easier to make a CRITERIA
to be a part of a grammar and be used without escape hatch.  In the
combination of proper string serialization it will look like:

--8<---------------cut here---------------start------------->8---
`#(#(bindsym $mod+o ((class . "foo")
                     (tiling)
                     (window_type . toolbar))
             kill)
   #(bindsym $mod+e exec ,(file-append emacs "/bin/emacsclient"))
   ,#~"# This is comment\n# Layout related settings:"
   #(input
     #(#(xkb_layout us,ru)
       #(xkb_variant dvp,))))
--8<---------------cut here---------------end--------------->8---


and the resulting config will be:

--8<---------------cut here---------------start------------->8---

bindsym $mod+o [class="foo" tiling window_type=toolbar] kill
bindsym $mod+e exec /gnu/store/2808l07ld4hzlmlslvbqjlqrprw7f1xz-emacs/bin/emacsclient
# This is comment
# Layout related settings:
input * {
    xkb_layout us,ru
    xkb_variant dvp,
}
--8<---------------cut here---------------end--------------->8---

Sharps are a little bit noisy, but such config is a little more complete
than original one, probably easier to parse, type check and serialize.
Also, I used vectors recently for serialization to a few different type
of configuration formats and quite satisfied with them.


Thank you very much for a fresh look, the thoughtful questions and
ideas!  Only the knowledge I got thanks to this discussion is worth
starting this thread :)

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]

  reply	other threads:[~2022-02-13 14:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09  9:12 Return back original implementation for text-config serialization Andrew Tropin
2022-01-09 11:19 ` Liliana Marie Prikler
2022-01-09 17:48   ` Andrew Tropin
2022-01-09 19:44     ` Liliana Marie Prikler
2022-01-10  9:49       ` Andrew Tropin
2022-01-10 20:12         ` Liliana Marie Prikler
2022-01-12 15:05           ` Andrew Tropin
2022-01-09 12:17 ` Maxime Devos
2022-01-09 12:19 ` Maxime Devos
2022-01-09 17:59   ` Andrew Tropin
2022-01-09 19:00     ` Maxime Devos
2022-01-18 14:26 ` Ludovic Courtès
2022-01-20 13:20   ` Andrew Tropin
2022-01-21  9:30     ` Maxime Devos
2022-01-26  8:34       ` Andrew Tropin
2022-01-27  5:04         ` Maxim Cournoyer
2022-01-28 15:48           ` Andrew Tropin
2022-02-05 11:09           ` Ludovic Courtès
2022-02-13 14:14             ` Andrew Tropin
2022-01-26  8:36       ` Andrew Tropin
2022-02-05 11:34         ` Maxime Devos
2022-02-13 14:09           ` Andrew Tropin [this message]
2022-01-24 15:37     ` Ludovic Courtès
2022-01-26  9:11       ` Andrew Tropin
2022-01-26  9:21         ` Andrew Tropin
2022-02-05 14:43     ` Xinglu Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0dyoo2m.fsf@trop.in \
    --to=andrew@trop.in \
    --cc=guix-devel@gnu.org \
    --cc=guix-maintainers@gnu.org \
    --cc=ludo@gnu.org \
    --cc=maximedevos@telenet.be \
    --cc=public@yoctocell.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).