about summary refs log tree commit diff
path: root/scripts/install-nix-from-closure.sh
blob: 00f23e0f4c7f6280cf9a5e08f258862efa52c769 (plain) (blame)
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
#! /bin/sh -e

nix=@nix@
regInfo=@regInfo@

if ! $nix/bin/nix-store --load-db < $regInfo; then
    echo "$0: unable to register valid paths"
    exit 1
fi

. @nix@/etc/profile.d/nix.sh

if ! $nix/bin/nix-env -i @nix@; then
    echo "$0: unable to install Nix into your default profile"
    exit 1
fi

# Subscribe the user to the Nixpkgs channel and fetch it.
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
    $nix/bin/nix-channel --add http://nixos.org/channels/nixpkgs-unstable
fi
$nix/bin/nix-channel --update nixpkgs

# Add nix.sh to the shell's profile.d directory.
p=$NIX_LINK/etc/profile.d/nix.sh

if [ -w /etc/profile.d ]; then
    ln -s $p /etc/profile.d/
elif [ -w /usr/local/etc/profile.d ]; then
    ln -s $p /usr/local/etc/profile.d/
else
    cat <<EOF
Installation finished.  To ensure that the necessary environment
variables are set, please add the line

  source $p

to your shell profile (e.g. ~/.profile).
EOF
fi