bash.scm
| 1 | ;;; Guix Home Manager. |
| 2 | ;;; |
| 3 | ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> |
| 4 | ;;; |
| 5 | ;;; This program is free software: you can redistribute it and/or modify |
| 6 | ;;; it under the terms of the GNU General Public License as published by |
| 7 | ;;; the Free Software Foundation, either version 3 of the License, or |
| 8 | ;;; (at your option) any later version. |
| 9 | ;;; |
| 10 | ;;; This program is distributed in the hope that it will be useful, |
| 11 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ;;; GNU General Public License for more details. |
| 14 | ;;; |
| 15 | ;;; You should have received a copy of the GNU General Public License |
| 16 | ;;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | (define-module (home bash) |
| 19 | #:use-module (guix build utils) |
| 20 | #:use-module (guix gexp) |
| 21 | #:use-module (guix records) |
| 22 | #:use-module (gnu packages lxde) |
| 23 | #:use-module (ice-9 match) |
| 24 | #:use-module (home) |
| 25 | #:export (bash-configuration |
| 26 | bash-configuration-rc |
| 27 | bash-configuration-profile |
| 28 | bash-configuration-history |
| 29 | |
| 30 | default-bashrc |
| 31 | default-bash-profile |
| 32 | |
| 33 | bash-home-type)) |
| 34 | |
| 35 | (define default-bashrc |
| 36 | `("export SHELL |
| 37 | |
| 38 | if [[ $- != *i* ]]; then |
| 39 | # Non interative shell. For SSH session, load /etc/profile to get |
| 40 | # PATH and other variables set up. |
| 41 | [[ -n \"$SSH_CLIENT\" ]] && source /etc/profile |
| 42 | return |
| 43 | fi |
| 44 | |
| 45 | source /etc/bashrc |
| 46 | |
| 47 | if [ -n \"$GUIX_ENVIRONMENT\" ]; then |
| 48 | PS1='\\u@\\h \\w [env]\\$ ' |
| 49 | else |
| 50 | PS1='\\u@\\h \\w\\$ ' |
| 51 | fi |
| 52 | alias ls='ls -p --color=auto' |
| 53 | alias ll='ls -l' |
| 54 | alias grep='grep --color=auto' |
| 55 | ")) |
| 56 | |
| 57 | (define default-bash-profile |
| 58 | `("if [ -f ~/.bashrc ]; then . ~/.bashrc; fi |
| 59 | # Workaround guix bug (not adding load path before processing the command name) |
| 60 | export GUILE_LOAD_PATH=~/.config/guix/current/share/guile/site/3.0:$GUILE_LOAD_PATH |
| 61 | export GUILE_LOAD_COMPILED_PATH=~/.config/guix/current/lib/guile/3.0/site-ccache:\ |
| 62 | $GUILE_LOAD_COMPILED_PATH |
| 63 | ")) |
| 64 | |
| 65 | (define-record-type* <bash-configuration> |
| 66 | bash-configuration make-bash-configuration |
| 67 | bash-configuration? |
| 68 | (rc bash-configuration-rc |
| 69 | (default default-bashrc)) |
| 70 | (profile bash-configuration-profile |
| 71 | (default default-bash-profile)) |
| 72 | (history bash-configuration-history)) |
| 73 | |
| 74 | (define bash-home-type |
| 75 | (home-type |
| 76 | (name 'bash) |
| 77 | (extensions |
| 78 | (list |
| 79 | (home-extension |
| 80 | (target root-home-type) |
| 81 | (compute |
| 82 | (lambda (config) |
| 83 | (match config |
| 84 | (($ <bash-configuration> rc profile history) |
| 85 | (let ((bashrc (apply mixed-text-file "bashrc" rc)) |
| 86 | (bash-profile (apply mixed-text-file "bash-profile" profile))) |
| 87 | `((".bash_history" ,history) |
| 88 | (".bashrc" ,bashrc) |
| 89 | (".bash_profile" ,bash-profile)))))))))))) |
| 90 |