10if ! [ -e $self/.reginfo ]; then
11 echo "$0: incomplete installer (.reginfo is missing)" >&2
15if [ -z "$USER" ]; then
16 echo "$0: \$USER is not set" >&2
20if [ "$(id -u)" -eq 0 ]; then
21 printf '\e[1;31mwarning: installing Nix as root is not supported by this script!\e[0m\n'
24echo "performing a single-user installation of Nix..." >&2
26if ! [ -e $dest ]; then
27 cmd="mkdir -m 0755 $dest && chown $USER $dest"
28 echo "directory $dest does not exist; creating it by running '$cmd' using sudo" >&2
29 if ! sudo sh -c "$cmd"; then
30 echo "$0: please manually run ‘$cmd’ as root to create $dest" >&2
35if ! [ -w $dest ]; then
36 echo "$0: directory $dest exists, but is not writable by you. This could indicate that another user has already performed a single-user installation of Nix on this system. If you wish to enable multi-user support see http://nixos.org/nix/manual/#ssec-multi-user. If you wish to continue with a single-user install for $USER please run ‘chown -R $USER $dest’ as root." >&2
42echo -n "copying Nix to $dest/store..." >&2
44for i in $(cd $self/store >/dev/null && echo *); do
46 i_tmp="$dest/store/$i.$$"
47 if [ -e "$i_tmp" ]; then
50 if ! [ -e "$dest/store/$i" ]; then
51 cp -Rp "$self/store/$i" "$i_tmp"
54 mv "$i_tmp" "$dest/store/$i"
55 chmod -w "$dest/store/$i"
60echo "initialising Nix database..." >&2
61if ! $nix/bin/nix-store --init; then
62 echo "$0: failed to initialize the Nix database" >&2
66if ! $nix/bin/nix-store --load-db < $self/.reginfo; then
67 echo "$0: unable to register valid paths" >&2
71. $nix/etc/profile.d/nix.sh
73if ! $nix/bin/nix-env -i "$nix"; then
74 echo "$0: unable to install Nix into your default profile" >&2
78# Install an SSL certificate bundle.
79if [ -z "$SSL_CERT_FILE" -o ! -f "$SSL_CERT_FILE" ]; then
80 $nix/bin/nix-env -i "$cacert"
81 export SSL_CERT_FILE="$HOME/.nix-profile/etc/ssl/certs/ca-bundle.crt"
84# Subscribe the user to the Nixpkgs channel and fetch it.
85if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
86 $nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
88if [ -z "$_NIX_INSTALLER_TEST" ]; then
89 $nix/bin/nix-channel --update nixpkgs
92# Make the shell source nix.sh during login.
93p=$HOME/.nix-profile/etc/profile.d/nix.sh
96for i in .bash_profile .bash_login .profile; do
99 if ! grep -q "$p" "$fn"; then
100 echo "modifying $fn..." >&2
101 echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> $fn
108if [ -z "$added" ]; then
111Installation finished! To ensure that the necessary environment
112variables are set, please add the line
116to your shell profile (e.g. ~/.profile).
121Installation finished! To ensure that the necessary environment
122variables are set, either log in again, or type
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list