From 089683bbd301f6e085f00fbd53713f335abac40e Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Feb 2022 16:14:23 +0300 Subject: [PATCH 5/5] home: symlink-manager: Respect XDG_CONFIG_HOME during activation. * gnu/home/services/symlink-manager.scm (update-symlinks-script): Respect XDG_CONFIG_HOME during activation. --- gnu/home/services/symlink-manager.scm | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/symlink-manager.scm index 747bb343d3..418bfbd98a 100644 --- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -85,8 +85,8 @@ (define ((file-tree-traverse preordering) node) (use-modules (guix build utils)) - (let* ((config-home (or (getenv "XDG_CONFIG_HOME") - (string-append (getenv "HOME") "/.config"))) + (let* ((xdg-config-home (or (getenv "XDG_CONFIG_HOME") + (string-append (getenv "HOME") "/.config"))) (he-path (string-append (getenv "HOME") "/.guix-home")) (new-he-path (string-append he-path ".new")) @@ -117,13 +117,24 @@ (define ((file-tree-traverse preordering) node) (lambda (path) (readlink (string-append new-files-path "/" path)))) + (preprocess-path + (lambda (path) + "If file is in xdg-configuration-files-subdir use +subdirectory from XDG_CONFIG_HOME to generate a target path." + (if (string-prefix? #$xdg-configuration-files-subdir path) + (string-append + (substring xdg-config-home (1+ (string-length home-path))) + (substring + path (string-length #$xdg-configuration-files-subdir))) + (string-append "." path)))) + (get-target-path (lambda (path) - (string-append home-path "/." path))) + (string-append home-path "/" (preprocess-path path)))) (get-backup-path (lambda (path) - (string-append backup-dir "/." path))) + (string-append backup-dir "/" (preprocess-path path)))) (directory? (lambda (path) @@ -224,6 +235,12 @@ (define ((file-tree-traverse preordering) node) (display (G_ " done\n")))) to-create))))) + (format #t "home-path: ~a\nxdg-config-home: ~a\n" + home-path xdg-config-home) + + (format #t "prepr: ~a\n" + (preprocess-path "config/sway/config")) + (when old-tree (cleanup-symlinks)) -- 2.34.0