aboutsummaryrefslogtreecommitdiffhomepage
path: root/bootstrap
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-09-05 23:23:27 +0900
committernsfisis <nsfisis@gmail.com>2023-09-05 23:23:27 +0900
commit73a4a7594127c062856f98720661e99f2a10566f (patch)
tree4e62d6aaf85cf860b7c7b77b7a6bc8d7238fb4f7 /bootstrap
parente2dc92f5bb2ef48e042f7a0c88ae4f9fcaac1ff1 (diff)
downloaddotfiles-73a4a7594127c062856f98720661e99f2a10566f.tar.gz
dotfiles-73a4a7594127c062856f98720661e99f2a10566f.tar.zst
dotfiles-73a4a7594127c062856f98720661e99f2a10566f.zip
bootstrap: rename bootstrap.sh to bootstrap
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap113
1 files changed, 113 insertions, 0 deletions
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..ab78d8c
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+if [ $# != 1 ]; then
+ echo "Usage: $0 <host>" >&2
+ echo "Availabel hosts:" >&2
+ grep '= mkHomeConfiguration' flake.nix | cut -d '=' -f 1 | sed -e 's/^ */ * /' >&2
+ exit 1
+fi
+
+export XDG_CONFIG_HOME="$HOME/.config"
+export XDG_CACHE_HOME="$HOME/.cache"
+export XDG_DATA_HOME="$HOME/.local/share"
+export XDG_STATE_HOME="$HOME/.local/state"
+
+for dir in \
+ "$XDG_CONFIG_HOME" \
+ "$XDG_CACHE_HOME" \
+ "$XDG_DATA_HOME" \
+ "$XDG_STATE_HOME" \
+ ; \
+do
+ if [ ! -d "$dir" ]; then
+ mkdir -p "$dir"
+ fi
+done
+if [ ! -d .bootstrap ]; then
+ mkdir .bootstrap
+fi
+if [ ! -f .bootstrap/nix-install ]; then
+ curl -o .bootstrap/nix-install -L https://nixos.org/nix/install
+fi
+if [ ! -d /nix ]; then
+ sh .bootstrap/nix-install --daemon
+ hash -r
+fi
+if ! grep -q "nix-command flakes" /etc/nix/nix.conf; then
+ echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf > /dev/null
+fi
+if [ ! -d "$HOME/.local/state/nix/profiles" ]; then
+ mkdir -p "$HOME/.local/state/nix/profiles"
+fi
+if ! type home-manager > /dev/null 2>&1; then
+ nix run "nixpkgs#home-manager" -- switch --flake ".#$1"
+fi
+
+# These dotfiles are not managed by home-manager.
+for name in \
+ .vimrc \
+ .zshenv \
+ .zshrc \
+ ; \
+do
+ if [ ! -L ~/"$name" ]; then
+ ln -s -f ~/dotfiles/"$name" ~/"$name"
+ fi
+done
+for name in \
+ alacritty \
+ git \
+ nvim \
+ ; \
+do
+ if [ ! -L ~/.config/"$name" ]; then
+ ln -s -f ~/dotfiles/.config/"$name" ~/.config/"$name"
+ fi
+done
+
+# Go
+for name in \
+ gitalias/git-extract-issue \
+ gitalias/git-sw \
+ ; \
+do
+ src_file="src/$name.go"
+ bin_file="bin/$name"
+ if [ "$bin_file" -ot "$src_file" ]; then
+ go build -o "$bin_file" "$src_file"
+ fi
+done
+if [ ! -d ~/bin ]; then
+ mkdir ~/bin
+fi
+if [ ! -d ~/bin/gitalias ]; then
+ mkdir ~/bin/gitalias
+fi
+for name in \
+ tmux-pane-idx \
+ gitalias/git-extract-issue \
+ gitalias/git-sw \
+ ; \
+do
+ if [ ! -L ~/bin/"$name" ]; then
+ ln -s -f ~/dotfiles/bin/"$name" ~/bin/"$name"
+ fi
+done
+if [ ! -f ~/.config/alacritty/alacritty.local.yml ]; then
+ if [ "$(uname)" = "Darwin" ]; then
+ ln -s -f ~/.config/alacritty/alacritty.macos.yml ~/.config/alacritty/alacritty.local.yml
+ else
+ ln -s -f ~/.config/alacritty/alacritty.linux.yml ~/.config/alacritty/alacritty.local.yml
+ fi
+fi
+if [ ! -d ~/.config/skk ]; then
+ mkdir ~/.config/skk
+fi
+if [ ! -f ~/.config/skk/jisyo.L ]; then
+ _compressed_jisyo="$(mktemp)"
+ curl -fL -o "$_compressed_jisyo" https://skk-dev.github.io/dict/SKK-JISYO.L.unannotated.gz
+ gunzip -cd "$_compressed_jisyo" > ~/.config/skk/jisyo.L
+fi
+if [ ! -d "$XDG_STATE_HOME/zsh" ]; then
+ mkdir -p "$XDG_STATE_HOME/zsh"
+fi