-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
70 lines (59 loc) · 1.76 KB
/
init.sh
File metadata and controls
70 lines (59 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -e
git config user.name "$(git log --reverse --format=%an | head -n 1)"
git config user.email "$(git log --reverse --format=%ae | head -n 1)"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOTFILES_DIR="$HOME/.dotfiles"
if [ -L $DOTFILES_DIR ] || [ ! -d $DOTFILES_DIR ]; then
rm $DOTFILES_DIR &>/dev/null
ln -s $SCRIPT_DIR $DOTFILES_DIR
fi
if ! command -v nix >/dev/null; then
curl -fsSL https://install.determinate.systems/nix | sh -s -- install --prefer-upstream-nix
# The determinate systems nix installer finishes with the line below:
# To get started using Nix, open a new shell or run `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh`
echo "Please open a new shell, it works better..."
echo "Then, to continue initializing dotfiles, run \`cd ~/.dotfiles/ && bash init.sh\`"
echo ""
kill $(jobs -p) &>/dev/null
exit 0
fi
pushd $DOTFILES_DIR &>/dev/null
if command -v nixos-rebuild >/dev/null; then
OS="NixOS"
else
OS="$(uname)"
fi
case $OS in
"NixOS")
sudo nixos-rebuild switch --flake ./nix
;;
"Darwin")
if ! command -v darwin-rebuild >/dev/null; then
sudo nix run nix-darwin -- switch --flake ./nix
else
sudo darwin-rebuild switch --flake ./nix
fi
;;
*)
if ! command -v home-manager >/dev/null; then
nix run home-manager/master -- switch --flake ./nix
else
home-manager switch --flake ./nix
fi
;;
esac
for dir in ./*/; do
init_file="init.sh"
if [ -f "$dir/$init_file" ]; then
pushd "$dir" &>/dev/null
bash "$init_file"
popd &>/dev/null
fi
done
if ! command -v kanata >/dev/null && [ "$OS" != "NixOS" ] && [ "$OS" != "Darwin" ]; then
pushd ./kanata &>/dev/null
bash ./kanata_install.sh
popd &>/dev/null
fi
popd &>/dev/null