services: home-writable-files-manager: Improve handling of out-of-store files.

* modules/rosenthal/home/services/writable-files-manager.scm
  (update-writable-files-script)
  [cleanup-writable-files]: Handle copied and symlinked targets differently.
  [create-writable-files]: Create symlink when source doesn't exist.
This commit is contained in:
Hilton Chain committed 2026-11-30 10:55:10 +08:00
1 parent a8da12053f
commit 6af9d5426f
1 file changed
+4 -2
@@ -146,7 +146,8 @@ subdirectory from XDG_CONFIG_HOME to generate a target path."
;; we'll create later, it will be backed up later during ;; we'll create later, it will be backed up later during
;; create-writable-files phase. ;; create-writable-files phase.
(if (or (symlink-to-store? target) (if (or (symlink-to-store? target)
(equal? (file-hash* source) (equal?
(file-hash* (if (symbolic-link? target) file source))
(file-hash* target))) (file-hash* target)))
(begin (begin
(format #t (G_ "Removing ~a...") target) (format #t (G_ "Removing ~a...") target)
@@ -213,7 +214,8 @@ subdirectory from XDG_CONFIG_HOME to generate a target path."
(backup-file (strip file))) (backup-file (strip file)))
(format #t (G_ "Copying ~a -> ~a...") (format #t (G_ "Copying ~a -> ~a...")
source target) source target)
(if (file-is-directory? source) (if (or (not (file-exists? source))
(file-is-directory? source))
(symlink source target) (symlink source target)
(begin (begin
(copy-file source target) (copy-file source target)