From 1cc6df732f266f1623196ed80d4c5861150f8fa1 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Sun, 29 May 2022 22:49:48 +0200 Subject: [PATCH] [home] Install bash and symlink its dotfiles. `home-bash-service-type` installs bash. This commit configures the service through `home-bash-configuration` to symlink .bashrc and .bash_profile. --- home.scm | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/home.scm b/home.scm index 8eab708..92ab5cf 100644 --- a/home.scm +++ b/home.scm @@ -3,6 +3,48 @@ ;; ;; home.scm - home directory configuration for GNU Guix. -(use-modules (gnu home)) +(use-modules (gnu home) + (gnu home services) + (gnu home services shells) + (gnu packages base) + (gnu services) + (guix gexp) + (guix utils) + (ice-9 textual-ports)) -(home-environment) +(define (read-file file) + "Returns contents of FILE as a string." + (unless (access? file R_OK) + (error "Can't access file: " file)) + (call-with-input-file file get-string-all)) + +(define (expand-file-name file dir) + "If FILE is an absolute path, returns FILE. Otherwise, prepends DIR." + (if (absolute-file-name? file) + file + (string-append dir "/" file))) + +(define dot-bash-profile + (plain-file + "bash-profile" + (read-file + (expand-file-name "bash/.bash_profile" (current-source-directory))))) + +(define dot-bashrc + (plain-file + "bashrc" + (read-file + (expand-file-name "bash/.bashrc" (current-source-directory))))) + +(home-environment + (packages (list)) + (services + (list + ;; `local-file` for `.bashrc` causes an error. A workaround it to load + ;; `.bashrc`, put it in a `plain-file` (`dot-bashrc`) and then pass it as + ;; argument. + (service home-bash-service-type + (home-bash-configuration + (guix-defaults? #f) + (bash-profile (list dot-bash-profile)) + (bashrc (list dot-bashrc))))))) -- 2.39.5