From de934655193382dac3f7a63cf37cc1af285972e2 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Fri, 3 Jun 2022 22:49:56 +0200 Subject: [PATCH] [home] Symlink dotfiles using a service. This commit adds a custom service-type for symlinking files. It uses it to symlink profile.d scripts. --- conf/home/symlink.scm | 32 ++++++++++++++++++++++++++++++++ home.scm | 5 ++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 conf/home/symlink.scm diff --git a/conf/home/symlink.scm b/conf/home/symlink.scm new file mode 100644 index 0000000..10183f1 --- /dev/null +++ b/conf/home/symlink.scm @@ -0,0 +1,32 @@ +;; Copyright (c) 2022 Jakub Czajka +;; 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}."))) diff --git a/home.scm b/home.scm index ac5b113..b271bb6 100644 --- 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"))))) -- 2.39.5