···28 echo "WARNING: bad ownership on $NIX_USER_PROFILE_DIR" >&2
29 fi
3031- if ! test -L $HOME/.nix-profile; then
32- if test "$USER" != root; then
33- ln -s $NIX_USER_PROFILE_DIR/profile $HOME/.nix-profile
34- else
35- # Root installs in the system-wide profile by default.
36- ln -s /nix/var/nix/profiles/default $HOME/.nix-profile
37- fi
38- fi
03940- # Subscribe the root user to the NixOS channel by default.
41- if [ "$USER" = root -a ! -e $HOME/.nix-channels ]; then
42- echo "${config.system.defaultChannel} nixos" > $HOME/.nix-channels
43- fi
4445- # Create the per-user garbage collector roots directory.
46- NIX_USER_GCROOTS_DIR=/nix/var/nix/gcroots/per-user/$USER
47- mkdir -m 0755 -p $NIX_USER_GCROOTS_DIR
48- if test "$(stat --printf '%u' $NIX_USER_GCROOTS_DIR)" != "$(id -u)"; then
49- echo "WARNING: bad ownership on $NIX_USER_GCROOTS_DIR" >&2
50- fi
5152- # Set up a default Nix expression from which to install stuff.
53- if [ ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr ]; then
54- rm -f $HOME/.nix-defexpr
55- mkdir $HOME/.nix-defexpr
56- if [ "$USER" != root ]; then
57- ln -s /nix/var/nix/profiles/per-user/root/channels $HOME/.nix-defexpr/channels_root
58- fi
059 fi
60 '';
61
···28 echo "WARNING: bad ownership on $NIX_USER_PROFILE_DIR" >&2
29 fi
3031+ if test -w $HOME; then
32+ if ! test -L $HOME/.nix-profile; then
33+ if test "$USER" != root; then
34+ ln -s $NIX_USER_PROFILE_DIR/profile $HOME/.nix-profile
35+ else
36+ # Root installs in the system-wide profile by default.
37+ ln -s /nix/var/nix/profiles/default $HOME/.nix-profile
38+ fi
39+ fi
4041+ # Subscribe the root user to the NixOS channel by default.
42+ if [ "$USER" = root -a ! -e $HOME/.nix-channels ]; then
43+ echo "${config.system.defaultChannel} nixos" > $HOME/.nix-channels
44+ fi
4546+ # Create the per-user garbage collector roots directory.
47+ NIX_USER_GCROOTS_DIR=/nix/var/nix/gcroots/per-user/$USER
48+ mkdir -m 0755 -p $NIX_USER_GCROOTS_DIR
49+ if test "$(stat --printf '%u' $NIX_USER_GCROOTS_DIR)" != "$(id -u)"; then
50+ echo "WARNING: bad ownership on $NIX_USER_GCROOTS_DIR" >&2
51+ fi
5253+ # Set up a default Nix expression from which to install stuff.
54+ if [ ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr ]; then
55+ rm -f $HOME/.nix-defexpr
56+ mkdir $HOME/.nix-defexpr
57+ if [ "$USER" != root ]; then
58+ ln -s /nix/var/nix/profiles/per-user/root/channels $HOME/.nix-defexpr/channels_root
59+ fi
60+ fi
61 fi
62 '';
63