install: break up files, add nix
This commit is contained in:
parent
c381dc1228
commit
4a00ab548c
37
README.md
37
README.md
@ -1,11 +1,32 @@
|
||||
### Dotfiles
|
||||
## Dotfiles
|
||||
|
||||
My personal configuration files.
|
||||
Developer config files.
|
||||
|
||||
##### Usage
|
||||
| Tool | Description |
|
||||
| -------- | ----------- |
|
||||
| Homebrew | Package management |
|
||||
| Nix | Package management (experimental) |
|
||||
| Fish | Shell |
|
||||
| Git | Version control |
|
||||
| Neovim | Editor |
|
||||
|
||||
1. Clone this repository into `~/dotfiles`
|
||||
2. Install [Homebrew](https://brew.sh/): `./install-brew.sh`
|
||||
3. Install tools: `brew bundle install --file=brew/Brewfile`
|
||||
4. Install optional tools: `brew/install-extra.sh [--casks]`
|
||||
5. Install everything else, including symlinks: `./install.sh`
|
||||
MacOS is my primary work environment, hence Homebrew. This setup can be deployed on Linux too. I am aware of criticisms with Homebrew on Linux, but it fits my needs. Nix is being considered as an alternative.
|
||||
|
||||
### Usage
|
||||
|
||||
Run the interactive installer for Mac/Linux: `./install.sh`
|
||||
|
||||
If you decline every prompt, it looks like this:
|
||||
|
||||
```
|
||||
> ./install.sh
|
||||
Install Homebrew? [Y/n] n
|
||||
Install Homebrew packages? [Y/n] n
|
||||
Install Nix? [Y/n] n
|
||||
Install Nix packages? [Y/n] n
|
||||
Set login shell? [Y/n] n
|
||||
Create symlinks? [Y/n] n
|
||||
Install vim plugins? [Y/n] n
|
||||
```
|
||||
|
||||
These steps _should_ be executed in order. You can safely rerun a step if needed; it tries to be idempotent. Backups are created if you have existing configs that would be overwritten. Definitely do not create symlinks until you have installed the [required](brew/Brewfile) packages (the config files depend on them).
|
||||
|
@ -6,10 +6,6 @@ brew "diff-so-fancy"
|
||||
brew "fd"
|
||||
brew "fish"
|
||||
brew "fzf"
|
||||
brew "gawk"
|
||||
brew "git"
|
||||
brew "neovim"
|
||||
brew "ripgrep"
|
||||
brew "tldr"
|
||||
brew "tree"
|
||||
brew "wget"
|
||||
|
@ -12,7 +12,9 @@ dungeon
|
||||
elvish
|
||||
fortune
|
||||
fzy
|
||||
gawk
|
||||
gcc
|
||||
git
|
||||
gitup
|
||||
go
|
||||
gradle
|
||||
@ -55,6 +57,7 @@ syncthing
|
||||
telnet
|
||||
termtosvg
|
||||
tig
|
||||
tldr
|
||||
triangle
|
||||
tmux
|
||||
ttyd
|
||||
@ -63,6 +66,7 @@ unrtf
|
||||
up
|
||||
vitetris
|
||||
watch
|
||||
wget
|
||||
yq
|
||||
zeek
|
||||
zsxd
|
||||
|
@ -72,6 +72,11 @@ if test -x /home/linuxbrew/.linuxbrew/bin/brew
|
||||
eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv)
|
||||
end
|
||||
|
||||
# Nix package manager
|
||||
if test -f ~/.nix-profile/etc/profile.d/nix.sh
|
||||
functions -q fenv && fenv source ~/.nix-profile/etc/profile.d/nix.sh
|
||||
end
|
||||
|
||||
# Cheatsheet widget (Ctrl+G)
|
||||
if command -q navi
|
||||
navi widget fish | source
|
||||
|
@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if Homebrew is already installed
|
||||
if [ -x "$(command -v brew)" ]; then
|
||||
echo "Homebrew is already installed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Install Homebrew
|
||||
case "$(uname -s)" in
|
||||
Darwin|Linux)
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported kernel: $(uname -s)"
|
||||
;;
|
||||
esac
|
38
install.sh
38
install.sh
@ -1,22 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOTFILES="$HOME/dotfiles"
|
||||
DOTFILES=$(cd "$(dirname "$0")" && pwd)
|
||||
|
||||
# Install symlinks
|
||||
"$DOTFILES/install-symlinks.sh"
|
||||
confirm() {
|
||||
local prompt="$1 [Y/n] "
|
||||
|
||||
# Install plugin manager for Neovim, if it doesn't exist
|
||||
VIM_PLUG_SRC="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
||||
VIM_PLUG_DST="$HOME/.local/share/nvim/site/autoload/plug.vim"
|
||||
if [ ! -f "$VIM_PLUG_DST" ]; then
|
||||
echo "Downloading plug.vim ..."
|
||||
curl -fsSL -o "$VIM_PLUG_DST" --create-dirs "$VIM_PLUG_SRC"
|
||||
fi
|
||||
while true; do
|
||||
read -e -p "$prompt" yn
|
||||
case "$yn" in
|
||||
"" ) return 0;; # default is yes
|
||||
[Yy]* ) return 0;;
|
||||
[Nn]* ) return 1;;
|
||||
* ) ;; # wait for yes or no
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Install plugins for Neovim
|
||||
nvim +PlugInstall +qall
|
||||
# Install tools
|
||||
confirm "Install Homebrew?" && "$DOTFILES/install/install-brew.sh"
|
||||
confirm "Install Homebrew packages?" && "$DOTFILES/install/install-brew-packages.sh"
|
||||
confirm "Install Nix?" && "$DOTFILES/install/install-nix.sh"
|
||||
confirm "Install Nix packages?" && "$DOTFILES/install/install-nix-packages.sh"
|
||||
|
||||
# Make fish the default shell
|
||||
BREW_PREFIX=$(brew --prefix)
|
||||
grep -q "$BREW_PREFIX/bin/fish" /etc/shells || echo "$BREW_PREFIX/bin/fish" | sudo tee -a /etc/shells
|
||||
sudo chsh -s "$BREW_PREFIX/bin/fish" $(whoami)
|
||||
# Extra steps
|
||||
confirm "Set login shell?" && "$DOTFILES/install/install-shell.sh"
|
||||
confirm "Create symlinks?" && "$DOTFILES/install/install-symlinks.sh"
|
||||
confirm "Install vim plugins?" && "$DOTFILES/install/install-vim-plugins.sh"
|
||||
|
13
install/install-brew-packages.sh
Executable file
13
install/install-brew-packages.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "***** INSTALL HOMEBREW PACKAGES *****"
|
||||
|
||||
DOTFILES=$(cd "$(dirname "$0")/.." && pwd)
|
||||
|
||||
# Install required tools
|
||||
brew bundle install --file="$DOTFILES/brew/Brewfile"
|
||||
|
||||
# Install optional tools (prompted by fzf)
|
||||
"$DOTFILES/brew/install-extra.fish"
|
||||
|
||||
echo
|
11
install/install-brew.sh
Executable file
11
install/install-brew.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "***** INSTALL HOMEBREW *****"
|
||||
|
||||
if [ -x "$(command -v brew)" ]; then
|
||||
echo "Homebrew is already installed."
|
||||
else
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||
fi
|
||||
|
||||
echo
|
19
install/install-nix-packages.sh
Executable file
19
install/install-nix-packages.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "***** INSTALL NIX PACKAGES *****"
|
||||
|
||||
NIX_ENV="$HOME/.nix-profile/bin/nix-env"
|
||||
|
||||
if [ -x "$NIX_ENV" ]; then
|
||||
"$NIX_ENV" -iA nixpkgs.bat
|
||||
"$NIX_ENV" -iA nixpkgs.fd
|
||||
"$NIX_ENV" -iA nixpkgs.fish
|
||||
"$NIX_ENV" -iA nixpkgs.neovim
|
||||
"$NIX_ENV" -iA nixpkgs.ripgrep
|
||||
"$NIX_ENV" -iA nixpkgs.tree
|
||||
"$NIX_ENV" -iA nixpkgs.gitAndTools.diff-so-fancy
|
||||
else
|
||||
echo "Cannot install Nix packages! $NIX_ENV is not executable."
|
||||
fi
|
||||
|
||||
echo
|
11
install/install-nix.sh
Executable file
11
install/install-nix.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "***** INSTALL NIX *****"
|
||||
|
||||
if [ -d /nix ]; then
|
||||
echo "Nix is already installed."
|
||||
else
|
||||
/bin/bash -c "$(curl -fsSL https://nixos.org/nix/install) --no-daemon"
|
||||
fi
|
||||
|
||||
echo
|
20
install/install-shell.sh
Executable file
20
install/install-shell.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "***** INSTALL SHELL *****"
|
||||
|
||||
SHELL_PATH='/usr/local/bin/fish'
|
||||
|
||||
if [ ! -x "$SHELL_PATH" ]; then
|
||||
echo "Cannot set login shell! $SHELL_PATH is not executable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$SHELL" = "$SHELL_PATH" ]; then
|
||||
echo "$SHELL_PATH is already the login shell."
|
||||
else
|
||||
echo "Setting the login shell to $SHELL_PATH ..."
|
||||
grep -q "$SHELL_PATH" /etc/shells || echo "$SHELL_PATH" | sudo tee -a /etc/shells
|
||||
sudo chsh -s "$SHELL_PATH" $(whoami)
|
||||
fi
|
||||
|
||||
echo
|
@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOTFILES="$HOME/dotfiles"
|
||||
echo "***** INSTALL SYMLINKS *****"
|
||||
|
||||
DOTFILES=$(cd "$(dirname "$0")/.." && pwd)
|
||||
|
||||
backup_existing() {
|
||||
if [ -e "$1" ]; then
|
||||
@ -24,3 +26,5 @@ ln -fsv "$DOTFILES/bash/.bashrc" "$HOME/.bashrc" # Bash does not support XDG con
|
||||
ln -fsv "$DOTFILES/fish" "$HOME/.config"
|
||||
ln -fsv "$DOTFILES/nvim" "$HOME/.config"
|
||||
ln -fsv "$DOTFILES/git" "$HOME/.config"
|
||||
|
||||
echo
|
18
install/install-vim-plugins.sh
Executable file
18
install/install-vim-plugins.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "***** INSTALL VIM PLUGINS *****"
|
||||
|
||||
VIM_PLUG="$HOME/.local/share/nvim/site/autoload/plug.vim"
|
||||
|
||||
if [ -f "$VIM_PLUG" ]; then
|
||||
echo "Updating vim plugin manager..."
|
||||
echo "Updating vim plugins..."
|
||||
nvim +PlugUpgrade +PlugUpdate +qall
|
||||
else
|
||||
echo "Installing vim plugin manager..."
|
||||
curl -fsSL -o "$VIM_PLUG" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
echo "Installing vim plugins..."
|
||||
nvim +PlugInstall +qall
|
||||
fi
|
||||
|
||||
echo
|
Loading…
x
Reference in New Issue
Block a user