nix/home/program/bash/default.nix

68 lines
1.8 KiB
Nix
Raw Normal View History

2024-12-18 10:54:24 +03:00
{
util,
pkgs,
secret,
config,
...
}:
let
2024-12-18 10:54:24 +03:00
accent = "${config.module.style.color.accentR};${config.module.style.color.accentG};${config.module.style.color.accentB}";
negative = "${config.module.style.color.negativeR};${config.module.style.color.negativeG};${config.module.style.color.negativeB}";
neutral = "${config.module.style.color.neutralR};${config.module.style.color.neutralG};${config.module.style.color.neutralB}";
positive = "${config.module.style.color.positiveR};${config.module.style.color.positiveG};${config.module.style.color.positiveB}";
tgbot = secret.tg.bt;
tgdata = secret.tg.dt "false";
tgdatasilent = secret.tg.dt "true";
2024-12-18 11:13:33 +03:00
modulesRaw = pkgs.writeText "bash-user-modules-raw" (util.readFiles (util.ls ./module));
2024-12-18 10:54:24 +03:00
modulesFile = pkgs.replaceVars modulesRaw {
inherit
accent
negative
neutral
positive
tgbot
tgdata
tgdatasilent
;
};
in
{
2024-12-18 10:54:24 +03:00
inherit modulesFile;
bashrc =
2024-12-18 10:54:24 +03:00
(builtins.readFile modulesFile)
+ ''
# Find all functions.
function find_function() {
/usr/bin/env cat ${modulesFile} | /usr/bin/env grep "^function.*()" | /usr/bin/env sed -e "s/^function //" -e "s/().*//"
}
# Export all functions.
export -f $(find_function | tr '\n' ' ')
export -f find_function
# Autostart Sway.
if [[ -z $DISPLAY ]] && [[ "$(tty)" = "/dev/tty1" ]]; then
exec sway
fi
'';
# bash_profile = ''
# # Home manager.
# [ -e ~/.nix-profile/etc/profile.d/nix.sh ] && source ~/.nix-profile/etc/profile.d/nix.sh
# # Bashrc.
# [ -f ~/.bashrc ] && source ~/.bashrc
# # Profile.
# [ -f ~/.profile ] && source ~/.profile
# '';
# profile = ''
# # Load HM vars.
# [ -e ~/.nix-profile/etc/profile.d/hm-session-vars.sh ] && source ~/.nix-profile/etc/profile.d/hm-session-vars.sh
# '';
}