summary refs log tree commit diff
path: root/modules/programs
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-05-28 12:06:54 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-05-28 12:06:54 +0000
commit421dcc35c56bce06d75f541b225767e59305f375 (patch)
tree3a82e8a67780a25e86b741b21b41a9f49e15be08 /modules/programs
parent3badebea95d77106e454f9351e94f8ca9939de8b (diff)
downloadnixpkgs-421dcc35c56bce06d75f541b225767e59305f375.tar
nixpkgs-421dcc35c56bce06d75f541b225767e59305f375.tar.gz
nixpkgs-421dcc35c56bce06d75f541b225767e59305f375.tar.bz2
nixpkgs-421dcc35c56bce06d75f541b225767e59305f375.tar.lz
nixpkgs-421dcc35c56bce06d75f541b225767e59305f375.tar.xz
nixpkgs-421dcc35c56bce06d75f541b225767e59305f375.tar.zst
nixpkgs-421dcc35c56bce06d75f541b225767e59305f375.zip
* Moved the Bash configuration to modules/programs/bash.
svn path=/nixos/branches/modular-nixos/; revision=15759
Diffstat (limited to 'modules/programs')
-rw-r--r--modules/programs/bash/bash.nix42
-rw-r--r--modules/programs/bash/bashrc-user.sh6
-rw-r--r--modules/programs/bash/bashrc.sh84
-rw-r--r--modules/programs/bash/inputrc36
-rw-r--r--modules/programs/bash/profile.sh50
5 files changed, 218 insertions, 0 deletions
diff --git a/modules/programs/bash/bash.nix b/modules/programs/bash/bash.nix
new file mode 100644
index 00000000000..e7be3b5e102
--- /dev/null
+++ b/modules/programs/bash/bash.nix
@@ -0,0 +1,42 @@
+# This module defines global configuration for the Bash shell, in
+# particular /etc/bashrc and /etc/profile.
+
+{config, pkgs, ...}:
+
+{
+  environment.etc =
+    [ { # /etc/bashrc: script executed when the shell starts as a
+        # non-login shell.  /etc/profile also sources this file, so
+        # most global configuration (such as environment variables)
+        # should go into this script.
+        source = pkgs.substituteAll {
+          src = ./bashrc.sh;
+          systemPath = config.system.path;
+          wrapperDir = config.security.wrapperDir;
+          modulesTree = config.system.modulesTree;
+          defaultLocale = config.i18n.defaultLocale;
+          nixEnvVars = config.nix.envVars;
+          shellInit = config.environment.shellInit;
+        };
+        target = "bashrc";      
+      }
+
+      { # Script executed when the shell starts as a login shell.
+        source = ./profile.sh;
+        target = "profile";
+      }
+
+      { # Template for ~/.bashrc: script executed when the shell
+        # starts as a non-login shell.
+        source = ./bashrc-user.sh;
+        target = "skel/.bashrc";
+      }
+      
+      { # Configuration for readline in bash.
+        source = ./inputrc;
+        target = "inputrc";
+      }
+    ];
+
+  system.build.binsh = pkgs.bashInteractive;
+}
diff --git a/modules/programs/bash/bashrc-user.sh b/modules/programs/bash/bashrc-user.sh
new file mode 100644
index 00000000000..ef536c132c9
--- /dev/null
+++ b/modules/programs/bash/bashrc-user.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+if [ -f /etc/bashrc ]
+then
+    source /etc/bashrc
+fi
diff --git a/modules/programs/bash/bashrc.sh b/modules/programs/bash/bashrc.sh
new file mode 100644
index 00000000000..ad6e5d3f247
--- /dev/null
+++ b/modules/programs/bash/bashrc.sh
@@ -0,0 +1,84 @@
+# 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
+export MODULE_DIR=@modulesTree@/lib/modules
+export NIXPKGS_CONFIG=/nix/etc/config.nix
+export NIXPKGS_ALL=/etc/nixos/nixpkgs
+export PAGER="less -R"
+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
+@shellInit@
+export LOCALE_ARCHIVE=/var/run/current-system/sw/lib/locale/locale-archive
+
+
+# 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"
+
+    # Automake's `aclocal' bails out if it finds non-existent directories
+    # in its path.  !!! This has been fixed in the stdenv branch.
+    if [ -d "$i/share/aclocal" ]; then
+        export ACLOCAL_PATH="$i/share/aclocal:$ACLOCAL_PATH"
+    fi
+
+    # "lib/site_perl" is for backwards compatibility with packages
+    # from Nixpkgs <= 0.12.
+    export PERL5LIB="$i/lib/perl5/site_perl:$i/lib/site_perl:$PERL5LIB"
+
+    # GStreamer.
+    export GST_PLUGIN_PATH="$i/lib/gstreamer-0.10:$GST_PLUGIN_PATH"
+
+    # KDE/Gnome stuff.
+    export KDEDIRS=$i:$KDEDIRS
+    export XDG_CONFIG_DIRS=$i/etc/xdg:$XDG_CONFIG_DIRS
+    export XDG_DATA_DIRS=$i/share:$XDG_DATA_DIRS
+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"
diff --git a/modules/programs/bash/inputrc b/modules/programs/bash/inputrc
new file mode 100644
index 00000000000..e4eabc052c5
--- /dev/null
+++ b/modules/programs/bash/inputrc
@@ -0,0 +1,36 @@
+# inputrc borrowed from CentOS (RHEL).
+
+set bell-style none
+
+set meta-flag on
+set input-meta on
+set convert-meta off
+set output-meta on
+
+#set mark-symlinked-directories on
+
+$if mode=emacs
+
+# for linux console and RH/Debian xterm
+"\e[1~": beginning-of-line
+"\e[4~": end-of-line
+"\e[5~": beginning-of-history
+"\e[6~": end-of-history
+"\e[3~": delete-char
+"\e[2~": quoted-insert
+"\e[5C": forward-word
+"\e[5D": backward-word
+"\e[1;5C": forward-word
+"\e[1;5D": backward-word
+
+# for rxvt
+"\e[8~": end-of-line
+
+# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
+"\eOH": beginning-of-line
+"\eOF": end-of-line
+
+# for freebsd console
+"\e[H": beginning-of-line
+"\e[F": end-of-line
+$endif
diff --git a/modules/programs/bash/profile.sh b/modules/programs/bash/profile.sh
new file mode 100644
index 00000000000..8718f8087fc
--- /dev/null
+++ b/modules/programs/bash/profile.sh
@@ -0,0 +1,50 @@
+# 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.
+
+source /etc/bashrc
+
+
+# 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
+        ln -s $NIX_USER_PROFILE_DIR/profile $HOME/.nix-profile
+    else
+        # Root installs in the system-wide profile by default.
+        ln -s /nix/var/nix/profiles/default $HOME/.nix-profile
+    fi
+fi
+
+
+# Create the per-user garbage collector roots directory.
+NIX_USER_GCROOTS_DIR=/nix/var/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 test ! -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
+    ln -s /etc/nixos/nixpkgs $HOME/.nix-defexpr/nixpkgs_sys
+    ln -s /etc/nixos/nixos $HOME/.nix-defexpr/nixos
+    if test "$USER" != root; then
+        ln -s /nix/var/nix/gcroots/per-user/root/channels $HOME/.nix-defexpr/channels_root
+    fi
+fi
+
+
+# Read system-wide modifications.
+if test -f /etc/profile.local; then
+    source /etc/profile.local
+fi