Subject: [bug#73467] [PATCH] Wireguard: Add autostart? field.

From: Sergey Trofimov <[email-masked]>
Date: Thu, 26 Sep 2024 19:45:26 +0200

Apoorv Singh <[email-masked]> writes:

> The following patch adds a record field autostart? which can be used by the user
> to configure weather the wireguard service should start automatically.

I generally agree that there should be a way to disable autostart and
I've solved it in a more generic way:

--8<---------------cut here---------------start------------->8---
(define (no-autostart input-service)
  "Augment shepherd extension of INPUT-SERVICE to disable auto-start."
  (define (transform-extension ex)
    (match ex
      (($ (@@ (gnu services) <service-extension>)
          (and ($ (@@ (gnu services) <service-type>) 'shepherd-root _) kind)
          compute)

       (service-extension
        kind
        (lambda (config)
          (let ((orig (car (compute config))))
            (list (shepherd-service (inherit orig) (auto-start? #f)))))))

      (_ ex)))

  (match input-service
    (($ (@@ (gnu services) <service>)
        (and ($ (@@ (gnu services) <service-type>) _ extensions _) kind)
        value)

     (service
      (service-type
       (inherit kind)
       (extensions (map transform-extension extensions)))
      value))))
--8<---------------cut here---------------end--------------->8---

Anyway, you need to document the new configuration parameter in the manual.