2016-12-12 22:51:08 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.bash;
|
|
|
|
|
2017-03-11 21:30:15 +00:00
|
|
|
shell = pkgs.runCommand pkgs.bashInteractive.name
|
2016-12-12 22:51:08 +00:00
|
|
|
{ buildInputs = [ pkgs.makeWrapper ]; }
|
|
|
|
''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
2017-03-11 21:30:15 +00:00
|
|
|
makeWrapper ${pkgs.bashInteractive}/bin/bash $out/bin/bash
|
2016-12-12 22:51:08 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
|
|
|
|
programs.bash.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to configure bash as an interactive shell.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.bash.interactiveShellInit = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Shell script code called during interactive bash shell initialisation.
|
|
|
|
'';
|
|
|
|
type = types.lines;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
environment.systemPackages =
|
|
|
|
[ # Include bash package
|
2017-03-11 21:30:15 +00:00
|
|
|
pkgs.bashInteractive
|
2016-12-12 22:51:08 +00:00
|
|
|
];
|
|
|
|
|
2016-12-18 13:04:31 +00:00
|
|
|
environment.loginShell = mkDefault "${shell}/bin/bash -l";
|
2016-12-17 22:11:35 +00:00
|
|
|
environment.variables.SHELL = mkDefault "${shell}/bin/bash";
|
2016-12-12 22:51:08 +00:00
|
|
|
|
|
|
|
environment.etc."bashrc".text = ''
|
|
|
|
# /etc/bashrc: DO NOT EDIT -- this file has been generated automatically.
|
|
|
|
# This file is read for interactive shells.
|
|
|
|
|
|
|
|
# Only execute this file once per shell.
|
|
|
|
if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi
|
|
|
|
__ETC_BASHRC_SOURCED=1
|
|
|
|
|
2017-01-08 21:56:16 +00:00
|
|
|
export PATH=${config.environment.systemPath}''${PATH:+:$PATH}
|
|
|
|
${config.system.build.setEnvironment}
|
|
|
|
${config.system.build.setAliases}
|
|
|
|
|
|
|
|
${config.environment.extraInit}
|
|
|
|
${config.environment.interactiveShellInit}
|
|
|
|
${cfg.interactiveShellInit}
|
2016-12-12 22:51:08 +00:00
|
|
|
|
|
|
|
# Read system-wide modifications.
|
|
|
|
if test -f /etc/bash.local; then
|
|
|
|
. /etc/bash.local
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|