From 403643f980af5424e56e34afb4bc93d59ecd9c39 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 30 May 2018 22:18:15 -0700 Subject: [PATCH] Remove pyenv and other NixOS tweaks --- dotfiles/lib/setup_functions.sh | 47 +++++++++++++-------------------- dotfiles/lib/shellpath.sh | 15 +---------- dotfiles/xprofile | 4 ++- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/dotfiles/lib/setup_functions.sh b/dotfiles/lib/setup_functions.sh index f8b2ccba..e98a4d67 100644 --- a/dotfiles/lib/setup_functions.sh +++ b/dotfiles/lib/setup_functions.sh @@ -14,35 +14,17 @@ function shell_contains () { return 1 } -function _set_python_command { - # See comment in add_to_path about why this is necessary - if command_exists pyenv; - then - _python_command="$(pyenv which python)" - else - which pyenv - _python_command="$(which python)" - fi - shell_contains "$_python_command" "shim" && \ - echo "Warning: setting python command to shim" -} - function environment_variable_exists { eval "value=\"\${$1+x}\"" [ ! -z $value ] } function setup_unless_environment_variable_exists { - environment_variable_exists "$1" || $2 - export "$1=$(date)" + environment_variable_exists "$1" || { $2 && export "$1=$(date)"; } } function add_to_path { - environment_variable_exists _python_command || _set_python_command - # We need to get a path to the ACTUAL python command because - # pyenv alters PATH before actually executing python, which ends - # up changing PATH in a way that is not desireable. - eval "$($_python_command $HOME/.lib/python/shell_path.py --include-assignment "$@")" + eval "$(python $HOME/.lib/python/shell_path.py --include-assignment "$@")" } # Taken from http://www.unix.com/shell-programming-and-scripting/27932-how-know-linux-distribution-i-am-using.html @@ -65,6 +47,11 @@ function get_linux_distro { [ -n "$dist" ] && echo "$dist" && return 0 fi + if [ -r /etc/os-release ]; then + dist=$(grep 'ID=' /etc/os-release | sed 's/ID=//' | head -1) + [ -n "$dist" ] && echo "$dist" && return 0 + fi + dist=$(find /etc/ -maxdepth 1 -name '*release' 2> /dev/null | sed 's/\/etc\///' | sed 's/-release//' | head -1) [ -n "$dist" ] && echo "$dist" && return 0 @@ -75,14 +62,18 @@ function get_linux_distro { function is_osx() { - case `uname` in - 'Darwin') - return 0 - ;; - *) - return 1; - ;; - esac + if command_exists uname; then + case `uname` in + 'Darwin') + return 0; + ;; + *) + return 1; + ;; + esac + else + return 1 + fi } function source_directory_files { diff --git a/dotfiles/lib/shellpath.sh b/dotfiles/lib/shellpath.sh index 0815cafa..4243636e 100644 --- a/dotfiles/lib/shellpath.sh +++ b/dotfiles/lib/shellpath.sh @@ -3,10 +3,6 @@ source "$HOME/.lib/setup_functions.sh" function _setup_path { _path_helper - # XXX/TODO: - # This is in shellenv.sh now - _python_setup - add_to_path "$HOME/.lib/bin" "$HOME/.local/bin" "$HOME/bin" --before add_to_path "/usr/local/sbin" "/usr/local/bin" "/usr/bin" --after _ruby_setup @@ -16,6 +12,7 @@ function _setup_path { _haskell_setup _java_setup _go_setup + _python_setup _racket_setup _rust_setup _tex_setup @@ -49,17 +46,7 @@ function _osx_path_setup { } function _python_setup { - export PYENV_ROOT="/usr/local/var/pyenv" - - if which pyenv > /dev/null; then - eval "$(pyenv init - --no-rehash)" - else - echo "WARNING: pyenv is not installed on this machine and python will likely not function correctly" - fi - add_to_path "$HOME/.lib/python" --after - # if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi - add_to_path "$HOME/.lib/python" --path-var 'PYTHONPATH' } diff --git a/dotfiles/xprofile b/dotfiles/xprofile index 95704b81..34526974 100644 --- a/dotfiles/xprofile +++ b/dotfiles/xprofile @@ -1,7 +1,9 @@ # -*- mode: sh; -*- + # If there are issues with path, check /etc/profile for hard overrides of PATH. -source "$HOME/.lib/login.sh" +. "$HOME/.lib/login.sh" # XXX: prevents https://github.com/xmonad/xmonad/issues/86 from affecting startup + rm -f ~/.xmonad/xmonad.state load_xkb_map.sh