diff options
Diffstat (limited to 'modules/ryan-services')
-rw-r--r-- | modules/ryan-services/file-manager.scm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/ryan-services/file-manager.scm b/modules/ryan-services/file-manager.scm new file mode 100644 index 0000000..9f0bdc4 --- /dev/null +++ b/modules/ryan-services/file-manager.scm | |||
@@ -0,0 +1,25 @@ | |||
1 | (define-module (ryan-services file-manager) | ||
2 | #:use-module (gnu packages) | ||
3 | #:use-module (gnu packages base) | ||
4 | #:use-module (gnu services) | ||
5 | #:use-module (gnu services configuration) | ||
6 | #:use-module (gnu home services) | ||
7 | #:use-module (gnu home services shepherd) | ||
8 | #:use-module (srfi srfi-1) | ||
9 | #:use-module (guix gexp)) | ||
10 | |||
11 | (define-public (home-symlinks files) | ||
12 | ;; Simple service to symlink two paths. Treats all paths with HOME prepended | ||
13 | (for-each (lambda (pair) | ||
14 | (let ((path1 (car pair)) | ||
15 | (path2 (cadr pair))) | ||
16 | (let ((full-path1 (string-append (getenv "HOME") "/" path1)) | ||
17 | (full-path2 (string-append (getenv "HOME") "/" path2))) | ||
18 | (if (file-exists? full-path2) | ||
19 | (if (eq? (stat:type (lstat full-path2)) 'regular) | ||
20 | ((display (format #f "WARNING: Deleting regular file ~a.\n" full-path2)) | ||
21 | (delete-file full-path2) | ||
22 | (symlink full-path1 full-path2)) | ||
23 | #f) | ||
24 | (symlink full-path1 full-path2))))) | ||
25 | files)) | ||