Hi,

On Sun Mar 22, 2026 at 4:24 PM CET, Tanguy Le Carrour wrote:
> On Thu Mar 19, 2026 at 8:52 AM CET, Tanguy Le Carrour wrote:
>> On Wed Mar 18, 2026 at 3:47 PM CET, Remco van 't Veer wrote:
>>> 2026/03/18, Tanguy Le Carrour:
>>>
>>>> I do not "own" the `gunicorn-service-type` and cannot add a `requirement` 
>>>> to its
>>>> shepherd extension to tell it that it should run after the database.
>>>
>>> I use this trick to make a service depend on another service:
>>>
>>>   https://mail.gnu.org/archive/html/help-guix/2024-03/msg00075.html 
> […]
> But, even if the `depend-on` was working as expected, I would still don’t get 
> **how**
> it was supposed to work, as the activations are run **before** Shepherd is 
> even started?! 🤔

So after having given it yet another try, I dropped the call to `depend-on`. It 
was not doing
anything as I had no `shepherd-root-service-type` as extension of 
`gertrude-service-type`.

Instead, I turned my `gertrude-db-init` from being an `activation-service-type` 
into a `shepherd-root-service-type`.
This Shepherd service depends on `'postgresql`, which is what I wanted, and 
runs the DB schema init
command and sets `(stop #~(const #f)) (respawn? #f) (one-shot? #t)`. The web 
service still runs before,
but I can live with that, I guess.

Now I just have to make `depend-on` work to make `gertrude-service-type` (or 
`gunicorn-service-type`)
require `gertrude-db-init`.

When I do this:

```scheme
(define (depend-on type new-requirement)
  (service-type
   (inherit type)
   (extensions
    (map (lambda (extension)
           (let ((target (service-extension-target extension))
                 (compute (service-extension-compute extension)))
             (if (eq? target shepherd-root-service-type)
                 (service-extension shepherd-root-service-type
                                    (lambda (config)
                                      (map (lambda (service)
                                             (shepherd-service
                                              (inherit service)
                                              (requirement
                                               (cons*
                                                new-requirement
                                                (shepherd-service-requirement 
config)))))
                                           (compute config))))
                 extension)))
         (service-type-extensions type)))))


(service (depend-on gertrude-service-type 'gertrude-initialisation)
  (gertrude-configuration
    (server-name "test")
    (dsn "test"))))
```

I get: `In procedure shepherd-service-requirement: Wrong type argument: 
#<<gertrude-configuration> […]`.

Same kind of error when I do:

```scheme
(define gertrude-service-type
  (service-type
   (extensions
     (list
       (service-extension (depend-on gunicorn-service-type 'postgresql)
                          gertrude-gunicorn-apps)))))
```

I get: `In procedure shepherd-service-requirement: Wrong type argument: 
#<<gunicorn-configuration> […]`.

So, I guess, I’m not using it properly.

Any idea what I’m doing wrong?!

--
Tanguy

Reply via email to