-
Notifications
You must be signed in to change notification settings - Fork 50
/
setup-doughnut-dev.sh
executable file
·68 lines (56 loc) · 1.82 KB
/
setup-doughnut-dev.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
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -eo pipefail
export NIXPKGS_ALLOW_UNFREE=1
export unameOut="$(uname -s)"
export os_type=Unsupported
get_os_type() {
case "${unameOut}" in
Linux*) os_type=Linux ;;
Darwin*) os_type=Mac ;;
*) os_type="UNKNOWN:${unameOut}" ;;
esac
}
download_nixpkg_manager_install_script() {
rm -f ./install-nix
curl -sSf -L -o install-nix https://install.lix.systems/lix
chmod +x ./install-nix
}
configure_nix_flakes() {
if [ ! -f "${HOME}/.config/nix/nix.conf" ]; then
mkdir -p "${HOME}/.config/nix"
touch "${HOME}/.config/nix/nix.conf"
fi
if ! grep -Fxq "experimental-features = nix-command flakes" "${HOME}/.config/nix/nix.conf"; then
cat <<-EOF > "${HOME}/.config/nix/nix.conf"
experimental-features = nix-command flakes
EOF
fi
}
allow_nix_unfree() {
mkdir -p "${HOME}/.config/nixpkgs"
touch "${HOME}/.config/nixpkgs/config.nix"
cat <<-EOF > "${HOME}/.config/nixpkgs/config.nix"
{ allowUnfree = true; }
EOF
}
install_nixpkg_manager() {
get_os_type
if ! command -v nix >/dev/null 2>&1; then
download_nixpkg_manager_install_script
touch .bash_profile
if [ "${os_type}" == "Mac" || "${os_type}" == "Linux" ]; then
./install-nix -s -- install
else
echo "Unsupported OS Platform for Nix development enviroment. Exiting!!!"
exit 1
fi
fi
allow_nix_unfree
configure_nix_flakes
}
install_nixpkg_manager
echo "------------------------------------------ CONGRATS !!! ----------------------------------------------------"
echo " doughnut basic nix development environment tooling setup complete."
echo " Please exit this shell terminal and start a new one in doughnut root directory then execute 'nix develop'."
echo "------------------------------------------ END ----------------------------------------------------"
rm -f ./install-nix