;;
;; 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)))))))