-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnix-install
64 lines (49 loc) · 1.94 KB
/
nix-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
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
# customized version of https://nixos.org/nix/install
# tested on CentOS 6.5 and Ubuntu 14.04
{ # Prevent execution if this script was only partially downloaded
unpack=nix-binary-tarball-unpack
require_util() {
type "$1" > /dev/null 2>&1 || which "$1" > /dev/null 2>&1 ||
oops "you do not have \`$1' installed, which i need to $2"
}
oops() {
echo "$0: $@" >&2
#rm -rf "$unpack" # XXX: to speed up subsequent install attempts
echo leftovers: $unpack >&2
exit 1
}
case "$(uname -s).$(uname -m)" in
Linux.x86_64) system=x86_64-linux;;
Linux.i?86) system=i686-linux;;
Darwin.x86_64) system=x86_64-darwin;;
*) oops "sorry, there is no binary distribution of Nix for your platform";;
esac
url="https://nixos.org/releases/nix/nix-1.10/nix-1.10-$system.tar.bz2"
require_util curl "download the binary tarball"
require_util bzcat "decompress the binary tarball"
require_util tar "unpack the binary tarball"
echo "unpacking Nix binary tarball for $system from \`$url'..."
if [ ! -d $unpack ]; then
mkdir "$unpack" || oops "failed to create \`$unpack' directory"
curl -O -L "$url" || oops "could not download \`$url'"
tar xjf $(basename "$url") -C "$unpack" || oops "failed to unpack \`$url'"
fi
[ -e "$unpack"/*/install ] ||
oops "installation script is missing from the binary tarball!"
sudo install -d /etc/nix
cat > /etc/nix/nix.conf << EOF
build-users-group =
EOF
sudo install -m 755 -o $USER -d /nix
"$unpack"/*/install
if [ $? -eq 0 ]; then
rm -rf "$unpack"
echo patching your default environment...
echo 'export PATH=/nix/var/nix/profiles/default/bin:$PATH' | sudo tee /etc/profile.d/nix-adhoc.sh
# ubuntu needs /etc/environment (see sshd pam policies):
echo PATH="/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | sudo tee /etc/environment
sudo chmod +x /etc/profile.d/nix-adhoc.sh
fi
} # End of wrapping
# vim: ts=4 sts=4 sw=4 et