help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Staging Scheme code to run as one-shot service


From: Owen T. Heisler
Subject: Re: Staging Scheme code to run as one-shot service
Date: Mon, 4 Mar 2024 22:01:10 -0600

Hi Florian,

On 3/4/24 02:31, pelzflorian (Florian Pelz) wrote:
P.S. There also is the code for

https://issues.guix.gnu.org/62584#0

which is not using a Shepherd service.

At first I was confused by the link to an April-1 joke. :-) But that did work, thanks!

Here is a working example (I'm not sure why default-value is required):

```scm
;; $(guix system vm input.scm --no-graphic)
(use-modules (gnu bootloader)
             (gnu bootloader grub)
             (gnu services base)
             (gnu system file-systems)
             (guix gexp))
(define (say-hello-gexp _)
  #~(begin
      (display "====say-hello====\n"
               (current-error-port))))
(define say-hello-service-type
  (service-type (name 'say-hello)
                (extensions (list (service-extension boot-service-type
                                                     say-hello-gexp)))
                ;; without default-value, error:
                ;; no value specified for service of type 'say-hello'
                (default-value 0)
                (description "Print say-hello during boot.")))
(operating-system
  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (targets '("/dev/vda"))
                (terminal-inputs '(console serial))
                (terminal-outputs '(console serial))
                (timeout 1)))
  (file-systems (cons (file-system
                        (mount-point "/")
                        (device "/dev/vda1")
                        (type "ext4")) %base-file-systems))
  (host-name "test-guix-vm")
  (kernel-arguments (cons "console=ttyS0" %default-kernel-arguments))
  (services
   (append (list (service say-hello-service-type)) %base-services)))
```

Thanks,
Owen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]