nixos/install.sh

83 lines
2.1 KiB
Bash
Executable file

#! /usr/bin/env sh
# Install various dotfiles into their proper places
create_symlink () {
FILENAME="$(basename $2)"
if [ ! -e "$1/$FILENAME" ]
then
ln -s $(readlink -f "$2") "$1/$FILENAME"
echo "$(readlink -f $2) -> $1/$FILENAME"
else
echo "$1/$FILENAME already exists"
fi
}
git_clone_if_missing () {
if [ ! -d "$2" ]
then
git clone --depth 1 "$1" "$2"
else
echo "$1 already checked out: $2"
fi
}
# .config files
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
mkdir -p "$CONFIG_DIR"
for FILE in config/*
do
create_symlink "$CONFIG_DIR" "$FILE"
done
mkdir -p "$CONFIG_DIR/systemd/user"
for FILE in systemd/*
do
create_symlink "$CONFIG_DIR/systemd/user" "$FILE"
done
# SSH sockets
mkdir -p "$HOME/.ssh/sockets"
[ ! -e "$HOME/.ssh/config" ] && cp templates/ssh-config "$HOME/.ssh/config"
# nvim setup - install Packer
PACKER_REPO="https://github.com/wbthomason/packer.nvim"
PACKER_DIR="$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim"
git_clone_if_missing "$PACKER_REPO" "$PACKER_DIR"
# Set up git editor if missing
grep "editor" "$HOME/.gitconfig" > /dev/null || git config --global core.editor "nvim"
# Add NerdFont symbols
mkdir -p "$HOME/.local/share/fonts"
for FILE in nerdfont_symbols/*
do
create_symlink "$HOME/.local/share/fonts" "$FILE"
done
# Ensure nvim plugins
mkdir -p "$HOME/.local/bin"
for FILE in bin/*
do
which -a "$(basename $FILE)" > /dev/null || create_symlink "$HOME/.local/bin" "$FILE"
done
# oh-my-zsh
if [ ! -d "$ZSH" ]
then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
echo "oh-my-zsh already installed: $ZSH"
fi
OHMYZSH_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
if [ -d "$OHMYZSH_DIR" ]
then
# Powerlevel10k theme
POWERLEVEL_REPO="https://github.com/romkatv/powerlevel10k.git"
POWERLEVEL_DIR="$OHMYZSH_DIR/themes/powerlevel10k"
git_clone_if_missing "$POWERLEVEL_REPO" "$POWERLEVEL_DIR"
# aliases
create_symlink "$OHMYZSH_DIR" "./aliases.zsh"
create_symlink "$OHMYZSH_DIR" "./completions.zsh"
fi