diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-09-13T21·48-0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-09-13T21·48-0400 |
commit | aac14222f52b15c9f4eea90359e9df09fb301739 (patch) | |
tree | d535d42ac0edb55e53b9d5423f79b254451a2518 /scripts/nix-profile.sh.in | |
parent | 54fe8e0773870631724b7325553f84637bb3e05a (diff) |
nix-profile.sh: Revert to single-user version
Commit 6a214f3e06fa1c5f0a4d40e555f14d87691af297 copied most of the Nix shell initialisation code from NixOS to nix-profile.sh; however, that code assumes a multi-user install and is Linux-specific (e.g. it calls the "stat" command). So go back to the simple single-user version. Fixes #49.
Diffstat (limited to 'scripts/nix-profile.sh.in')
-rw-r--r-- | scripts/nix-profile.sh.in | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/scripts/nix-profile.sh.in b/scripts/nix-profile.sh.in index bc3dc719eb6f..ed49a892d969 100644 --- a/scripts/nix-profile.sh.in +++ b/scripts/nix-profile.sh.in @@ -1,50 +1,17 @@ -export NIX_USER_PROFILE_DIR=@localstatedir@/nix/profiles/per-user/$USER -export NIX_PROFILES="@localstatedir@/nix/profiles/default $HOME/.nix-profile" +if test -n "$HOME"; then + NIX_LINK="$HOME/.nix-profile" -# 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 + # Set the default profile. + if ! [ -L "$NIX_LINK" ]; then + echo "creating $NIX_LINK" >&2 + _NIX_DEF_LINK=@localstatedir@/nix/profiles/default + @coreutils@/ln -s "$_NIX_DEF_LINK" "$NIX_LINK" fi -fi -export PATH="$HOME/.nix-profile/bin:$PATH" - -# Subscribe the root user to the Nixpkgs channel by default. -if [ "$USER" = root -a ! -e $HOME/.nix-channels ]; then - echo "http://nixos.org/releases/nixos/channels/nixpkgs-unstable nixpkgs" > $HOME/.nix-channels -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 + # Subscribe the root user to the Nixpkgs channel by default. + if [ ! -e $HOME/.nix-channels ]; then + echo "http://nixos.org/releases/nixos/channels/nixpkgs-unstable nixpkgs" > $HOME/.nix-channels fi -fi -# Set up secure multi-user builds: non-root users build through the -# Nix daemon. -if [ "$USER" != root -a -e @localstatedir@/nix/daemon-socket/socket ]; then - export NIX_REMOTE=daemon -else - unset NIX_REMOTE + export PATH=$NIX_LINK/bin:$PATH fi |