-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
43 lines (31 loc) · 1.21 KB
/
bootstrap.sh
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
#!/usr/bin/env bash
# Install nix
if ! command -v nix &> /dev/null; then
echo "Nix not found, installing..."
sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
fi
nix --version
mkdir -p ~/.config/nix
cat << EOF > ~/.config/nix/nix.conf
experimental-features = nix-command flakes
EOF
# Install nix
if ! command -v home-manager &> /dev/null; then
echo "Nix Home Manager (HM) not found, Setting up..."
echo "Adding 22.05 HM channel..."
nix-channel --add https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz home-manager
nix-channel --update
echo "Installing Home Manager..."
export NIX_PATH=$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels${NIX_PATH:+:$NIX_PATH}
nix-shell '<home-manager>' -A install
fi
echo "Home Manager: $(home-manager --version)"
echo "Loading session vars..."
# shellcheck disable=SC1091
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
read -rp "Which home configuration would you like to activate? " flake
home-manager switch --flake .#"${flake}"
if [ "$1" -eq "1" ]; then
echo "Something went wrong, trying with backup mode..."
home-manager switch -b backup --flake .#"${flake}"
fi