Subject: [bug#68857] gnu: home: dotfiles: Avoid creating extra directory in $HOME.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 04 Mar 2024 16:46:35 +0100

Hi,

Giacomo Leidi <[email-masked]> skribis:

> The current implementation of the home-dotfiles-service-type contradicts
> the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch
> properly implements both the plain and Stow dotfiles directory layouts.
>
> It does so by refactoring home-dotfiles-configuration, renaming the
> directories field to a single directory, adding a new packages field to
> support GNU Stow's users workflow and introducing a new layout field to
> switch between the two directory layouts.
>
> * gnu/home/services/dotfiles (home-dotfiles-configuration): Migrate to
> (gnu services configuration);
> [directories]: rename to...;
> [directory]: ...this, new field;
> [packages]: new field;
> [layout]: new field;
> (strip-stow-dotfile): new variable;
> (strip-plain-dotfile): new variable;
> (home-dotfiles-configuration->files): use the new fields;
> [directory-contents]: allow for
> selecting a subset of application dotfile directories;
> * doc/guix.texi: document the new layouts.
>
> Change-Id: I2e96037608353e360828290f055ec5271cfdfd48

LGTM, but…

> -  (directories       home-dotfiles-configuration-directories       ;list of strings
> -                     (default '()))

[...]

> +  (directory
> +   (string)
> +   "The dotfiles directory where @code{home-dotfiles-service-type}
> +will look for application dotfiles.")

This is an incompatible change.  Can we keep the old ‘directories’
field?

(Maybe this change is worthwhile, but it’s beyond the scope of this
patch series IMO, so I’d suggest discussing it separately.)

>  (define-public home-dotfiles-service-type
>    (service-type (name 'home-dotfiles)
>                  (extensions
>                   (list (service-extension home-files-service-type
> -                                          home-dotfiles-configuration->files)))
> -                (default-value (home-dotfiles-configuration))
> +                                          (lambda (config)
> +                                            (when config
> +                                              (home-dotfiles-configuration->files config))))))
> +                (default-value #f)

Better not provide a default value than provide one that is invalid.  My
suggestion would be to remove the ‘default-value’ field here.

Apologies for the delays and thanks for your work and for your patience!

Ludo’.