guix-dotfiles/modules/ryan-services/file-manager.scm
2024-04-10 20:13:45 -04:00

26 lines
1.2 KiB
Scheme

(define-module (ryan-services file-manager)
#:use-module (gnu packages)
#:use-module (gnu packages base)
#:use-module (gnu services)
#:use-module (gnu services configuration)
#:use-module (gnu home services)
#:use-module (gnu home services shepherd)
#:use-module (srfi srfi-1)
#:use-module (guix gexp))
(define-public (home-symlinks files)
;; Simple service to symlink two paths. Treats all paths with HOME prepended
(for-each (lambda (pair)
(let ((path1 (car pair))
(path2 (cadr pair)))
(let ((full-path1 (string-append (getenv "HOME") "/" path1))
(full-path2 (string-append (getenv "HOME") "/" path2)))
(if (file-exists? full-path2)
(if (eq? (stat:type (lstat full-path2)) 'regular)
((display (format #f "WARNING: Deleting regular file ~a.\n" full-path2))
(delete-file full-path2)
(symlink full-path1 full-path2))
#f)
(symlink full-path1 full-path2)))))
files))