diff --git a/nixos/modules/programs/bash/bash.nix b/nixos/modules/programs/bash/bash.nix index 213f0d2698ae..6acbea562822 100644 --- a/nixos/modules/programs/bash/bash.nix +++ b/nixos/modules/programs/bash/bash.nix @@ -111,6 +111,13 @@ in internal = true; }; + logout = lib.mkOption { + default = ""; + description = '' + Shell script code called during login bash shell logout. + ''; + type = lib.types.lines; + }; }; }; @@ -197,6 +204,21 @@ in fi ''; + environment.etc.bash_logout.text = '' + # /etc/bash_logout: DO NOT EDIT -- this file has been generated automatically. + + # Only execute this file once per shell. + if [ -n "$__ETC_BASHLOGOUT_SOURCED" ] || [ -n "$NOSYSBASHLOGOUT" ]; then return; fi + __ETC_BASHLOGOUT_SOURCED=1 + + ${cfg.logout} + + # Read system-wide modifications. + if test -f /etc/bash_logout.local; then + . /etc/bash_logout.local + fi + ''; + # Configuration for readline in bash. We use "option default" # priority to allow user override using both .text and .source. environment.etc.inputrc.source = lib.mkOptionDefault ./inputrc;