nixpkgs/modules/programs/bash/bash.nix
Peter Simons 432d71f3ed modules/programs/bash: major clean-up and re-factoring of /etc/profile and /etc/bashrc
* Moved bash-specific code from /etc/profile to /etc/bashrc.

 * Moved general Bourne shell code from /etc/bashrc to /etc/profile.

 * Added "include guards" to both files to ensure that they aren't sourced
   multiple times (which would result in lots of redundancy in $PATH, etc.).

 * Both files include each other to make sure that the correct system
   environment is always defined.

 * When the current user has installed the 'bash-completion' package in her
   $HOME/.nix-profile, programmable completion is automatically enabled in
   interactive shells.

 * The /etc/skel/.bashrc we installed has been dropped because it is redundant.

svn path=/nixos/trunk/; revision=29451
2011-09-23 14:21:36 +00:00

63 lines
1.5 KiB
Nix

# This module defines global configuration for the Bash shell, in
# particular /etc/bashrc and /etc/profile.
{ config, pkgs, ... }:
with pkgs.lib;
let
options = {
environment.shellInit = mkOption {
default = "";
example = ''export PATH=/godi/bin/:$PATH'';
description = "
Script used to initialized user shell environments.
";
merge = mergeStringOption;
};
};
in
{
require = [options];
environment.etc =
[ { # Script executed when the shell starts as a login shell.
source = pkgs.substituteAll {
src = ./profile.sh;
wrapperDir = config.security.wrapperDir;
modulesTree = config.system.modulesTree;
shellInit = config.environment.shellInit;
};
target = "profile";
}
{ # /etc/bashrc: executed every time a bash starts. Sources
# /etc/profile to ensure that the system environment is
# configured properly.
source = ./bashrc.sh;
target = "bashrc";
}
{ # Configuration for readline in bash.
source = ./inputrc;
target = "inputrc";
}
];
system.build.binsh = pkgs.bashInteractive;
system.activationScripts.binsh = stringAfter [ "stdio" ]
''
# Create the required /bin/sh symlink; otherwise lots of things
# (notably the system() function) won't work.
mkdir -m 0755 -p /bin
ln -sfn ${config.system.build.binsh}/bin/sh /bin/sh
'';
}