nix/module/common/bash/default.nix

23 lines
591 B
Nix
Raw Normal View History

2024-04-06 03:03:58 +03:00
{ style, util, pkgs, ... } @args: let
modules = util.catText (util.ls ./module) args;
2024-04-28 21:24:49 +03:00
modulesFile = pkgs.writeText "bashModules" modules;
2024-04-06 03:03:58 +03:00
in {
2024-04-08 18:26:01 +03:00
inherit modules;
config = modules + util.trimTabs (''
2024-04-06 03:03:58 +03:00
# Find all functions.
function find_function() {
2024-04-28 21:24:49 +03:00
/usr/bin/env cat ${modulesFile} | /usr/bin/env grep "^function.*()" | /usr/bin/env sed -e "s/^function //" -e "s/().*//"
2024-04-06 03:03:58 +03:00
}
# Export all functions.
export -f $(find_function | tr '\n' ' ')
2024-04-07 19:57:58 +03:00
export -f find_function
2024-04-06 03:03:58 +03:00
# Autostart Sway.
if [[ -z $DISPLAY ]] && [[ "$(tty)" = "/dev/tty1" ]]; then
exec sway
fi
'');
}