Hi guix-developers,

In https://lists.gnu.org/archive/html/guix-devel/2021-01/msg00053.html Carlo 
mentioned to instead use the `service` system to modify all parts needed in the 
operating system to get ZFS installed, and noted as well that the only thing 
missing in the `service` system is the ability to push kernel modules into the 
operating system.

Here's a sketch of an attempt to add that feature so we can conveniently add 
ZFS on Guix by just adding a `(service zfs-service-type...)`.

First, we need a new `kernel-loadable-module-service-type` in 
`gnu/services.scm`:

```scheme
(define kernel-loadable-module-service-type
  ;; A service to add the kernel modules of a package.
  (service-type (name 'kernel-loadable-module)
                (extensions '())
                (compose concatenate)
                (extend append)
                (description "Register kernel modules that will be placed in a
loadable place where the kernel can find them.")
                (default-value '())))
```

Absolutely no idea if a `'()` extensions makes sense but *shrug*.

Then, in `gnu/system.scm`, we create this new function:

```scheme
(define (operating-system-all-kernel-loadable-modules os)
  ;; Gathers the kernel-loadable modules in the KERNEL-LOADABLE-FIELD
  ;; field of the OS, as well as those registered by services.
  (let ((service (fold-services (cons (service 
kernel-loadable-module-service-type '())
                                      (operating-system-user-services os))
                                #:target-type 
kernel-loadable-module-service-type)))
    (append (service-value service)
            (operating-system-kernel-loadable-modules))))
```

Does that make sense? Am I misusing `fold-services` and `service-value` here?

Onward, we modify as well the function `operating-system-directory-base`:

```scheme
(define* (operating-system-directory-base-entries os)
  "Return the basic entries of the 'system' directory of OS for use as the
value of the SYSTEM-SERVICE-TYPE service."
  (let* ((locale  (operating-system-locale-directory os))
         (kernel  (operating-system-kernel os))
         (hurd    (operating-system-hurd os))
         (modules (operating-system-all-kernel-loadable-modules os))
;...
```

The above is the reason why we need to `cons` a synthetic 
`kernel-loadable-module-service-type` service, the function 
`operating-system-directory-base-entries` is used do create the default for 
`operating-system-essential-services`, and the `operating-sstem-services` is 
just the concatenation of the user and essential services.  I think.

Would this work?

Thanks
raid5atemyhomework

Reply via email to