forked from Nix-QChem/NixOS-QChem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·119 lines (86 loc) · 2.4 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#/usr/bin/env bash
set -e
error() {
printf "$0: $@\n" >&2
exit 1
}
yesno() {
printf "$1 [y/n] "
read -r reply
if [ "$reply" == "y" ]; then
ret=1
else
ret=0
fi
}
if [ "$1" == "--help" ]; then
cat <<EOF
Installs the Nix package manager and the NixOS-QChem overlay.
EOF
exit 0
fi
# Check if git is available
command -v git --version > /dev/null || error "Git is not installed. We need git to check out the overlay."
# Needed by the nix installer
command -v curl --version > /dev/null || error "Curl is not installed."
command -v xz --version > /dev/null || error "Xz is not installed."
command -v rsync --version > /dev/null || error "rsync is not installed."
#
# Nix installation
#
has_nix=0
command -v nix --version > /dev/null && has_nix=1
if [ $has_nix == 0 ]; then
yesno "\nDo you want to install the Nix package manager?"
if [ $ret == 0 ]; then
error "Exiting...\n"
fi
printf "Download and run Nix installer...\n"
curl -L https://nixos.org/nix/install | sh -s -- --daemon
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
fi
#
# Install the overlay
#
overlay_path=~/.config/nixpkgs/overlays/qchem
# make sure the path is clear
if [ -d $overlay_path ]; then
yesno "\nThere seems to be already an overlay isntalled at $overlay_path.\nDo you want to delete it and reinstall it?"
if [ $ret == 0 ]; then
error "Aborting. Please clear $overlay_path and try again."
fi
rm -fr $overlay_path
fi
mkdir -p ~/.config/nixpkgs/overlays
git clone https://github.com/markuskowa/NixOS-QChem.git $overlay_path
config_file=~/.config/nixpkgs/config.nix
if [ ! -e $config_file ]; then
allowUnfree=false
yesno "\nDo you want to allow the installation of packages with unfree licenses?"
if [ $ret == 1 ]; then
allowUnfree=true
fi
optAVX=false
yesno "\nDo you want to build the overlay packages with AVX2 optimizations?"
if [ $ret == 1 ]; then
optAVX=true
fi
cat > $config_file << EOF
{
allowUnfree = $allowUnfree;
qchem-config = {
# CPU architecture specific tunings, e.g. AVX2
optAVX = $optAVX;
};
}
EOF
else
printf "Config file $config_file exists. Skipping config creation."
fi
cat <<EOF
The Nix and the NixOS-QChem overlay are now installed in you system.
Before you can use it you need refresh your environment by doing a re-login.
For future upgrades please run:
nix-channel --update
and 'git pull' in $overlay_path
EOF