* 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.
|
# !!! 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" ''
|
pamConsoleHandlers = pkgs.writeText "console.handlers" ''
|
||||||
console consoledevs /dev/tty[0-9][0-9]* :[0-9]\.[0-9] :[0-9]
|
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}
|
${pkgs.pam_console}/sbin/pam_console_apply lock logfail wait -t tty -s -c ${pamConsolePerms}
|
||||||
@ -25,6 +19,7 @@ let
|
|||||||
|
|
||||||
pamConsolePerms = ./security/console.perms;
|
pamConsolePerms = ./security/console.perms;
|
||||||
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
||||||
@ -106,19 +101,19 @@ import ../helpers/make-etc.nix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ # Script executed when the shell starts as a non-login shell (system-wide version).
|
{ # 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 {
|
source = pkgs.substituteAll {
|
||||||
src = ./profile.sh;
|
src = ./bashrc.sh;
|
||||||
inherit systemPath wrapperDir modulesTree nssModulesPath;
|
inherit systemPath wrapperDir modulesTree nssModulesPath;
|
||||||
inherit (pkgs) glibc;
|
inherit (pkgs) glibc;
|
||||||
timeZone = config.time.timeZone;
|
timeZone = config.time.timeZone;
|
||||||
defaultLocale = config.i18n.defaultLocale;
|
defaultLocale = config.i18n.defaultLocale;
|
||||||
inherit nixEnvVars;
|
inherit nixEnvVars;
|
||||||
};
|
};
|
||||||
|
target = "bashrc";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # Script executed when the shell starts as a login shell.
|
||||||
|
source = ./profile.sh;
|
||||||
target = "profile";
|
target = "profile";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +209,7 @@ import ../helpers/make-etc.nix {
|
|||||||
then pkgs.pam_ldap
|
then pkgs.pam_ldap
|
||||||
else "/no-such-path";
|
else "/no-such-path";
|
||||||
inherit (pkgs.xorg) xauth;
|
inherit (pkgs.xorg) xauth;
|
||||||
inherit envConf pamConsoleHandlers;
|
inherit pamConsoleHandlers;
|
||||||
isLDAPEnabled = if isLDAPEnabled then "" else "#";
|
isLDAPEnabled = if isLDAPEnabled then "" else "#";
|
||||||
};
|
};
|
||||||
target = "pam.d/" + program;
|
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
|
@isLDAPEnabled@ session optional @pam_ldap@/lib/security/pam_ldap.so
|
||||||
session required @pam_unix2@/lib/security/pam_unix2.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
|
# This file is executed by all login shells. Don't ask what a login
|
||||||
export LD_LIBRARY_PATH=/var/run/opengl-driver/lib
|
# shell is, nobody knows. Most global environment variables should go
|
||||||
if test -n "@nssModulesPath@"; then
|
# in /etc/bashrc, which is by default included by non-login shells,
|
||||||
LD_LIBRARY_PATH=@nssModulesPath@:$LD_LIBRARY_PATH
|
# but which we include here as well.
|
||||||
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
|
|
||||||
|
|
||||||
|
source /etc/bashrc
|
||||||
# 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@
|
|
||||||
|
|
||||||
|
|
||||||
# Set up the per-user profile.
|
# 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
|
mkdir -m 0755 -p $NIX_USER_PROFILE_DIR
|
||||||
if test "$(stat --printf '%u' $NIX_USER_PROFILE_DIR)" != "$(id -u)"; then
|
if test "$(stat --printf '%u' $NIX_USER_PROFILE_DIR)" != "$(id -u)"; then
|
||||||
echo "WARNING: bad ownership on $NIX_USER_PROFILE_DIR" >&2
|
echo "WARNING: bad ownership on $NIX_USER_PROFILE_DIR" >&2
|
||||||
@ -45,20 +22,6 @@ if ! test -L $HOME/.nix-profile; then
|
|||||||
fi
|
fi
|
||||||
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.
|
# Create the per-user garbage collector roots directory.
|
||||||
NIX_USER_GCROOTS_DIR=/nix/var/nix/gcroots/per-user/$USER
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Include bashrc settings
|
|
||||||
|
|
||||||
source /etc/bashrc
|
|
||||||
|
|
||||||
# Read system-wide modifications.
|
# Read system-wide modifications.
|
||||||
if test -f /etc/profile.local; then
|
if test -f /etc/profile.local; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user