Differentiate between host-specific startup progs and profiles
[~bandali/configs] / .profile
index edd38a3..c4b9019 100644 (file)
--- a/.profile
+++ b/.profile
-#PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
-#PATH=$HOME/.gem/ruby/2.4.0/bin:$PATH
-export PATH=$HOME/.local/bin:$HOME/.cabal/bin:$HOME/.cargo/bin:$HOME/.elan/bin:$PATH
-export XDG_CONFIG_HOME=$HOME/.config
-export XDG_DATA_HOME=$HOME/.local/share
-export XDG_DATA_DIRS=/usr/local/share:/usr/share
+# ~/.profile: executed by the command interpreter for login shells.
+# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
+# exists.
+# see /usr/share/doc/bash/examples/startup-files for examples.
+# the files are located in the bash-doc package.
+
+# the default umask is set in /etc/profile; for setting the umask
+# for ssh logins, install and configure the libpam-umask package.
+#umask 022
+
+# source host-specific profile
+if [ -f "$HOME/.config/$(hostname).profile" ]; then
+    . "$HOME/.config/$(hostname).profile"
+fi
+
+export EDITOR="emacsclient -nw"
+export VISUAL="emcl"
+export GPG_TTY=$(tty)
+
+PATH="$HOME/.cabal/bin:$HOME/.cargo/bin:$HOME/.elan/bin:$PATH"
+if [ -z "$IS_GUIX_SYSTEM" ]; then
+    PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
+    INFOPATH="$HOME/.config/guix/current/share/info${INFOPATH:+:}$INFOPATH"
+    export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
+fi
+export PATH
+export INFOPATH
+
+export MY_GUIX_MANIFESTS="$HOME/.config/guix/manifest"
+export MY_GUIX_PROFILES="$HOME/.config/guix/profile"
+
+export XDG_CONFIG_HOME="$HOME/.config"
+export XDG_DATA_HOME="$HOME/.local/share"
+
+if [ -f "$HOME/.config/user-dirs.dirs" ]; then
+    set -a
+    . "$HOME/.config/user-dirs.dirs"
+    set +a
+fi
+
+export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc
+export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc
+
 export MAILDIR="$HOME/mail"
-export CVS_RSH=ssh
-#export MATHMODELS=$HOME/src/eiffel/mathmodels
-#export RUST_SRC_PATH=~/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src
-#export PATH=$PATH:$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/
+export CVS_RSH="ssh"
+
+if [ -x "$(command -v go)" ]; then
+    export GOPATH="$HOME/s/go"
+    export PATH="$GOPATH/bin:$PATH"
+fi
 
-# Eiffel2Java stuff
-#export JAVA_HOME=/usr/lib/jvm/default
-#export CPATH=$CPATH:"$JAVA_HOME/include:$JAVA_HOME/include/linux"
-#export LIBRARY_PATH=$LIBRARY_PATH:"$JAVA_HOME/jre/lib/amd64/server"
-#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$JAVA_HOME/jre/lib/amd64/server"
+export _JAVA_AWT_WM_NONREPARENTING=1
+export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true'
+#export MOZ_USE_XINPUT2=1  # precise scrolling in firefox
 
-#export PATH="$HOME/usr/build/pvs:$PATH"
-#export SBCLISP_HOME=/usr/share/sbcl-source
-#export PVS_LIBRARY_PATH="$HOME/usr/build/pvs/nasalib"
+# if running bash
+if [ -n "$BASH_VERSION" ]; then
+    # include .bashrc if it exists
+    if [ -f "$HOME/.bashrc" ]; then
+       . "$HOME/.bashrc"
+    fi
+fi
 
-export MOZ_USE_XINPUT2=1  # precise scrolling in firefox
+if [ -z "$IS_GUIX_SYSTEM" ]; then
+    # if guix is installed
+    if [ -x "$(command -v guix)" ]; then
+        SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
+        if [ -d "$SSL_CERT_DIR" -o -h "$SSL_CERT_DIR" ]; then
+            export SSL_CERT_DIR
+            export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
+        else
+            printf "it seems you forgot to \`guix install nss-certs\'\n"
+        fi
+        GUIX_PROFILE="$HOME/.guix-profile"
+        . "$GUIX_PROFILE/etc/profile"
+        unset XDG_DATA_DIRS
+    fi
+fi
 
-#export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
-#export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
+for p in $MY_GUIX_PROFILES/*; do
+    profile=$p/$(basename "$p")
+    if [ -f "$profile"/etc/profile ]; then
+        GUIX_PROFILE="$profile"
+        . "$GUIX_PROFILE"/etc/profile
+    fi
+    unset profile
+done
 
-export NIXPKGS=$HOME/src/git/nixpkgs
+export PATH="$HOME/u/local/bin:$HOME/.local/bin:$PATH"
 
-if [ -e /home/amin/.nix-profile/etc/profile.d/nix.sh ]; then . /home/amin/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
+# start an ssh-agent (with guix's openssh)
+if [ -z "$IS_GUIX_SYSTEM" ]; then
+    if ! pgrep -u "$USER" ssh-agent > /dev/null; then
+        rm -f ~/.ssh-agent-thing
+        ssh-agent > ~/.ssh-agent-thing
+    fi
+    if [[ ! "$SSH_AUTH_SOCK" ]]; then
+        eval "$(<~/.ssh-agent-thing)"
+    fi
+fi
 
-export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
-export PATH="/$HOME/.config/guix/current/bin${PATH:+:}$PATH"
-export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
-export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
-export GIT_SSL_CAINFO="$SSL_CERT_FILE"
+# footenote: when on a foreign distro and using Xfce, don't forget to
+# disable its auto-start of gpg- and ssh-agent, by issuing
+#     xfconf-query -c xfce4-session -p /startup/ssh-agent/enabled -n -t bool -s false
+#     xfconf-query -c xfce4-session -p /startup/gpg-agent/enabled -n -t bool -s false
+# see https://docs.xfce.org/xfce/xfce4-session/advanced#ssh_and_gpg_agents
+# also, MATE does something similar with gnome-keyring-daemon:
+# http://william.shallum.net/random-notes/disabling-gnome-keyring-daemon-ssh-agent-on-mate-desktop