diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2016-12-12 23:51:08 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2016-12-12 23:51:08 +0100 |
| commit | 9439a439e8507010f837115fd3787d34d89fbd5a (patch) | |
| tree | 5f47bf09aff7b862705d0ea8b58b471102af5a9a /modules/programs | |
| parent | d24886a64849ca0a3b85a835ede37e75f3484058 (diff) | |
add programs.bash module
Diffstat (limited to 'modules/programs')
| -rw-r--r-- | modules/programs/bash.nix | 79 | ||||
| -rw-r--r-- | modules/programs/zsh.nix | 4 |
2 files changed, 83 insertions, 0 deletions
diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix new file mode 100644 index 0000000..9d7930b --- /dev/null +++ b/modules/programs/bash.nix @@ -0,0 +1,79 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.bash; + + bash = pkgs.runCommand pkgs.zsh.name + { buildInputs = [ pkgs.makeWrapper ]; } + '' + source $stdenv/setup + + mkdir -p $out/bin + makeWrapper ${pkgs.bash}/bin/bash $out/bin/bash + ''; + +in + +{ + options = { + + programs.bash.enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to configure bash as an interactive shell. + ''; + }; + + programs.bash.shell = mkOption { + type = types.path; + default = "${bash}/bin/bash"; + description = '' + Zsh shell to use. + ''; + }; + + 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 + pkgs.bash + ]; + + environment.variables.SHELL = "${cfg.shell}"; + + 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 + + export PATH=${config.environment.systemPath}''${PATH:+:$PATH} + ${config.system.build.setEnvironment} + ${config.system.build.setAliases} + + ${cfg.interactiveShellInit} + + # Read system-wide modifications. + if test -f /etc/bash.local; then + . /etc/bash.local + fi + ''; + + }; +} diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index ddf88ac..8c84557 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -112,6 +112,10 @@ in if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi __ETC_ZSHRC_SOURCED=1 + export PATH=${config.environment.systemPath}''${PATH:+:$PATH} + ${config.system.build.setEnvironment} + ${config.system.build.setAliases} + ${cfg.interactiveShellInit} # Read system-wide modifications. |
