Hi Guix,

Since the config file deployment mechanism of Guix Home is designed to be
pluggable, as mentioned in the comments of (gnu home services), I tried to write
a home-writable-files-manager-service-type[1] to deploy writable config files.

This home service type is based on home-symlink-manager-service-type and serves
as a replacement to it.  On home environment activation, the service deploys
config files as regular files and makes them writable -- with the exception of
directories, they're still symlinked.

When deploying a config file, if its target file exists and differs from it in
sha256 hash, the previously existing target file will be saved to a backup
directory, similar to the home-symlink-manager-service-type.

Comparing with home-symlink-manager-service-type, since the deployed files are
writable, this approach is compatible with more software and makes it easier to
edit these files before a reconfiguration of the home environment.

For example, with the following service

--8<---------------cut here---------------start------------->8---
(simple-service 'my-libc-files
                home-files-service-type
                `(("my-libc-dir" ,(file-append glibc "/lib"))
                  ("my-libc.so"  ,(file-append glibc "/lib/libc.so"))))
--8<---------------cut here---------------end--------------->8---

The activated home environment will have ~/my-libc-dir as a symlink and
~/my-libc.so as a writable regular file.

To use the service, assuming you have the definition, modify essential-services
from your home environment declaration and replace the original
home-symlink-manager-service-type.  No other changes are needed.

(Refer to home-environment-default-essential-services via @@ here, since
currently it is not exported.)

--8<---------------cut here---------------start------------->8---
(home-environment
  (packages ...)
  (essential-services
   (cons* (service home-writable-files-manager-service-type)
          (modify-services ((@@ (gnu home) 
home-environment-default-essential-services)
                            this-home-environment)
            (delete home-symlink-manager-service-type))))
  (services ...))
--8<---------------cut here---------------end--------------->8---

Thanks


[1]: 
https://codeberg.org/hako/Rosenthal/src/commit/ed943d36b4163d7186109e9e430adbe0392aaa8d/modules/rosenthal/home/services/writable-files-manager.scm

Reply via email to