diff options
author | Ryan Schanzenbacher <ryan@rschanz.org> | 2024-04-10 20:13:45 -0400 |
---|---|---|
committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2024-04-10 20:13:45 -0400 |
commit | 9026be364d5e7ec04c739bfbc5fcc20b03bddf43 (patch) | |
tree | 486c2ca7e1a0fd15739be9d37dd7774b62fb948a /modules/ryan-services/file-manager.scm | |
parent | b88d77fb2d0d5028a6f5670695dee6bec129501f (diff) |
FISH
Diffstat (limited to 'modules/ryan-services/file-manager.scm')
-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)) | ||