* Move most bash initialisation to /etc/bashrc. Now finally ssh
commands like "ssh -t host command" initialise the environment properly. svn path=/nixos/trunk/; revision=12366
This commit is contained in:
parent
0ac32cbb99
commit
088b09f401
18
etc/bashrc
18
etc/bashrc
|
@ -1,18 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# A nice prompt.
|
||||
PROMPT_COLOR="1;31m"
|
||||
let $UID && PROMPT_COLOR="1;32m"
|
||||
PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
|
||||
if test "x$TERM" == "xxterm"; then
|
||||
PS1="\033]2;\h:\u:\w\007$PS1"
|
||||
fi
|
||||
|
||||
# Some aliases.
|
||||
alias ls="ls --color=tty"
|
||||
alias ll="ls -l"
|
||||
alias l="ls -alh"
|
||||
alias which="type -p"
|
||||
|
||||
# Help `rpcgen' find `cpp', assuming it's installed in the user's environment.
|
||||
alias rpcgen="rpcgen -Y $HOME/.nix-profile/bin"
|
70
etc/bashrc.sh
Normal file
70
etc/bashrc.sh
Normal file
|
@ -0,0 +1,70 @@
|
|||
# Initialise a bunch of environment variables.
|
||||
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
|
||||
export LD_LIBRARY_PATH=/var/run/opengl-driver/lib
|
||||
if test -n "@nssModulesPath@"; then
|
||||
LD_LIBRARY_PATH=@nssModulesPath@:$LD_LIBRARY_PATH
|
||||
fi
|
||||
export MODULE_DIR=@modulesTree@/lib/modules
|
||||
export NIXPKGS_CONFIG=/nix/etc/config.nix
|
||||
export PAGER="less -R"
|
||||
export TZ=@timeZone@
|
||||
export TZDIR=@glibc@/share/zoneinfo
|
||||
export FONTCONFIG_FILE=/etc/fonts/fonts.conf
|
||||
export LANG=@defaultLocale@
|
||||
export EDITOR=nano
|
||||
export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info
|
||||
export LOCATE_PATH=/var/cache/locatedb
|
||||
|
||||
|
||||
# Set up secure multi-user builds: non-root users build through the
|
||||
# Nix daemon.
|
||||
if test "$USER" != root; then
|
||||
export NIX_REMOTE=daemon
|
||||
else
|
||||
export NIX_REMOTE=
|
||||
fi
|
||||
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
@nixEnvVars@
|
||||
|
||||
|
||||
# Include the various profiles in the appropriate environment variables.
|
||||
NIX_USER_PROFILE_DIR=/nix/var/nix/profiles/per-user/$USER
|
||||
|
||||
NIX_PROFILES="/nix/var/nix/profiles/default $NIX_USER_PROFILE_DIR/profile"
|
||||
|
||||
for i in $NIX_PROFILES; do # !!! reverse
|
||||
export PATH=$i/bin:$i/sbin:$PATH
|
||||
export INFOPATH=$i/info:$i/share/info:$INFOPATH
|
||||
export PKG_CONFIG_PATH="$i/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export ACLOCAL_PATH="$i/share/aclocal:$ACLOCAL_PATH"
|
||||
done
|
||||
|
||||
|
||||
# Search directory for Aspell dictionaries.
|
||||
export ASPELL_CONF="dict-dir $NIX_USER_PROFILE_DIR/profile/lib/aspell"
|
||||
|
||||
|
||||
# ~/bin and the setuid wrappers override other bin directories.
|
||||
export PATH=$HOME/bin:@wrapperDir@:$PATH
|
||||
|
||||
|
||||
# Provide a nice prompt.
|
||||
PROMPT_COLOR="1;31m"
|
||||
let $UID && PROMPT_COLOR="1;32m"
|
||||
PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
|
||||
if test "$TERM" = "xterm"; then
|
||||
PS1="\033]2;\h:\u:\w\007$PS1"
|
||||
fi
|
||||
|
||||
|
||||
# Some aliases.
|
||||
alias ls="ls --color=tty"
|
||||
alias ll="ls -l"
|
||||
alias l="ls -alh"
|
||||
alias which="type -p"
|
||||
|
||||
|
||||
# Help `rpcgen' find `cpp', assuming it's installed in the user's environment.
|
||||
alias rpcgen="rpcgen -Y $HOME/.nix-profile/bin"
|
|
@ -11,12 +11,6 @@ let
|
|||
# !!! ugh, these files shouldn't be created here.
|
||||
|
||||
|
||||
envConf = pkgs.writeText "environment" ''
|
||||
PATH=${systemPath}/bin:${systemPath}/sbin:${pkgs.openssh}/bin
|
||||
NIX_REMOTE=daemon
|
||||
'' /* ${pkgs.openssh}/bin is a hack to get remote scp to work */;
|
||||
|
||||
|
||||
pamConsoleHandlers = pkgs.writeText "console.handlers" ''
|
||||
console consoledevs /dev/tty[0-9][0-9]* :[0-9]\.[0-9] :[0-9]
|
||||
${pkgs.pam_console}/sbin/pam_console_apply lock logfail wait -t tty -s -c ${pamConsolePerms}
|
||||
|
@ -25,6 +19,7 @@ let
|
|||
|
||||
pamConsolePerms = ./security/console.perms;
|
||||
|
||||
|
||||
in
|
||||
|
||||
|
||||
|
@ -106,19 +101,19 @@ import ../helpers/make-etc.nix {
|
|||
}
|
||||
|
||||
{ # Script executed when the shell starts as a non-login shell (system-wide version).
|
||||
source = ./bashrc;
|
||||
target = "bashrc";
|
||||
}
|
||||
|
||||
{ # Script executed when the shell starts as a login shell.
|
||||
source = pkgs.substituteAll {
|
||||
src = ./profile.sh;
|
||||
src = ./bashrc.sh;
|
||||
inherit systemPath wrapperDir modulesTree nssModulesPath;
|
||||
inherit (pkgs) glibc;
|
||||
timeZone = config.time.timeZone;
|
||||
defaultLocale = config.i18n.defaultLocale;
|
||||
inherit nixEnvVars;
|
||||
};
|
||||
target = "bashrc";
|
||||
}
|
||||
|
||||
{ # Script executed when the shell starts as a login shell.
|
||||
source = ./profile.sh;
|
||||
target = "profile";
|
||||
}
|
||||
|
||||
|
@ -214,7 +209,7 @@ import ../helpers/make-etc.nix {
|
|||
then pkgs.pam_ldap
|
||||
else "/no-such-path";
|
||||
inherit (pkgs.xorg) xauth;
|
||||
inherit envConf pamConsoleHandlers;
|
||||
inherit pamConsoleHandlers;
|
||||
isLDAPEnabled = if isLDAPEnabled then "" else "#";
|
||||
};
|
||||
target = "pam.d/" + program;
|
||||
|
|
|
@ -10,4 +10,3 @@ password sufficient @pam_unix2@/lib/security/pam_unix2.so nullok
|
|||
|
||||
@isLDAPEnabled@ session optional @pam_ldap@/lib/security/pam_ldap.so
|
||||
session required @pam_unix2@/lib/security/pam_unix2.so
|
||||
session optional pam_env.so envfile=@envConf@
|
||||
|
|
|
@ -1,35 +1,12 @@
|
|||
export PATH=@wrapperDir@:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
|
||||
export LD_LIBRARY_PATH=/var/run/opengl-driver/lib
|
||||
if test -n "@nssModulesPath@"; then
|
||||
LD_LIBRARY_PATH=@nssModulesPath@:$LD_LIBRARY_PATH
|
||||
fi
|
||||
export MODULE_DIR=@modulesTree@/lib/modules
|
||||
export NIXPKGS_CONFIG=/nix/etc/config.nix
|
||||
export PAGER="less -R"
|
||||
export TZ=@timeZone@
|
||||
export TZDIR=@glibc@/share/zoneinfo
|
||||
export FONTCONFIG_FILE=/etc/fonts/fonts.conf
|
||||
export LANG=@defaultLocale@
|
||||
export EDITOR=nano
|
||||
export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info
|
||||
export LOCATE_PATH=/var/cache/locatedb
|
||||
# This file is executed by all login shells. Don't ask what a login
|
||||
# shell is, nobody knows. Most global environment variables should go
|
||||
# in /etc/bashrc, which is by default included by non-login shells,
|
||||
# but which we include here as well.
|
||||
|
||||
|
||||
# Set up secure multi-user builds: non-root users build through the
|
||||
# Nix daemon.
|
||||
if test "$USER" != root; then
|
||||
export NIX_REMOTE=daemon
|
||||
else
|
||||
export NIX_REMOTE=
|
||||
fi
|
||||
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
@nixEnvVars@
|
||||
source /etc/bashrc
|
||||
|
||||
|
||||
# Set up the per-user profile.
|
||||
NIX_USER_PROFILE_DIR=/nix/var/nix/profiles/per-user/$USER
|
||||
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
|
||||
|
@ -45,20 +22,6 @@ if ! test -L $HOME/.nix-profile; then
|
|||
fi
|
||||
fi
|
||||
|
||||
NIX_PROFILES="/nix/var/nix/profiles/default $NIX_USER_PROFILE_DIR/profile"
|
||||
|
||||
for i in $NIX_PROFILES; do # !!! reverse
|
||||
export PATH=$i/bin:$i/sbin:$PATH
|
||||
export INFOPATH=$i/info:$i/share/info:$INFOPATH
|
||||
export PKG_CONFIG_PATH="$i/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export ACLOCAL_PATH="$i/share/aclocal:$ACLOCAL_PATH"
|
||||
done
|
||||
|
||||
# Search directory for Aspell dictionaries.
|
||||
export ASPELL_CONF="dict-dir $NIX_USER_PROFILE_DIR/profile/lib/aspell"
|
||||
|
||||
export PATH=$HOME/bin:$PATH
|
||||
|
||||
|
||||
# Create the per-user garbage collector roots directory.
|
||||
NIX_USER_GCROOTS_DIR=/nix/var/nix/gcroots/per-user/$USER
|
||||
|
@ -80,9 +43,6 @@ if test ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Include bashrc settings
|
||||
|
||||
source /etc/bashrc
|
||||
|
||||
# Read system-wide modifications.
|
||||
if test -f /etc/profile.local; then
|
||||
|
|
Loading…
Reference in a new issue