modules/ryan-services/file-manager.scm
f3ee8355e3b453fc14ac3d6b63fb7368798d66d7
· 1.2 KB · 25 lines
raw
| 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)) |