GNU bug report logs - #60657
Rethinking how service extensions work

Previous Next

Package: guix;

Reported by: Bruno Victal <mirai <at> makinata.eu>

Date: Sun, 8 Jan 2023 12:32:02 UTC

Severity: normal

Full log


Message #11 received at 60657 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Bruno Victal <mirai <at> makinata.eu>
Cc: 60657 <at> debbugs.gnu.org
Subject: Re: bug#60657: Rethinking how service extensions work
Date: Sat, 25 Feb 2023 18:46:18 +0100
Hi Bruno,

Bruno Victal <mirai <at> makinata.eu> skribis:

> The current situation with services in Guix is that service extensions do not care about dependencies.

This is the result of “services” being unrelated to “Shepherd services”,
as noted in the manual (info "(guix) Services").

> This can result in cryptic errors as seen in [1].
>
> [1] https://issues.guix.gnu.org/57589#12
>
> In [1], the issue arises from using activation-service-type to create files/directories for services
> when these should be either (1) shepherd one-shot services or moved into the 'start' procedure of the service.
> 'activation-service-type' should only be used for doing things "listed on its label", that is, performing
> actions at boot-time or after a system reconfigure.

Right.

As we once discussed on IRC, the conclusion to me is that some of the
code currently implemented as activation snippets should rather be
implemented either as part of the ‘start’ method of the corresponding
Shepherd service, or as a one-shot Shepherd service that the main
service would depend on.

> But both solutions (1) and (2) are still not enough as the directories themselves might not yet
> be available and the services must be aware of this fact and wait for them to be ready. One example
> would be a network dependent mount or a simple service that mounts a volume such as:
>
> (simple-service 'mount-overlayfs shepherd-root-service-type
>                 (list (shepherd-service (requirement '(foo-mount))
>                                         (provision '(overlayfs-foo))
>                                         (documentation "Mount OverlayFS.")
>                                         (one-shot? #t)
>                                         (start (let ((util-linux (@ (gnu packages linux) util-linux)))
>                                                  #~(lambda _
>                                                      (system* #$(file-append util-linux "/bin/mount")
>                                                               "-t" "overlay"
>                                                               "-o" (string-append "noatime,nodev,noexec,ro,"
>                                                                                   "lowerdir="
>                                                                                   (string-join '("/srv/foo/overlays/top-layer"
>                                                                                                  "/srv/foo/overlays/layer2"
>                                                                                                  "/srv/foo/overlays/layer1"
>                                                                                                  "/media/foo-base") ":"))
>                                                               "none" "/media/foo" )))))))

Note that this should prolly be declared as a ‘file-system’ rather than
as a custom service.  That way, it would get a “standard” Shepherd
service.

There are cases where we add explicit dependencies on
‘file-system-/media/foo’ or similar.  <file-system> has a ‘dependencies’
field specifically for this purpose (info "(guix) File Systems").

Would that work for you?

HTH,
Ludo’.




This bug report was last modified 2 years and 38 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.