Subject: [bug#72714] [PATCH] home: services: Add 'home-sway-service-type'.

From: Arnaud Daby-Seesaram <[email-masked]>
Date: Sun, 06 Oct 2024 11:05:31 +0200

Hi Florian,

"pelzflorian (Florian Pelz)" <[email-masked]> writes:
> Thank you Arnaud for this mountain of work.
With pleasure :).

> Arnaud Daby-Seesaram <[email-masked]> writes:
>> Also: given that you assisted me quite a lot, do you want me to add a
>> line in the commit message to express that you helped me write the
>> patch
>
> Not for my review; this would be unusual.
Noted.

> Normally scm->go is probably unneeded here, because guile will find the compiled
> .go file.  However program-file seems to add --no-auto-compile.  Not
> sure now.
I do not know why the flag --no-auto-compile is passed either.

> Another more thing.  I try (bar (sway-bar)), but it prints an empty bar
> configuration to .config/sway/config.  In patch 6, you added
> no-serialization.  Did this break it?

Hmmm, I am not sure.
It is normal that `(sway-bar)' is an empty bar configuration (as all bar
fields are now optional or empty by default).  However, no configuration
block should appear in the serialised configuration in this case.

Maybe you need to pass --fresh-auto-compile to Guile when executing your
test scripts (so that it does not trust its cache).  I realised once
that when updating the module `(gnu home services sway)', my test files
would not be recompiled and old serialisation functions were used.

In v6, `serialize-bar' looks like

--8<---------------cut here---------------start------------->8---
(add-block* "bar [bar name]"
  [possibly empty list L1]
  [...]
  [possibly empty list Ln])
--8<---------------cut here---------------end--------------->8---

Thus, if all lists `Li' are empty, this should not add any line to the
configuration file.  (Except for the header "# Bar configuration.[...]",
as it is added in the main serialisation function).

In my current version of the patch, the header is also removed if
nothing follows.  Currently (on my local files), `(sway-configuration
(bar (sway-bar)))' is serialised into the following:

--8<---------------cut here---------------start------------->8---
####################################
### Auto-generated configuration ###
####################################
# DO NOT EDIT MANUALLY.

# Variables.
############
[ ... default variables ... ]

# Keybindings.
##############
[ ... default keybindings ...]

# Gestures.
###########
[ ... default gestures ...]

# Programs to execute (at startup).
###################################
[ ... default startup programs ...]
--8<---------------cut here---------------end--------------->8---

and `(sway-configuration (bar (sway-bar (hidden-state 'show))))' is
serialised into:

--8<---------------cut here---------------start------------->8---
####################################
### Auto-generated configuration ###
####################################
# DO NOT EDIT MANUALLY.

# Variables.
############
[ ... ]

# Bar configuration.
####################
bar bar0 {
    hidden_state show
}

# Keybindings.
##############
[ ... ]

# Gestures.
###########
[ ... ]

# Programs to execute (at startup).
###################################
[ ... ]
--8<---------------cut here---------------end--------------->8---

So at least, the v8 should behave as expected.

Best regards,

-- 
Arnaud