all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Contributing Guix Home services
@ 2023-03-25 16:53 Tanguy LE CARROUR
  2023-04-04  7:45 ` Tanguy LE CARROUR
  0 siblings, 1 reply; 8+ messages in thread
From: Tanguy LE CARROUR @ 2023-03-25 16:53 UTC (permalink / raw)
  To: guix-devel

Hi Guix,

For the past few… months (!?) I've been working on migrating from
git+stow to a proper Guix Home setup.

It's been painful, but I've learned a lot along the way. There's still
a lot to be done —and a lot to learn!—, but I wanted to know
what were the requirements for a home service to be accepted in master?

I've written home services for the following programs: afew, bat, beets, dunst,
gnupg, imv, khal, khard, mpd, msmtp, nowty, profanity, swappy, tig, tor,
transmission, user-dirs, vdirsyncer, wofi, zathura. Others are on the way.

For the time being, they are available on my channel:
<https://git.easter-eggs.org/bioneland/guix/-/tree/main/bioneland/home/services>.

Most of them are about writing configuration files. But I've limited myself
to the configuration options I was actually using. So they are far from
being complete. But it's kind of cool to be able to write:

```scheme
(define move-left "t")
(define move-up "s")
(define move-down "r")
(define move-right "n")

;; […]

(service home-imv-service-type
  (home-imv-configuration
    (prev move-left)
    (next move-right)
    (zoom-in move-up)
    (zoom-out move-down)))

(service home-khal-service-type
  (home-khal-configuration
    (up move-up)
    (down move-down)
    (left move-left)
    (right move-right)))
```

My main concern now is to figure out how to implement complexe
configurations to be able to write things like:

```scheme
(service home-khal-service-type
  (home-khal-configuration
    (calendars
      (list (khal-calendar (name "my_calendar")
                           (path "~/.calendars/xxxx/")
                           (color "light gray"))))))

(service home-khard-service-type
  (home-khard-configuration
    (addressbooks
      (list (khard-addresbook (name "my_contact")
                              (path "~/.contacts/xxxx/"))))))

(service home-msmtp-service-type
  (home-msmtp-configuration
    (default-account "t@bl")
    (accounts
      (list (msmtp-account (name "t@bl")
                           (host "mail.domain.tld")
                           (port 587)
                           (user "tanguy@bioneland.net")
                           (from "tanguy@bioneland.net"))))))
```

I'm not sure how to make `define-configuration` accept complexe structures.
When I look at `gnu/home/services/ssh.scm`, it seems to be doing the other way
around and define the configuration with `define-record-type` and "put"
the "configuration" inside.

Any guidance would be highly appreciated!

Best regards,

-- 
Tanguy


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Contributing Guix Home services
  2023-03-25 16:53 Contributing Guix Home services Tanguy LE CARROUR
@ 2023-04-04  7:45 ` Tanguy LE CARROUR
  2023-04-13 20:42   ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Tanguy LE CARROUR @ 2023-04-04  7:45 UTC (permalink / raw)
  To: guix-devel

Quoting Tanguy LE CARROUR (2023-03-25 17:53:23)
> My main concern now is to figure out how to implement complexe
> configurations to be able to write things like:
> […]
> I'm not sure how to make `define-configuration` accept complexe structures.
> When I look at `gnu/home/services/ssh.scm`, it seems to be doing the other way
> around and define the configuration with `define-record-type` and "put"
> the "configuration" inside.

Note to self: when in doubt, RTFM! 😅… where the "F" stands for "Fabulous"! 😁
<https://guix.gnu.org/manual/devel/en/html_node/Complex-Configurations.html>

This doesn't answer the question "how complete need a service be to make
it to master?", though. But I've a lot of re-write to do before submitting patches
anyway!

-- 
Tanguy


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Contributing Guix Home services
  2023-04-04  7:45 ` Tanguy LE CARROUR
@ 2023-04-13 20:42   ` Ludovic Courtès
  2023-04-14 12:03     ` Tanguy LE CARROUR
  0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2023-04-13 20:42 UTC (permalink / raw)
  To: Tanguy LE CARROUR; +Cc: guix-devel

Hi Tanguy!

Tanguy LE CARROUR <tanguy@bioneland.org> skribis:

> This doesn't answer the question "how complete need a service be to make
> it to master?", though. But I've a lot of re-write to do before submitting patches
> anyway!

Sorry for not noticing earlier!  There’s no formal rule, but I think
that what we’ve been doing so far is to ensure basic functionality of
the service is covered, and to provide an “escape hatch” for bits of the
configuration that are not covered.

Contributions in this area are most welcome!

Thanks,
Ludo’.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Contributing Guix Home services
  2023-04-13 20:42   ` Ludovic Courtès
@ 2023-04-14 12:03     ` Tanguy LE CARROUR
  2023-04-17 13:39       ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Tanguy LE CARROUR @ 2023-04-14 12:03 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi Ludo’


Quoting Ludovic Courtès (2023-04-13 22:42:56)
> Tanguy LE CARROUR <tanguy@bioneland.org> skribis:
> 
> > This doesn't answer the question "how complete need a service be to make
> > it to master?", though. But I've a lot of re-write to do before submitting patches
> > anyway!
> 
> Sorry for not noticing earlier!

No problem!
It's been quite a journey on my side! Ups. Downs. Mostly downs, though! 😅
Thanks to Simon's unconditional technical and moral support, a **LOT**
has changed since I sent this message. Hopefully for the better! 🤞
At least now one of them [1] looks like a decent home service. Except
for the problem with `(every khal-calendar? lst)` that I haven't figure
out yet.

[1]: https://git.easter-eggs.org/bioneland/guix/-/blob/main/bioneland/home/services/khal.scm


The one for MSMTP [2] does not contain all the available options, but all
the configurations and serializers are there.

[2]: https://git.easter-eggs.org/bioneland/guix/-/blob/main/bioneland/home/services/msmtp.scm


> There’s no formal rule, but I think that what we’ve been doing so far is to ensure basic functionality of
> the service is covered, and to provide an “escape hatch” for bits of the
> configuration that are not covered.

If by "escape hatch" you mean `extra-config`, you're right! I'll try to
add it where ever I can. Does make sense to add on to every
configuration though.


> Contributions in this area are most welcome!

I'll try to submit a patch for one of the two mentioned above soon…ish!

Cheers,

-- 
Tanguy


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Contributing Guix Home services
  2023-04-14 12:03     ` Tanguy LE CARROUR
@ 2023-04-17 13:39       ` Ludovic Courtès
  2023-04-20 15:28         ` Tanguy LE CARROUR
  0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2023-04-17 13:39 UTC (permalink / raw)
  To: Tanguy LE CARROUR; +Cc: guix-devel

Hi!

Tanguy LE CARROUR <tanguy@bioneland.org> skribis:

> It's been quite a journey on my side! Ups. Downs. Mostly downs, though! 😅
> Thanks to Simon's unconditional technical and moral support, a **LOT**
> has changed since I sent this message. Hopefully for the better! 🤞

Heh.  :-)  While it’s fresh on your mind, it would be nice to list the
problems you ran into on your journey and see what we can do about it.

> At least now one of them [1] looks like a decent home service. Except
> for the problem with `(every khal-calendar? lst)` that I haven't figure
> out yet.
>
> [1]: https://git.easter-eggs.org/bioneland/guix/-/blob/main/bioneland/home/services/khal.scm
>
>
> The one for MSMTP [2] does not contain all the available options, but all
> the configurations and serializers are there.
>
> [2]: https://git.easter-eggs.org/bioneland/guix/-/blob/main/bioneland/home/services/msmtp.scm

I don’t use these two programs, but the services look nice!  The extra
bit of work you’d have to do is documentation, similar to what is done
for the other Home services.  Maybe start with msmtp to get a feel of
what that entails?

>> There’s no formal rule, but I think that what we’ve been doing so far is to ensure basic functionality of
>> the service is covered, and to provide an “escape hatch” for bits of the
>> configuration that are not covered.
>
> If by "escape hatch" you mean `extra-config`, you're right!

Yup!

> I'll try to submit a patch for one of the two mentioned above soon…ish!

Excellent, thanks!

Ludo’.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Contributing Guix Home services
  2023-04-17 13:39       ` Ludovic Courtès
@ 2023-04-20 15:28         ` Tanguy LE CARROUR
  2023-05-03 20:42           ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Tanguy LE CARROUR @ 2023-04-20 15:28 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi Ludo’,


Quoting Ludovic Courtès (2023-04-17 15:39:02)
> Tanguy LE CARROUR <tanguy@bioneland.org> skribis:
> > It's been quite a journey on my side! Ups. Downs. Mostly downs, though! 😅
> > Thanks to Simon's unconditional technical and moral support, a **LOT**
> > has changed since I sent this message. Hopefully for the better! 🤞
> 
> Heh.  :-)  While it’s fresh on your mind, it would be nice to list the
> problems you ran into on your journey and see what we can do about it.

Mostly figuring out how to test it!

On my machine at home, `guix home reconfigure` can take minutes.
And some errors don't actually show up.
After trying different solutions, I eventually settled on the following:
while developing, I add, at the end of service file, something like:

```scheme
(define configuration
  (home-service-configuration
   ; […]
  )

(mixed-text-file
 "test"
 (serialize-configuration configuration home-service-configuration-fields))
```

And then I run:

```console
> cat (guix build -f path/to/home/service.scm)
# … the content of the generated file
```

I can only test file generation, though.

Then I painfully discovered that replacing in a string is not as easy as
it sounds, or, more precisely, that "python replace in string" yields
better results than "scheme replace in string" in DuckDuckGo!

I've also used `gexp` in places where I'm not sure it makes any sense,
but it works, so… #pragmatic!


> > At least now one of them [1] looks like a decent home service. Except
> > for the problem with `(every khal-calendar? lst)` that I haven't figure
> > out yet.
> >
> > [1]: https://git.easter-eggs.org/bioneland/guix/-/blob/main/bioneland/home/services/khal.scm
> >
> >
> > The one for MSMTP [2] does not contain all the available options, but all
> > the configurations and serializers are there.
> >
> > [2]: https://git.easter-eggs.org/bioneland/guix/-/blob/main/bioneland/home/services/msmtp.scm
> 
> I don’t use these two programs, but the services look nice!  The extra
> bit of work you’d have to do is documentation, similar to what is done
> for the other Home services.  Maybe start with msmtp to get a feel of
> what that entails?

`(configuration->documentation 'home-msmtp-configuration)`
`(configuration->documentation 'msmtp-account)`
`(configuration->documentation 'msmtp-configuration)`
… *et voilà !*


> >> There’s no formal rule, but I think that what we’ve been doing so far is to ensure basic functionality of
> >> the service is covered, and to provide an “escape hatch” for bits of the
> >> configuration that are not covered.
> >
> > If by "escape hatch" you mean `extra-config`, you're right!
> 
> Yup!

The convention seems to be `extra-content`, but you knew what I meant, right!? 😅


> > I'll try to submit a patch for one of the two mentioned above soon…ish!
> 
> Excellent, thanks!

Done! <https://issues.guix.gnu.org/62969>
I could have done a **lot** more with the documentation, but I wanted to
be sure to get the basic right first.

-- 
Tanguy


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Contributing Guix Home services
  2023-04-20 15:28         ` Tanguy LE CARROUR
@ 2023-05-03 20:42           ` Ludovic Courtès
  2023-05-17  7:16             ` Tanguy LE CARROUR
  0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2023-05-03 20:42 UTC (permalink / raw)
  To: Tanguy LE CARROUR; +Cc: guix-devel

Hey!

Tanguy LE CARROUR <tanguy@bioneland.org> skribis:

> Quoting Ludovic Courtès (2023-04-17 15:39:02)
>> Tanguy LE CARROUR <tanguy@bioneland.org> skribis:
>> > It's been quite a journey on my side! Ups. Downs. Mostly downs, though! 😅
>> > Thanks to Simon's unconditional technical and moral support, a **LOT**
>> > has changed since I sent this message. Hopefully for the better! 🤞
>> 
>> Heh.  :-)  While it’s fresh on your mind, it would be nice to list the
>> problems you ran into on your journey and see what we can do about it.
>
> Mostly figuring out how to test it!
>
> On my machine at home, `guix home reconfigure` can take minutes.

Did you test with ‘guix home container’ first?  That’s what I do and I
added this command precisely so one can test without any risk of
breaking things.

It’s still too slow though, that’s right.

> I can only test file generation, though.

The msmtp service does nothing but file generation though, right?

> Then I painfully discovered that replacing in a string is not as easy as
> it sounds, or, more precisely, that "python replace in string" yields
> better results than "scheme replace in string" in DuckDuckGo!

True!  Perhaps something to add to the Cookbook’s Scheme intro.

(Fun fact: I’ve never used that (ice-9 string-fun) module that keeps
popping up in new code.  :-))

> I've also used `gexp` in places where I'm not sure it makes any sense,
> but it works, so… #pragmatic!

Alright.

> Done! <https://issues.guix.gnu.org/62969>

Wo0t!

Ludo’.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Contributing Guix Home services
  2023-05-03 20:42           ` Ludovic Courtès
@ 2023-05-17  7:16             ` Tanguy LE CARROUR
  0 siblings, 0 replies; 8+ messages in thread
From: Tanguy LE CARROUR @ 2023-05-17  7:16 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi Ludo’,

Sorry, busy week! 😅 … euh… busy 2 weeks! 😱


Quoting Ludovic Courtès (2023-05-03 22:42:27)
> Tanguy LE CARROUR <tanguy@bioneland.org> skribis:
> 
> > Quoting Ludovic Courtès (2023-04-17 15:39:02)
> >> Tanguy LE CARROUR <tanguy@bioneland.org> skribis:
> >> > It's been quite a journey on my side! Ups. Downs. Mostly downs, though! 😅
> >> > Thanks to Simon's unconditional technical and moral support, a **LOT**
> >> > has changed since I sent this message. Hopefully for the better! 🤞
> >> 
> >> Heh.  :-)  While it’s fresh on your mind, it would be nice to list the
> >> problems you ran into on your journey and see what we can do about it.
> >
> > Mostly figuring out how to test it!
> >
> > On my machine at home, `guix home reconfigure` can take minutes.
> 
> Did you test with ‘guix home container’ first?  That’s what I do and I
> added this command precisely so one can test without any risk of
> breaking things.
> 
> It’s still too slow though, that’s right.

Yes, when I use my actual home config, it also takes minutes to build
the container, but, if I use a fake home config, limited to the service
I want to test, it's way faster! Still slower than the following…

Append this test code at the end of the service file:

```scheme
(define configuration
  (home-service-configuration
   ; […]
  )

(mixed-text-file "test" (serialize-configuration configuration home-service-configuration-fields))
```

Then, from the command line:

```console
$ cat (guix build -f path/to/home/service.scm)
# … the content of the generated file
```


> > I can only test file generation, though.
> 
> The msmtp service does nothing but file generation though, right?
> 
> > Then I painfully discovered that replacing in a string is not as easy as
> > it sounds, or, more precisely, that "python replace in string" yields
> > better results than "scheme replace in string" in DuckDuckGo!
> 
> True!  Perhaps something to add to the Cookbook’s Scheme intro.
> 
> (Fun fact: I’ve never used that (ice-9 string-fun) module that keeps
> popping up in new code.  :-))

Whaaaat?! 🤯 How one would you do without it? 😅


-- 
Tanguy


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-17  7:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-25 16:53 Contributing Guix Home services Tanguy LE CARROUR
2023-04-04  7:45 ` Tanguy LE CARROUR
2023-04-13 20:42   ` Ludovic Courtès
2023-04-14 12:03     ` Tanguy LE CARROUR
2023-04-17 13:39       ` Ludovic Courtès
2023-04-20 15:28         ` Tanguy LE CARROUR
2023-05-03 20:42           ` Ludovic Courtès
2023-05-17  7:16             ` Tanguy LE CARROUR

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.