mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-28 02:37:09 +00:00
add programs.bash module
This commit is contained in:
parent
d24886a648
commit
9439a439e8
3 changed files with 84 additions and 0 deletions
|
@ -17,6 +17,7 @@ let
|
|||
./modules/launchd
|
||||
./modules/services/activate-system.nix
|
||||
./modules/services/nix-daemon.nix
|
||||
./modules/programs/bash.nix
|
||||
./modules/programs/tmux.nix
|
||||
./modules/programs/zsh.nix
|
||||
];
|
||||
|
|
79
modules/programs/bash.nix
Normal file
79
modules/programs/bash.nix
Normal file
|
@ -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
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue