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