Subject: Re: bug#71217: gnu: home: dotfiles: Files not excluded when they should

From: Ludovic Courtès <[email-masked]>
Date: Wed, 20 Nov 2024 23:33:52 +0100

Hi,

(Cc: Giacomo, who authored this service.)

Nicolas Odermatt-Lemay <[email-masked]> skribis:

> While attempting to setup home-dotfiles-service, I noticed that some files
> were being symlinked even though they were in the variable
> `%home-dotfiles-excluded', such as all the files of the .git directory.

Oh.

> This patch seems to fix the problem :
>
> diff --git a/gnu/home/services/dotfiles.scm b/gnu/home/services/dotfiles.scm
> index 823bdb03fb..38f7ff83d0 100644
> --- a/gnu/home/services/dotfiles.scm
> +++ b/gnu/home/services/dotfiles.scm
> @@ -45,7 +45,7 @@ (define-module (gnu home services dotfiles)
>  (define %home-dotfiles-excluded
>    '(".*~"
>      ".*\\.swp"
> -    "\\.git"
> +    "\\.git/.*"
>      "\\.gitignore"))
>
>  (define %home-dotfiles-layouts
> @@ -138,8 +138,7 @@ (define* (directory-contents directory #:key (packages
> #f))
>      (define (filter-files directory)
>        (find-files directory
>                    (lambda (file stat)
> -                    (not (regexp-exec exclusion-rx
> -                                      (basename file))))))
> +                    (not (regexp-exec exclusion-rx file)))))

That would change the semantics of ‘exclusion-rx’ though.

Maybe instead we should change from ‘file-files’ to ‘file-system-fold’
and not enter directories that match one of the exclusion patterns?

Ludo’.