forked from ryanb/dotfiles
/
install
executable file
·53 lines (40 loc) · 1.1 KB
/
install
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
#!/usr/bin/env bash
set -eo pipefail
get_filesystem_type () {
if [ -x "$(command -v diskutil)" ]; then
printf "%s" "$(diskutil info / | grep 'Type (Bundle)' | awk -F':' '{ print $2 }' | tr -d '[:space:]')"
else
printf "other"
fi
}
install_nix () {
local filesystem_type
filesystem_type="$(get_filesystem_type)"
local args=()
if ! [ "$SINGLE_USER" = "true" ]; then
args+=(--daemon)
fi
if [ "$filesystem_type" = "apfs" ]; then
args+=(--darwin-use-unencrypted-nix-store-volume)
fi
sh <(curl -L https://nixos.org/nix/install) "${args[@]}"
. /nix/var/nix/profiles/default/etc/profile.d/nix.sh
}
change_shell () {
sudo bash -c "echo $(which bash) >> /etc/shells"
sudo chsh -s "$(which bash)" "$(whoami)"
}
if ! [ -x "$(command -v nix)" ]; then
echo "Installing Nix"
install_nix
else
echo "Nix already installed, skipping"
fi
echo "Applying Home Manager Configuration"
nix-shell --run "home-manager switch -b bak"
if ! [ "$SHELL" == "$(which bash)" ]; then
echo "Changing shell to $(which bash)"
change_shell
else
echo "Shell already set to $(which bash), skipping"
fi