guix-devel
[Top][All Lists]
Advanced

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

Re: A friendlier API for operating-system declarations


From: antlers
Subject: Re: A friendlier API for operating-system declarations
Date: Fri, 19 May 2023 03:31:35 +0000

Anecdotally, my personal configurations are built out of composable operating-system transformers that add packages, services, etc. through trees of inherited records.

That's fairly straightforward for eg. adding packages, but becomes more complicated when you consider modifying service configurations (which you might want to inherit from when present and create when absent), nested service configurations (inheriting multiple times, the whole away down), or modifying kernel-arguments (where you might want to strip values for the option that you're setting from existing strings).

I feel that operating-system record fields should be `extendable` in the same way as services, and have always assumed that that's basically what RDE's `features` are.

It would be great to have structure that eliminates some of the nesting and boilerplate of an _expression_ like this:
```
;; imagine if this was (imperative-ness aside) as simple as:
;; lambda os: os.services(foo).z.foo += bar

(lambda (os)
  (operating-system
    (inherit os)
    (sevices
      (modify-services
        (operating-system-services os)
        (y-service-type
          config => (y-configuration
                      (inherit config)
                      (z-configuration
                        (z-configuration
                         (inherit (y-configuration-z config)
                         (foo (cons bar
                                    (z-configuration-foo
                                      (y-configuration-z config)))))))))))))

;; And if we want to create the service when it doesn't exist?
                         
(lambda (os)
  (operating-system
    (inherit os)
    (sevices
      (if (find (lambda (s)
                  (eq (service-kind s) y))
                (operating-system-services os))
          (modify-services
            (operating-system-services os)
            (y-service-type
              config => (y-configuration
                          (inherit config)
                          (z-configuration
                            (z-configuration
                             (inherit (y-configuration-z config)
                             (foo (cons bar
                                        (z-configuration-foo
                                          (y-configuration-z config))))))))))
          (cons (service y-service-type
                  (y-configuration
                    (z-configuration
                      (z-configuration
                        (foo (list bar))))))
                (operating-system-services os))))))
```

reply via email to

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