user-profile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # -*- mode: sh -*-
  2. ################################################################
  3. ### Environment
  4. MY_GUIX_PROFILE_NAMES="main build misc guile games fonts emacs"
  5. export MY_CONFIG_DIR="$HOME/config"
  6. export MY_GUILE_DIR="$MY_CONFIG_DIR/guile"
  7. export MY_GUIX_DIR="$MY_CONFIG_DIR/guix"
  8. export MY_SHELL_DIR="$MY_CONFIG_DIR/shell"
  9. export MY_PATH="$HOME/bin:$MY_GUILE_DIR/scripts:$MY_SHELL_DIR/scripts:$MY_CONFIG_DIR/guile-daemon/scripts"
  10. export MY_GUIX_PROFILES_DIR="$HOME/.guix-profiles"
  11. export MY_GUIX_USER_PROFILE_DIR="$MY_GUIX_PROFILES_DIR/main/main"
  12. export MY_GUIX_SYSTEM_PROFILE_DIR="/run/current-system/profile"
  13. add_dir_to_var_if_exists () {
  14. # Add directory $1 (if it exists) to environment variable $2.
  15. [ -d "$1" ] && eval $(echo "$2=$1:\$$2")
  16. }
  17. display_file_if_exists () {
  18. [ -a "$1" ] && echo "$1"
  19. }
  20. display_guix_profiles_paths () {
  21. for name in $MY_GUIX_PROFILE_NAMES
  22. do
  23. display_file_if_exists "$MY_GUIX_PROFILES_DIR/$name/$name"
  24. done
  25. display_file_if_exists "$MY_GUIX_SYSTEM_PROFILE_DIR"
  26. }
  27. set_guix_env () {
  28. # Calculate environment for all Guix profiles and add it to the
  29. # current environment.
  30. guix=$(PATH="$MY_PATH:$PATH" which guix)
  31. if [ $? -eq 0 ]; then # if 'guix' executable is found
  32. env_cmd="$guix package --search-paths=prefix"
  33. for path in $(display_guix_profiles_paths)
  34. do
  35. env_cmd="$env_cmd --profile=$path"
  36. # XXX Currently XDG_... variables are not set by 'guix
  37. # package --search-paths' command, so handle them manually.
  38. add_dir_to_var_if_exists "$path/share" xdg_data_dirs
  39. add_dir_to_var_if_exists "$path/etc/xdg" xdg_config_dirs
  40. done
  41. export XDG_DATA_DIRS="$xdg_data_dirs$XDG_DATA_DIRS"
  42. export XDG_CONFIG_DIRS="$xdg_config_dirs$XDG_CONFIG_DIRS"
  43. echo "Running: $env_cmd"
  44. eval $($env_cmd)
  45. fi
  46. }
  47. locale_dir="$MY_GUIX_PROFILES_DIR/locales/locales/lib/locale"
  48. [ -d "$locale_dir" ] && export GUIX_LOCPATH="$locale_dir"
  49. export LANG=en_US.UTF-8
  50. # Set some variables to default values if needed.
  51. [ ! -v MANPATH ] && [ -d /usr/share/man ] && export MANPATH=/usr/share/man
  52. [ ! -v XDG_DATA_DIRS ] && [ -d /usr/share ] && export XDG_DATA_DIRS=/usr/share
  53. [ ! -v XDG_CONFIG_DIRS ] && [ -d /etc/xdg ] && export XDG_CONFIG_DIRS=/etc/xdg
  54. set_guix_env
  55. if [ -d $MY_GUIX_SYSTEM_PROFILE_DIR ]; then # if it is GuixSD
  56. export PATH="/run/setuid-programs:$PATH"
  57. fi
  58. if [ -d $MY_GUIX_USER_PROFILE_DIR ]; then
  59. # Find GTK themes.
  60. export GTK_DATA_PREFIX="$MY_GUIX_USER_PROFILE_DIR"
  61. # Without this, other git outputs (like 'send-email') wouldn't work.
  62. export GIT_EXEC_PATH="$MY_GUIX_USER_PROFILE_DIR/libexec/git-core"
  63. aspell_dir="$MY_GUIX_USER_PROFILE_DIR/lib/aspell"
  64. if [ -d $aspell_dir ]; then
  65. # export ASPELL_CONF="data-dir $aspell_dir; dict-dir $aspell_dir"
  66. export ASPELL_CONF="dict-dir $aspell_dir"
  67. fi
  68. fi
  69. certs_dir=/var/guix/profiles/system/profile/etc/ssl/certs
  70. if [ -d "$certs_dir" ]; then
  71. export SSL_CERT_DIR="$certs_dir"
  72. export SSL_CERT_FILE="$certs_dir/ca-certificates.crt"
  73. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  74. fi
  75. export PATH="$MY_PATH:$PATH"
  76. export SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
  77. export GUIX_PACKAGE_PATH="$MY_GUIX_DIR/guix-package-path"
  78. misc_guile_dirs="$MY_GUILE_DIR/modules:$MY_GUIX_DIR/modules:$HOME/devel/guix:$HOME/devel/shepherd/modules"
  79. export GUILE_LOAD_PATH="$misc_guile_dirs${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
  80. export GUILE_LOAD_COMPILED_PATH="$misc_guile_dirs${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
  81. export EDITOR='emacsclient'
  82. export VIEWER='emacsclient'
  83. export XDG_CONFIG_HOME="$HOME/.config"
  84. export XDG_CACHE_HOME="$HOME/.cache"
  85. export XDG_DATA_HOME="$HOME/.local/share"
  86. # Always show normal scrollbars.
  87. export GTK_OVERLAY_SCROLLING=0
  88. # Prevent sox from using pulseaudio.
  89. export AUDIODRIVER=alsa
  90. # Without this, there is no sound in programs (usually games) that use
  91. # sdl-mixer (at least on GuixSD).
  92. export SDL_AUDIODRIVER=alsa
  93. ################################################################
  94. [[ -f ~/.bashrc ]] && . ~/.bashrc
  95. # Start shepherd if it is not already running.
  96. [[ -z $(pgrep -U $(id --user) "^shepherd$") ]] \
  97. && shepherd &>> $HOME/.config/shepherd/shepherd.log