guix-devel
[Top][All Lists]
Advanced

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

Re: A new paradigm for modifying operating system declarations


From: Carlo Zancanaro
Subject: Re: A new paradigm for modifying operating system declarations
Date: Tue, 05 Jan 2021 17:12:31 +1100
User-agent: mu4e 1.4.13; emacs 27.1

Hi raid5atemyhomework,

On Tue, Jan 05 2021, raid5atemyhomework wrote:
What `install-zfs` does is that it installs the same kernel-specific package in three different points:

* `kernel-loadable-modules`, because ZFS needs to get into the kernel somehow. * `packages`, because the kernel module is useless if you don't have the userland tools to interact with the kernel module. * `services`, because ZFS is well-documented outside of Guix as automatically mounting its filesystems at bootup, but that actually requires a bit of magic in the `init` system, specifically you need to actually **load** the module, then execute `zpool import -a -l` to have it scan for all filesystems and mount those that need automounting.

Thus, an `install-zfs`, that is a *single* form that inserts the correct bits in the correct ***three*** places, makes the experience of adding ZFS to your `operating-system` easier because there's less scope for error in actually adding the package. You just add a single `install-zfs`, not add three things (plus an extra `(define my-zfs (make-zfs-package linux-libre-5.4))` before your form).

In principle, I think this should all be handled by a service. Services have a number of extension points where they can impact the operating system being declared, by extending other services. For example, adding a package into the global profile is done by extending profile-service-type (which you can find in gnu/services.scm). Adding a shepherd service to manage a process is done by extending shepherd-root-service-type (in gnu/services/shepherd.scm).

This is how many services work. As an example, sddm-service-type extends services to: (a) start a process on the running system, (b) put files in /etc, (c) install some pam services, (d) add an account on the system, and (e) install packages in the global profile.

As far as I can tell, the only thing missing for a zfs-service-type to do what you want is that services can't currently add new kernel modules (although they can load them via kernel-module-loader-service-type). I may have missed a mechanism for this, though. If we added the ability to do this, then it should be possible to add zfs support by adding a single (service zfs-service-type) to your services list.

The approach of using services in this way has some advantages which are outlined in a blog post from 2015[1]. For me the most compelling advantage is that an zfs-service-type is more restricted in what it can do, and must be more explicit. An install-zfs procedure has free-reign over the entire operating-system definition that it gets passed, which makes it harder to reason about the composition of such procedures.

Carlo

[1]: https://guix.gnu.org/blog/2015/service-composition-in-guixsd/



reply via email to

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