feat: mac install support
This commit is contained in:
29
README.md
29
README.md
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
[](https://github.com/andrejusk/dotfiles/actions/workflows/ci.yml)
|
[](https://github.com/andrejusk/dotfiles/actions/workflows/ci.yml)
|
||||||
|
|
||||||
My collection of dotfiles and install scripts
|
A collection of dotfiles and install scripts
|
||||||
to set up development environments
|
to set up my development environment
|
||||||
🛠️ 📂️ 🚀
|
🛠️ 📂️ 🚀
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -12,16 +12,6 @@ A local repository can be installed by running:
|
|||||||
|
|
||||||
./script/install
|
./script/install
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>
|
|
||||||
Environment configuration for <code>install</code> script
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
| Variable | Description |
|
|
||||||
| --- | --- |
|
|
||||||
| `LOG_TARGET` | File to log installation output to (default: `~/.dotfiles/logs/install-{date}.log`) |
|
|
||||||
</details>
|
|
||||||
|
|
||||||
### Automated setup
|
### Automated setup
|
||||||
|
|
||||||
This repository can be installed without a local copy
|
This repository can be installed without a local copy
|
||||||
@@ -32,18 +22,3 @@ by invoking the `setup` script directly via `curl`:
|
|||||||
|
|
||||||
# Run
|
# Run
|
||||||
curl -s https://raw.githubusercontent.com/andrejusk/dotfiles/HEAD/script/setup | bash
|
curl -s https://raw.githubusercontent.com/andrejusk/dotfiles/HEAD/script/setup | bash
|
||||||
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>
|
|
||||||
Environment configuration for <code>setup</code> script
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
| Variable | Description |
|
|
||||||
| --- | --- |
|
|
||||||
| `DOTFILES_DIR` | Directory to clone the repository into (default: `~/.dotfiles`)
|
|
||||||
| `DOTFILES_SKIP_INSTALL` | Skip running the install script (default: `false`)
|
|
||||||
| `GITHUB_AUTHOR` | GitHub username to use for cloning repositories (default: `andrejusk`) |
|
|
||||||
| `GITHUB_REPO` | GitHub repository name to clone (default: `dotfiles`)
|
|
||||||
| `GITHUB_BRANCH` | GitHub branch to clone (default: `master`)
|
|
||||||
</details>
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ plugins=(
|
|||||||
emoji
|
emoji
|
||||||
git
|
git
|
||||||
history
|
history
|
||||||
|
poetry
|
||||||
zsh-autosuggestions
|
zsh-autosuggestions
|
||||||
zsh-syntax-highlighting
|
zsh-syntax-highlighting
|
||||||
)
|
)
|
||||||
@@ -25,3 +26,7 @@ source $ZSH/oh-my-zsh.sh
|
|||||||
|
|
||||||
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||||
|
|
||||||
|
export NVM_DIR="$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
|
||||||
|
|||||||
@@ -5,17 +5,21 @@ set -eo pipefail
|
|||||||
# Script to run all install scripts contained in install.d
|
# Script to run all install scripts contained in install.d
|
||||||
#
|
#
|
||||||
|
|
||||||
# Prevent running as root and check sudo access
|
# Prevent running as root
|
||||||
if [[ $EUID -eq 0 ]]; then
|
if [[ $EUID -eq 0 ]]; then
|
||||||
echo "Failed: Running as sudo. Please run as user"
|
echo "Failed: Running as sudo. Please run as user"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure sudo credentials are cached
|
||||||
sudo -v
|
sudo -v
|
||||||
|
|
||||||
|
# Set up directory variables
|
||||||
dir=$(dirname "$0")
|
dir=$(dirname "$0")
|
||||||
install_dir="$dir/install.d"
|
install_dir="$dir/install.d"
|
||||||
export DOTFILES=$(dirname "$dir")
|
export DOTFILES=$(dirname "$dir")
|
||||||
|
|
||||||
|
# Set up log destination
|
||||||
if [[ -z "$LOG_TARGET" ]]; then
|
if [[ -z "$LOG_TARGET" ]]; then
|
||||||
timestamp=$(date +%Y-%m-%dT%H:%M:%S)
|
timestamp=$(date +%Y-%m-%dT%H:%M:%S)
|
||||||
uuid=$(
|
uuid=$(
|
||||||
@@ -29,7 +33,14 @@ if [[ -z "$LOG_TARGET" ]]; then
|
|||||||
else
|
else
|
||||||
log_target="$LOG_TARGET"
|
log_target="$LOG_TARGET"
|
||||||
fi
|
fi
|
||||||
|
touch "$log_target"
|
||||||
|
if [[ ! -f "$log_target" ]]; then
|
||||||
|
echo "Failed: Unable to create log file \"$log_target\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log_abs_target=$(readlink -f "$log_target")
|
||||||
|
|
||||||
|
# Run install scripts
|
||||||
install() {
|
install() {
|
||||||
echo "Running \"$(basename "$0")\" at \"$(date)\""
|
echo "Running \"$(basename "$0")\" at \"$(date)\""
|
||||||
echo "Running as \"$(whoami)\" on \"$(hostname)\""
|
echo "Running as \"$(whoami)\" on \"$(hostname)\""
|
||||||
@@ -42,8 +53,9 @@ install() {
|
|||||||
unset script_name
|
unset script_name
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
echo "install: Logging to \"$log_abs_target\""
|
||||||
|
install 2>&1 | tee "$log_abs_target"
|
||||||
|
|
||||||
echo "install: Logging to \"$log_target\""
|
# Clean up
|
||||||
install 2>&1 | tee "$log_target"
|
unset uuid dir install_dir log_dir log_abs_target log_target
|
||||||
|
echo "Thank you!"
|
||||||
unset uuid dir install_dir log_dir log_target
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
build-essential
|
|
||||||
libssl-dev
|
|
||||||
libbz2-dev
|
|
||||||
libreadline-dev
|
|
||||||
libsqlite3-dev
|
|
||||||
libxml2-dev
|
|
||||||
libxmlsec1-dev
|
|
||||||
llvm
|
|
||||||
libncurses5-dev
|
|
||||||
libncursesw5-dev
|
|
||||||
xz-utils
|
|
||||||
tk-dev
|
|
||||||
libffi-dev
|
|
||||||
liblzma-dev
|
|
||||||
zlib1g-dev
|
|
||||||
@@ -5,18 +5,35 @@
|
|||||||
# Configure pyenv.
|
# Configure pyenv.
|
||||||
#
|
#
|
||||||
|
|
||||||
if ! bin_in_path "pyenv"; then
|
if ! command -v "pyenv" &> /dev/null; then
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
# see https://github.com/pyenv/pyenv/wiki/common-build-problems
|
# see https://github.com/pyenv/pyenv/wiki/common-build-problems
|
||||||
pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist"
|
ppyenv_packages=(
|
||||||
install_file "$pyenv_list_file"
|
build-essential
|
||||||
|
libssl-dev
|
||||||
|
libbz2-dev
|
||||||
|
libreadline-dev
|
||||||
|
libsqlite3-dev
|
||||||
|
libxml2-dev
|
||||||
|
libxmlsec1-dev
|
||||||
|
llvm
|
||||||
|
libncurses5-dev
|
||||||
|
libncursesw5-dev
|
||||||
|
xz-utils
|
||||||
|
tk-dev
|
||||||
|
libffi-dev
|
||||||
|
liblzma-dev
|
||||||
|
zlib1g-dev
|
||||||
|
)
|
||||||
|
pyenv_packages=($(comm -13 <(printf "%s\n" "${pyenv_packages[@]}" | sort) <(dpkg --get-selections | awk '{print $1}' | sort)))
|
||||||
|
if [ ${#pyenv_packages[@]} -gt 0 ]; then
|
||||||
|
sudo apt-get install -qq "${pyenv_packages[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
# see https://github.com/pyenv/pyenv-installer
|
# see https://github.com/pyenv/pyenv-installer
|
||||||
download_run \
|
bash -c "$(curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer)"
|
||||||
"https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \
|
|
||||||
bash
|
unset pyenv_packages
|
||||||
e
|
|
||||||
unset pyenv_list_file
|
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
brew install pyenv
|
brew install pyenv
|
||||||
brew install pyenv-virtualenv
|
brew install pyenv-virtualenv
|
||||||
@@ -30,10 +47,9 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|||||||
https://github.com/pyenv/pyenv-virtualenv.git \
|
https://github.com/pyenv/pyenv-virtualenv.git \
|
||||||
$virtualenv_path
|
$virtualenv_path
|
||||||
fi
|
fi
|
||||||
|
unset virtualenv_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval "$(pyenv init --path)"
|
eval "$(pyenv init --path)"
|
||||||
|
|
||||||
pyenv update
|
|
||||||
|
|
||||||
pyenv --version
|
pyenv --version
|
||||||
|
|||||||
@@ -7,16 +7,49 @@
|
|||||||
|
|
||||||
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
|
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
|
||||||
|
|
||||||
if ! bin_in_path "pip3"; then
|
if ! command -v "pip3" &>/dev/null; then
|
||||||
pyenv install 3.9.0
|
pyenv install 3.12.1
|
||||||
pyenv global 3.9.0
|
pyenv global 3.12.1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip
|
pip install --quiet --upgrade --user pip
|
||||||
pip3 install --upgrade pip
|
pip3 install --quiet --upgrade --user pip
|
||||||
python3 --version
|
python3 --version
|
||||||
pip3 --version
|
pip3 --version
|
||||||
|
|
||||||
for dep in $(jq -r ".pip_dependencies[]" $CONFIG); do
|
pip_dependencies=(
|
||||||
pip3 install --upgrade $dep
|
# docker-compose
|
||||||
done
|
# neovim
|
||||||
|
# "python-language-server[all]"
|
||||||
|
# pyvim
|
||||||
|
)
|
||||||
|
installed_packages=$(pip3 list --format=freeze | awk -F'==' '{print $1}')
|
||||||
|
pip_dependencies=($(comm -13 <(printf "%s\n" "${installed_packages[@]}" | sort) <(printf "%s\n" "${pip_dependencies[@]}" | sort)))
|
||||||
|
|
||||||
|
if [ ${#pip_dependencies[@]} -gt 0 ]; then
|
||||||
|
pip3 install --quiet --upgrade --user "${pip_dependencies[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset installed_packages pip_dependencies PYTHON_KEYRING_BACKEND
|
||||||
|
|
||||||
|
if ! command -v "pipx" &>/dev/null; then
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
|
sudo apt-get install -qq pipx
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
brew install pipx
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "pipx $(pipx --version)"
|
||||||
|
|
||||||
|
if ! command -v "poetry" &>/dev/null; then
|
||||||
|
pipx install poetry
|
||||||
|
fi
|
||||||
|
|
||||||
|
poetry --version
|
||||||
|
|
||||||
|
POETRY_PLUGIN="$ZSH/custom/plugins/poetry"
|
||||||
|
if [ ! -d "$POETRY_PLUGIN" ]; then
|
||||||
|
mkdir -p $POETRY_PLUGIN
|
||||||
|
poetry completions zsh > $POETRY_PLUGIN/_poetry
|
||||||
|
fi
|
||||||
|
|||||||
@@ -5,29 +5,35 @@
|
|||||||
# Configure Node.js.
|
# Configure Node.js.
|
||||||
#
|
#
|
||||||
|
|
||||||
nvm_version="0.39.7"
|
|
||||||
if ! bin_in_path "nvm"; then
|
|
||||||
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")"
|
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"
|
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
|
||||||
|
|
||||||
|
nvm_version="0.39.7"
|
||||||
|
if ! command -v "nvm" &>/dev/null; then
|
||||||
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh)"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
nvm --version
|
nvm --version
|
||||||
nvm alias default lts/iron
|
nvm alias default lts/iron
|
||||||
nvm install lts/iron
|
nvm install lts/iron
|
||||||
nvm use lts/iron
|
nvm use lts/iron
|
||||||
|
|
||||||
node --version
|
echo "Node.js $(node --version)"
|
||||||
|
|
||||||
yarn --version
|
echo "npm $(npm --version)"
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
npm_dependencies=(
|
||||||
for dep in $(jq -r ".node_dependencies[]" $CONFIG); do
|
"firebase-tools"
|
||||||
yarn global add $dep
|
"neovim"
|
||||||
yarn global upgrade $dep
|
"typescript-language-server"
|
||||||
done
|
"typescript"
|
||||||
|
)
|
||||||
|
|
||||||
|
npm_dependencies=($(comm -13 <(printf "%s\n" "${npm_dependencies[@]}" | sort) <(npm list -g --depth=0 --parseable | awk -F'/' '{print $NF}' | sort)))
|
||||||
|
|
||||||
|
if [ ${#npm_dependencies[@]} -gt 0 ]; then
|
||||||
|
npm install -g "${npm_dependencies[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset nvm_version
|
unset nvm_version npm_dependencies
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# /bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Description:
|
# Description:
|
||||||
|
|||||||
15
script/install.d/25-terraform.sh
Normal file
15
script/install.d/25-terraform.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Description:
|
||||||
|
# Install terraform.
|
||||||
|
#
|
||||||
|
|
||||||
|
if ! command -v "terraform" &>/dev/null; then
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
|
sudo apt-get install -qq terraform
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
brew tap hashicorp/tap
|
||||||
|
brew install hashicorp/tap/terraform
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
if ! command -v iterm2 &> /dev/null; then
|
if ! brew list --cask iterm2 &>/dev/null; then
|
||||||
brew install --cask iterm2
|
brew install --cask iterm2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
14
script/install.d/80-neofetch.sh
Normal file
14
script/install.d/80-neofetch.sh
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Description:
|
||||||
|
# Install neofetch.
|
||||||
|
#
|
||||||
|
|
||||||
|
if ! command -v "neofetch" &>/dev/null; then
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
|
sudo apt-get install -qq neofetch
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
brew install neofetch
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@@ -5,4 +5,4 @@
|
|||||||
# Print system information.
|
# Print system information.
|
||||||
#
|
#
|
||||||
|
|
||||||
screenfetch
|
neofetch
|
||||||
|
|||||||
@@ -69,19 +69,5 @@
|
|||||||
"tmux",
|
"tmux",
|
||||||
"unzip",
|
"unzip",
|
||||||
"yarn"
|
"yarn"
|
||||||
],
|
|
||||||
"node_dependencies": [
|
|
||||||
"firebase-tools",
|
|
||||||
"neovim",
|
|
||||||
"typescript-language-server",
|
|
||||||
"typescript"
|
|
||||||
],
|
|
||||||
"pip_dependencies": [
|
|
||||||
"awscli",
|
|
||||||
"docker-compose",
|
|
||||||
"neovim",
|
|
||||||
"poetry",
|
|
||||||
"python-language-server[all]",
|
|
||||||
"pyvim"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
3.9.0
|
3.12.1
|
||||||
|
|||||||
Reference in New Issue
Block a user