]> git.ekhem.eu.org Git - guix.git/commitdiff
[home] Install bash and symlink its dotfiles.
authorJakub Czajka <jakub@ekhem.eu.org>
Sun, 29 May 2022 20:49:48 +0000 (22:49 +0200)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:53:07 +0000 (19:53 +0100)
`home-bash-service-type` installs bash. This commit configures the
service through `home-bash-configuration` to symlink .bashrc and
.bash_profile.

home.scm

index 8eab7085cb83c2be10ef061dfe9a43ee9cae59fb..92ab5cffbdbc37d680c183718d169d9f681a105c 100644 (file)
--- 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)))))))