Hi! I am trying to use the new oci-service type and it seems to work
nicely! However I am not able to get it to work with a local OCI
archive. What am I doing wrong? Here is the service:

```scm
(simple-service 'oci-provisioning oci-service-type
                (oci-extension
                 (containers
                  (list
                   (oci-container-configuration
                    (image (oci-image
                            (repository "localhost/hello")
                            (value (local-file "/tmp/oci.tar")))))))))
```

And the result:

```
Backtrace:
In srfi/srfi-1.scm:
   586:29 19 (map1 (#<<service> type: #<service-type mingetty 7f2…> …))
   586:29 18 (map1 (#<<service> type: #<service-type mingetty 7f2…> …))
   586:29 17 (map1 (#<<service> type: #<service-type mingetty 7f2…> …))
   586:29 16 (map1 (#<<service> type: #<service-type mingetty 7f2…> …))
   586:29 15 (map1 (#<<service> type: #<service-type agetty 7f2b3…> …))
   586:29 14 (map1 (#<<service> type: #<service-type shepherd-sys…> …))
   586:29 13 (map1 (#<<service> type: #<service-type console-font…> …))
   586:29 12 (map1 (#<<service> type: #<service-type virtual-term…> …))
   586:17 11 (map1 (#<<service> type: #<service-type oci 7f2b3ad1…> …))
In gnu/services/containers.scm:
   1500:3 10 (oci-state->shepherd-services #<<oci-state> networks: …> …)
In srfi/srfi-1.scm:
   586:17  9 (map1 (#<<oci-container-configuration> user: %unset-ma…>))
In gnu/services/containers.scm:
  1317:17  8 (oci-container-shepherd-service _ #<<oci-runtime-state…> …)
  1185:17  7 (oci-image-loader #<<oci-runtime-state> runtime: podma…> …)
In ice-9/boot-9.scm:
  1752:10  6 (with-exception-handler _ _ #:unwind? _ # _)
In guix/store.scm:
   690:37  5 (thunk)
  2212:25  4 (run-with-store #<store-connection 256.99 7f2b3acd55a0> …)
  2212:25  3 (run-with-store #<store-connection 256.99 7f2b3acd55a0> …)
In ice-9/boot-9.scm:
  1685:16  2 (raise-exception _ #:continuable? _)
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong type to apply: #<<local-file> file: "/tmp/oci.tar" absolute:
#<promise #<procedure 7f5283a56d40 at ice-9/eval.scm:330:13 ()>> name:
"oci.tar" recursive?: #f select?: #<procedure true (file stat)>>
```

According to the manual, the oci-image value field accepts "a gexp or a
file-like object that evaluates to an OCI compatible tarball" and
"local-file ... returns a file-like object".

https://guix.gnu.org/manual/devel/en/html_node/Miscellaneous-Services.html#index-oci_002dimage

https://guix.gnu.org/manual/devel/en/html_node/G_002dExpressions.html#index-gexp_002d_003ederivation

Do I need to specify the local file in a different way?

Here is a full example:

```scm
(define-module (os)
  #:use-module (gnu packages file-systems)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services containers)
  #:use-module (gnu services dbus)
  #:use-module (gnu services desktop)
  #:use-module (gnu bootloader)
  #:use-module (gnu bootloader grub)
  #:use-module (gnu system)
  #:use-module (gnu system accounts)
  #:use-module (gnu system file-systems)
  #:use-module (gnu system shadow)
  #:use-module (guix gexp))

(define-public os
  (operating-system
   (bootloader (bootloader-configuration
                (bootloader grub-bootloader)))
   (file-systems (cons (file-system (device "/dev/vda1")
                                    (mount-point "/")
                                    (type "ext4"))
                       %base-file-systems))
   (host-name "test-os")
   (locale "en_US.utf8")
   (services
    (cons*
     ;; networking service-type omitted
     (service elogind-service-type)
     (service dbus-root-service-type)
     (service rootless-podman-service-type)
     (service
      oci-service-type
      (oci-configuration
       (runtime 'podman)
       (runtime-extra-arguments
        (list
         ;; This is necessary for running Podman in a `guix system vm`
         ;; because an overlay is used to share the host store and
         ;; Linux will not do another overlay on top of that.
         #~(string-append "--storage-opt=overlay.mount_program="
                          #$(file-append fuse-overlayfs
                                         "/bin/fuse-overlayfs"))))
       (verbose? #t)))
     (simple-service
      'oci-provisioning oci-service-type
      (oci-extension
       (containers
        (list
         (oci-container-configuration
          (image (oci-image
                  (repository "localhost/hello")
                  (value (local-file "/tmp/oci.tar")))))))))
     %base-services))))

os
```

The OCI archive was created like this:

```sh
podman image pull docker://hello-world
podman image save --format=oci-archive --output=/tmp/oci.tar \
    docker.io/library/hello-world
```

Thanks,
Owen

Reply via email to