--- /dev/null
+;; Copyright (c) 2022 Jakub Czajka <jakub@ekhem.eu.org>
+;; License: GPL-3.0 or later.
+;;
+;; symlink.scm - service for symlinking files.
+
+(define-module (conf home symlink)
+ #:use-module (gnu home services)
+ #:use-module (gnu services configuration)
+ #:use-module (guix gexp)
+ #:use-module (guix packages)
+ #:export (home-symlink-service-type))
+
+(define (symlink paths)
+ (define (make-symlink-pair path)
+ (let ((file (local-file path))
+ (first-slash (string-index path #\/)))
+ (if first-slash
+ (list (substring path (+ first-slash 1))
+ file)
+ (list path file))))
+
+ (map make-symlink-pair paths))
+
+(define home-symlink-service-type
+ (service-type (name 'home-profile)
+ (extensions
+ (list (service-extension home-files-service-type
+ symlink)))
+ (default-value '())
+ (description "Copies files to the guix store and symlinks them in
+the home directory. For a @path{a/b/c/d.ext}, creates a @file{d.ext} file in the
+guix store and symlinks it as @file{~/b/c/d.ext}.")))
;; home.scm - home directory configuration for GNU Guix.
(use-modules (conf home bash)
+ (conf home symlink)
(gnu home services)
(gnu packages base)
(guix gexp))
(list (service home-bash-service-type
(home-bash-configuration
(bash-profile "bash/.bash_profile")
- (bashrc "bash/.bashrc"))))))
+ (bashrc "bash/.bashrc")))
+ (service home-symlink-service-type
+ (list "bash/.config/profile.d/10-xdg.sh")))))