home: Add bash home type. * home/bash.scm: New file. * doc/bash.scm: New file. * doc/README.md: Add it.
doc/README.md
| 60 | 60 | * [KeepassXC](doc/keepassxc.md) | |
| 61 | 61 | * [OpenSSH](doc/ssh.md) | |
| 62 | 62 | ||
| 63 | + | #### Shell Software | |
| 64 | + | ||
| 65 | + | * [Bash](doc/bash.md) | |
| 66 | + | ||
| 63 | 67 | ### Common Issues | |
| 64 | 68 | ||
| 65 | 69 | #### No Sound on the System |
doc/bash.md unknown status 1
| 1 | + | Bash | |
| 2 | + | ==== | |
| 3 | + | ||
| 4 | + | Bash is the default shell on Guix. This lets you configure your shell | |
| 5 | + | environment and set it up properly. | |
| 6 | + | ||
| 7 | + | Main Configuration | |
| 8 | + | ------------------ | |
| 9 | + | ||
| 10 | + | Bash is configured by using the `bash-home-type` service type. | |
| 11 | + | ||
| 12 | + | **Scheme Procedure**: bash-home-type | |
| 13 | + | ||
| 14 | + | The type of service that generates configuration files for bash. Its value | |
| 15 | + | is a bash-configuration object. | |
| 16 | + | ||
| 17 | + | **Data Type**: bash-configuration | |
| 18 | + | ||
| 19 | + | Data type that represents the Bash configuration. This data type has the | |
| 20 | + | following fields: | |
| 21 | + | ||
| 22 | + | * **rc** (default *default-bashrc*): the content of the `.bashrc` file. This is | |
| 23 | + | a list of strings and | |
| 24 | + | * **profile** (default *default-bash-profile*): the content of the `.bash_profile` | |
| 25 | + | file. | |
| 26 | + | * **history** (default #f): the location of the `.bash_history` file for saving | |
| 27 | + | history. The location must be read-write accessible to your user. | |
| 28 | + | ||
| 29 | + | Example Configuration | |
| 30 | + | --------------------- | |
| 31 | + | ||
| 32 | + | ```scheme | |
| 33 | + | (user-home | |
| 34 | + | bash-home-type | |
| 35 | + | (bash-configuration | |
| 36 | + | (rc (append default-bashrc | |
| 37 | + | '("alias vim=nvim"))) | |
| 38 | + | (profile (append default-bash-profile | |
| 39 | + | `("EDITOR=nvim\n" | |
| 40 | + | ;; Minetest would not work without this :/ | |
| 41 | + | "export MINETEST_SUBGAME_PATH=" | |
| 42 | + | ,(@@ (gnu packages games) minetest-data) | |
| 43 | + | "/share/minetest/games/"))) | |
| 44 | + | (history "/data/alice/.local/share/bash/history"))) | |
| 45 | + | ``` |
home/bash.scm unknown status 1
| 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/2.2:$GUILE_LOAD_PATH | |
| 61 | + | export GUILE_LOAD_COMPILED_PATH=~/.config/guix/current/lib/guile/2.2/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)))))))))))) |