diff --git a/files/home/.bash_profile b/files/home/.bash_profile index bdcaeef..13f4ff7 100644 --- a/files/home/.bash_profile +++ b/files/home/.bash_profile @@ -1,6 +1,6 @@ # Load .profile, containing login, non-bash related initializations. [ -f "$HOME/.profile" ] && source "$HOME/.profile" -export NVM_DIR="$HOME/.nvm" +export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion diff --git a/files/home/.zshrc b/files/home/.zshrc new file mode 100644 index 0000000..e69de29 diff --git a/script/_utils.sh b/script/_utils.sh index 3bb73f1..4ec0b31 100755 --- a/script/_utils.sh +++ b/script/_utils.sh @@ -31,10 +31,6 @@ function apt_installed { dpkg --status $1 >/dev/null } -function clean { - sudo apt-get clean -qq -} - function update { sudo apt-get update -qq } diff --git a/script/install.d/00-os_info.sh b/script/install.d/00-os_info.sh index 57719f3..4e48e76 100755 --- a/script/install.d/00-os_info.sh +++ b/script/install.d/00-os_info.sh @@ -9,4 +9,6 @@ if [[ "$OSTYPE" == "darwin"* ]]; then sw_vers elif [[ "$OSTYPE" == "linux-gnu"* ]]; then lsb_release -a +else + echo "Unknown OS: $OSTYPE" fi diff --git a/script/install.d/02-brew.sh b/script/install.d/02-brew.sh new file mode 100755 index 0000000..935a74a --- /dev/null +++ b/script/install.d/02-brew.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# Description: +# (macOS only) Install homebrew. +# + +if [[ "$OSTYPE" == "darwin"* ]]; then + export NONINTERACTIVE=1 + if ! bin_in_path brew; then + download_run https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh /bin/bash + else + brew update + fi + + brew --version + + unset NONINTERACTIVE +fi diff --git a/script/install.d/02-zsh.sh b/script/install.d/02-zsh.sh deleted file mode 100755 index c94e36a..0000000 --- a/script/install.d/02-zsh.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# ----------------------------------------------------------------------------- -# Description: -# Install zsh shell. - - diff --git a/script/install.d/03-nerdfont.sh b/script/install.d/03-nerdfont.sh new file mode 100755 index 0000000..a7508a3 --- /dev/null +++ b/script/install.d/03-nerdfont.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# Description: +# (macOS only) Install nerdfonts. +# + +if [[ "$OSTYPE" == "darwin"* ]]; then + fonts_list=( + font-fira-mono-nerd-font + font-fira-code-nerd-font + ) + + brew tap homebrew/cask-fonts + for font in "${fonts_list[@]}"; do + brew install --cask "$font" + done + + unset fonts_list +fi diff --git a/script/install.d/04-zsh.sh b/script/install.d/04-zsh.sh new file mode 100755 index 0000000..a8e41be --- /dev/null +++ b/script/install.d/04-zsh.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# Description: +# Configure zsh shell. +# + +if ! bin_in_path zsh; then + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + install zsh + fi +fi + +zsh --version diff --git a/script/install.d/10-pyenv.sh b/script/install.d/10-pyenv.sh index f1afff3..a457cc1 100755 --- a/script/install.d/10-pyenv.sh +++ b/script/install.d/10-pyenv.sh @@ -1,20 +1,35 @@ #!/usr/bin/env bash -if ! bin_in_path "pyenv"; then - # see https://github.com/pyenv/pyenv/wiki/common-build-problems - pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist" - install_file "$pyenv_list_file" - # see https://github.com/pyenv/pyenv-installer - download_run \ - "https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \ - bash +# ----------------------------------------------------------------------------- +# Description: +# Configure pyenv. +# + +if ! bin_in_path "pyenv"; then + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + # see https://github.com/pyenv/pyenv/wiki/common-build-problems + pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist" + install_file "$pyenv_list_file" + + # see https://github.com/pyenv/pyenv-installer + download_run \ + "https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \ + bash +e + unset pyenv_list_file + elif [[ "$OSTYPE" == "darwin"* ]]; then + brew install pyenv + brew install pyenv-virtualenv + fi fi -virtualenv_path="$(pyenv root)/plugins/pyenv-virtualenv" -if [ ! -d "$virtualenv_path" ]; then - git clone \ - https://github.com/pyenv/pyenv-virtualenv.git \ - $virtualenv_path +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + virtualenv_path="$(pyenv root)/plugins/pyenv-virtualenv" + if [ ! -d "$virtualenv_path" ]; then + git clone \ + https://github.com/pyenv/pyenv-virtualenv.git \ + $virtualenv_path + fi fi eval "$(pyenv init --path)" diff --git a/script/install.d/11-python.sh b/script/install.d/11-python.sh index 270c669..f10e650 100755 --- a/script/install.d/11-python.sh +++ b/script/install.d/11-python.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# Description: +# Configure Python. +# + export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring if ! bin_in_path "pip3"; then diff --git a/script/install.d/12-node.sh b/script/install.d/12-node.sh index d3cff76..0286127 100755 --- a/script/install.d/12-node.sh +++ b/script/install.d/12-node.sh @@ -1,22 +1,33 @@ #!/usr/bin/env bash -nvm_version="v0.38.0" + +# ----------------------------------------------------------------------------- +# Description: +# Configure Node.js. +# + +nvm_version="0.39.7" if ! bin_in_path "nvm"; then - download_run "https://raw.githubusercontent.com/nvm-sh/nvm/${nvm_version}/install.sh" \ + download_run "https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh" \ "bash" fi +NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" nvm --version -nvm alias default lts/fermium -nvm install lts/fermium -nvm use lts/fermium +nvm alias default lts/iron +nvm install lts/iron +nvm use lts/iron node --version yarn --version -for dep in $(jq -r ".node_dependencies[]" $CONFIG); do - yarn global add $dep - yarn global upgrade $dep -done +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + for dep in $(jq -r ".node_dependencies[]" $CONFIG); do + yarn global add $dep + yarn global upgrade $dep + done +fi + +unset nvm_version diff --git a/script/install.d/20-docker.sh b/script/install.d/20-docker.sh index 3d9ad2e..a068a4d 100755 --- a/script/install.d/20-docker.sh +++ b/script/install.d/20-docker.sh @@ -1,13 +1,23 @@ #!/usr/bin/env bash -docker --version -readonly docker_group="docker" -if ! grep -q "$docker_group" /etc/group; then - echo "Adding docker group" - sudo groupadd "$docker_group" -fi +# ----------------------------------------------------------------------------- +# Description: +# (Ubuntu only) Configure docker. +# -if ! groups "$USER" | grep -q "\b$docker_group\b"; then - echo "Adding user to docker group" - sudo usermod -aG docker "$USER" +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + docker --version + + readonly docker_group="docker" + if ! grep -q "$docker_group" /etc/group; then + echo "Adding docker group" + sudo groupadd "$docker_group" + fi + + if ! groups "$USER" | grep -q "\b$docker_group\b"; then + echo "Adding user to docker group" + sudo usermod -aG docker "$USER" + fi + + unset docker_group fi diff --git a/script/install.d/98-apt-clean.sh b/script/install.d/98-apt-clean.sh deleted file mode 100755 index 00c4492..0000000 --- a/script/install.d/98-apt-clean.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -clean diff --git a/script/install.d/98-clean.sh b/script/install.d/98-clean.sh new file mode 100755 index 0000000..28f501a --- /dev/null +++ b/script/install.d/98-clean.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# Description: +# Clean up after installation. +# + +if [[ "$OSTYPE" == "darwin"* ]]; then + brew cleanup +elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo apt-get autoremove -qq + sudo apt-get clean -qq +fi \ No newline at end of file diff --git a/script/install.d/99-screenfetch.sh b/script/install.d/99-screenfetch.sh index 7563217..180fa04 100755 --- a/script/install.d/99-screenfetch.sh +++ b/script/install.d/99-screenfetch.sh @@ -1,2 +1,8 @@ #!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# Description: +# Print system information. +# + screenfetch