]> git.ekhem.eu.org Git - guix.git/commitdiff
[home] Symlink dotfiles using a service.
authorJakub Czajka <jakub@ekhem.eu.org>
Fri, 3 Jun 2022 20:49:56 +0000 (22:49 +0200)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:53:07 +0000 (19:53 +0100)
This commit adds a custom service-type for symlinking files. It uses
it to symlink profile.d scripts.

conf/home/symlink.scm [new file with mode: 0644]
home.scm

diff --git a/conf/home/symlink.scm b/conf/home/symlink.scm
new file mode 100644 (file)
index 0000000..10183f1
--- /dev/null
@@ -0,0 +1,32 @@
+;; 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}.")))
index ac5b1134225f3aa16eaec0c7700ab0e6c454c91f..b271bb6422d44da1ae354ab9f62145a980236741 100644 (file)
--- a/home.scm
+++ b/home.scm
@@ -4,6 +4,7 @@
 ;; home.scm - home directory configuration for GNU Guix.
 
 (use-modules (conf home bash)
+            (conf home symlink)
              (gnu home services)
             (gnu packages base)
             (guix gexp))
@@ -14,4 +15,6 @@
   (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")))))