-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·55 lines (43 loc) · 1.13 KB
/
install.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
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -euo pipefail
check_dependencies() {
local -r dependencies=(
"git"
"curl"
)
local not_met=false
for dep in "${dependencies[@]}"; do
if [[ -z $(command -v "$dep") ]]; then
echo "$dep is not installed"
not_met=true
fi
done
if [[ "$not_met" == true ]]; then
exit 1
fi
}
install_nix() {
if [[ -n $(command -v nix) ]]; then
return
fi
echo "[+] Installing Nix"
# see: https://github.com/DeterminateSystems/nix-installer
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix |
sh -s -- install
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
}
home_manager_switch() {
if [[ -n $(command -v home-manager) ]]; then
home-manager switch --flake .
else
nix-shell -p home-manager --run \
'home-manager --extra-experimental-features "nix-command flakes" switch --flake ".#${USER}@${HOSTNAME}"'
fi
}
main() {
check_dependencies
git submodule update --init --recursive
install_nix
home_manager_switch
}
main