2009-05-28 12:06:54 +00:00
|
|
|
# This module defines global configuration for the Bash shell, in
|
|
|
|
# particular /etc/bashrc and /etc/profile.
|
|
|
|
|
2010-09-13 15:41:38 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-05-28 12:06:54 +00:00
|
|
|
|
2009-05-28 13:17:56 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2010-09-13 15:41:38 +00:00
|
|
|
environment.shellInit = mkOption {
|
2009-05-28 13:17:56 +00:00
|
|
|
default = "";
|
|
|
|
example = ''export PATH=/godi/bin/:$PATH'';
|
|
|
|
description = "
|
|
|
|
Script used to initialized user shell environments.
|
|
|
|
";
|
2011-12-29 00:51:35 +00:00
|
|
|
type = with pkgs.lib.types; string;
|
2009-05-28 13:17:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
in
|
|
|
|
|
2009-05-28 12:06:54 +00:00
|
|
|
{
|
2009-05-28 13:17:56 +00:00
|
|
|
require = [options];
|
|
|
|
|
2009-05-28 12:06:54 +00:00
|
|
|
environment.etc =
|
2011-09-23 14:21:36 +00:00
|
|
|
[ { # Script executed when the shell starts as a login shell.
|
2009-05-28 12:06:54 +00:00
|
|
|
source = pkgs.substituteAll {
|
2011-09-23 14:21:36 +00:00
|
|
|
src = ./profile.sh;
|
2009-05-28 12:06:54 +00:00
|
|
|
wrapperDir = config.security.wrapperDir;
|
|
|
|
modulesTree = config.system.modulesTree;
|
|
|
|
shellInit = config.environment.shellInit;
|
|
|
|
};
|
|
|
|
target = "profile";
|
|
|
|
}
|
|
|
|
|
2011-09-23 14:21:36 +00:00
|
|
|
{ # /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";
|
2009-05-28 12:06:54 +00:00
|
|
|
}
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-05-28 12:06:54 +00:00
|
|
|
{ # Configuration for readline in bash.
|
|
|
|
source = ./inputrc;
|
|
|
|
target = "inputrc";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
system.build.binsh = pkgs.bashInteractive;
|
2010-09-13 15:41:38 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-05-28 12:06:54 +00:00
|
|
|
}
|