2012-05-27 09:34:57 +00:00
|
|
|
export NIX_USER_PROFILE_DIR=@localstatedir@/nix/profiles/per-user/$USER
|
|
|
|
export NIX_PROFILES="@localstatedir@/nix/profiles/default $HOME/.nix-profile"
|
2003-04-09 12:26:48 +00:00
|
|
|
|
2012-05-27 09:34:57 +00:00
|
|
|
# Set up the per-user profile.
|
|
|
|
mkdir -m 0755 -p $NIX_USER_PROFILE_DIR
|
|
|
|
if test "$(stat --printf '%u' $NIX_USER_PROFILE_DIR)" != "$(id -u)"; then
|
|
|
|
echo "WARNING: bad ownership on $NIX_USER_PROFILE_DIR" >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! test -L $HOME/.nix-profile; then
|
|
|
|
echo "creating $HOME/.nix-profile" >&2
|
|
|
|
if test "$USER" != root; then
|
|
|
|
@coreutils@/ln -s $NIX_USER_PROFILE_DIR/profile $HOME/.nix-profile
|
|
|
|
else
|
|
|
|
# Root installs in the system-wide profile by default.
|
|
|
|
@coreutils@/ln -s /nix/var/nix/profiles/default $HOME/.nix-profile
|
2004-01-05 11:18:59 +00:00
|
|
|
fi
|
2012-05-27 09:34:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export PATH="$HOME/.nix-profile/bin:$PATH"
|
|
|
|
|
2012-07-25 20:56:56 +00:00
|
|
|
# Subscribe the root user to the Nixpkgs channel by default.
|
2012-05-27 09:34:57 +00:00
|
|
|
if [ "$USER" = root -a ! -e $HOME/.nix-channels ]; then
|
2012-07-25 20:56:56 +00:00
|
|
|
echo "http://nixos.org/releases/nixos/channels/nixpkgs-unstable nixpkgs" > $HOME/.nix-channels
|
2012-05-27 09:34:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the per-user garbage collector roots directory.
|
|
|
|
NIX_USER_GCROOTS_DIR=@localstatedir@/nix/gcroots/per-user/$USER
|
|
|
|
mkdir -m 0755 -p $NIX_USER_GCROOTS_DIR
|
|
|
|
if test "$(stat --printf '%u' $NIX_USER_GCROOTS_DIR)" != "$(id -u)"; then
|
|
|
|
echo "WARNING: bad ownership on $NIX_USER_GCROOTS_DIR" >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up a default Nix expression from which to install stuff.
|
|
|
|
if [ ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr ]; then
|
|
|
|
echo "creating $HOME/.nix-defexpr" >&2
|
|
|
|
rm -f $HOME/.nix-defexpr
|
|
|
|
mkdir $HOME/.nix-defexpr
|
|
|
|
if [ "$USER" != root ]; then
|
|
|
|
@coreutils@/ln -s @localstatedir@/nix/profiles/per-user/root/channels $HOME/.nix-defexpr/channels_root
|
|
|
|
fi
|
|
|
|
fi
|
2003-04-09 12:26:48 +00:00
|
|
|
|
2012-05-27 09:34:57 +00:00
|
|
|
# Set up secure multi-user builds: non-root users build through the
|
|
|
|
# Nix daemon.
|
|
|
|
if test "$USER" != root; then
|
|
|
|
export NIX_REMOTE=daemon
|
|
|
|
else
|
|
|
|
unset NIX_REMOTE
|
2008-11-20 17:22:42 +00:00
|
|
|
fi
|