Subject: bug#68747: Extending postgresql-role-service-type as shown in manual leads to crash

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 26 Jan 2024 21:14:39 -0500

Hi,

We have this example in the manual, in (info "(guix) Database
Services"):

--8<---------------cut here---------------start------------->8---
          (service-extension postgresql-role-service-type
                             (const (postgresql-role
                                     (name "alice")
                                     (create-database? #t))))
--8<---------------cut here---------------end--------------->8---

Unfortunately, it doesn't seem to work as intended.  Adding the
following to my configuration:

--8<---------------cut here---------------start------------->8---
      (service postgresql-service-type)
      (service postgresql-role-service-type
                      (postgresql-role-configuration
                       (roles
                        (list (postgresql-role
                               (name "maxim")
                               (create-database? #t))))))
      (service-extension postgresql-role-service-type
                             (const (postgresql-role
                                     (name "cuirass")
                                     (create-database? #t))))
--8<---------------cut here---------------end--------------->8---

I get the following error upon reconfiguration:

--8<---------------cut here---------------start------------->8---
Backtrace:
          18 (primitive-load "/home/maxim/.config/guix/current/bin/g…")
In guix/ui.scm:
   2324:7 17 (run-guix . _)
  2287:10 16 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10 15 (with-exception-handler _ _ #:unwind? _ # _)
In guix/status.scm:
    859:3 14 (_)
    839:4 13 (call-with-status-report _ _)
In guix/scripts/system.scm:
   1305:4 12 (_)
In ice-9/boot-9.scm:
  1752:10 11 (with-exception-handler _ _ #:unwind? _ # _)
In guix/store.scm:
   661:37 10 (thunk)
   1300:8  9 (call-with-build-handler #<procedure 7f446c6d5c90 at g…> …)
  2180:25  8 (run-with-store #<store-connection 256.99 7f44768a8a00> …)
In guix/scripts/system.scm:
    847:2  7 (_ _)
    721:8  6 (_ #<store-connection 256.99 7f44768a8a00>)
In gnu/system.scm:
  1295:19  5 (operating-system-derivation _)
In gnu/services.scm:
   1166:6  4 (instantiate-missing-services _)
In srfi/srfi-1.scm:
   460:18  3 (fold #<procedure 7f446a968960 at gnu/services.scm:116…> …)
In gnu/services.scm:
  1167:27  2 (_ #<<service-extension> target: #<service-type postgr…> …)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure service-kind: Wrong type argument: #<<service-extension> target: #<service-type postgresql-role 7f4471875640> compute: #<procedure 7f446afc63a0 at ice-9/boot-9.scm:809:2 _>>
--8<---------------cut here---------------end--------------->8---

-- 
Thanks,
Maxim