mail container only needs to use mail.nix, not full fudo config

This commit is contained in:
root 2021-01-15 13:10:57 -06:00
commit 4ed8648925
7 changed files with 241 additions and 24 deletions

44
bash.nix Normal file
View File

@ -0,0 +1,44 @@
{ config, lib, pkgs, ... }:
let
helpers = pkgs.writeText "bash.helpers"
(builtins.readFile ./static/bash/bash.helpers);
colors =
pkgs.writeText "bash.colors" (builtins.readFile ./static/bash/bash.colors);
env = pkgs.writeText "bash.env" (builtins.readFile ./static/bash/bash.env);
in {
config.programs.bash = {
shellAliases = {
ll = "ls $LS_OPTIONS -alF";
l = "ls $LS_OPTIONS -CF";
la = "ls $LS_OPTIONS -A";
".." = "cd ..";
"..." = "cd ../..";
rm = "rm --one-file-system --preserve-root";
};
shellInit = ''
if [ -d $HOME/bin ]; then
PATH="$HOME/bin:$PATH"
fi
'';
interactiveShellInit = ''
case $TERM in
screen|xterm*|rxvt*)
export LS_OPTIONS="--color=auto"
;;
*)
export LS_OPTIONS=""
;;
esac
. ${colors}
. ${helpers}
. ${env}
'';
};
}

View File

@ -9,6 +9,7 @@ in {
./hardware-configuration.nix
./packages/local.nix
./config
./bash.nix
<home-manager/nixos>
];

View File

@ -158,8 +158,8 @@ in {
doom-emacs-config = pkgs.fetchgit {
url = "https://git.fudo.org/niten/doom-emacs.git";
rev = "467c45705c73ee39acbfabc04c5aaa4099408dc4";
sha256 = "172ah7ymlwymb4rx719nhsfvsxwmq14nlisba84kw34cmhdcsjh7";
rev = "f89cc7e24e09f0ea24ce7eef8aaf4f061744094c";
sha256 = "1cwf1dfknnpkg1gpj2c0nihxw00n790xsfli4fk3iqm62m66cw1s";
};
# vanilla-forum = import vanilla-forum.nix { inherit pkgs lib; };

72
static/bash/bash.colors Normal file
View File

@ -0,0 +1,72 @@
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
# Bold
BBlack='\e[1;30m' # Black
BRed='\e[1;31m' # Red
BGreen='\e[1;32m' # Green
BYellow='\e[1;33m' # Yellow
BBlue='\e[1;34m' # Blue
BPurple='\e[1;35m' # Purple
BCyan='\e[1;36m' # Cyan
BWhite='\e[1;37m' # White
# Underline
UBlack='\e[4;30m' # Black
URed='\e[4;31m' # Red
UGreen='\e[4;32m' # Green
UYellow='\e[4;33m' # Yellow
UBlue='\e[4;34m' # Blue
UPurple='\e[4;35m' # Purple
UCyan='\e[4;36m' # Cyan
UWhite='\e[4;37m' # White
# Background
On_Black='\e[40m' # Black
On_Red='\e[41m' # Red
On_Green='\e[42m' # Green
On_Yellow='\e[43m' # Yellow
On_Blue='\e[44m' # Blue
On_Purple='\e[45m' # Purple
On_Cyan='\e[46m' # Cyan
On_White='\e[47m' # White
# High Intensity
IBlack='\e[0;90m' # Black
IRed='\e[0;91m' # Red
IGreen='\e[0;92m' # Green
IYellow='\e[0;93m' # Yellow
IBlue='\e[0;94m' # Blue
IPurple='\e[0;95m' # Purple
ICyan='\e[0;96m' # Cyan
IWhite='\e[0;97m' # White
# Bold High Intensity
BIBlack='\e[1;90m' # Black
BIRed='\e[1;91m' # Red
BIGreen='\e[1;92m' # Green
BIYellow='\e[1;93m' # Yellow
BIBlue='\e[1;94m' # Blue
BIPurple='\e[1;95m' # Purple
BICyan='\e[1;96m' # Cyan
BIWhite='\e[1;97m' # White
# High Intensity backgrounds
On_IBlack='\e[0;100m' # Black
On_IRed='\e[0;101m' # Red
On_IGreen='\e[0;102m' # Green
On_IYellow='\e[0;103m' # Yellow
On_IBlue='\e[0;104m' # Blue
On_IPurple='\e[0;105m' # Purple
On_ICyan='\e[0;106m' # Cyan
On_IWhite='\e[0;107m' # White

22
static/bash/bash.env Normal file
View File

@ -0,0 +1,22 @@
if [ -d /fudo/etc ]; then
FUDO_CONFIG=/fudo/etc
fi
if [ -f $HOME/.bash_local ]; then
. $HOME/.bash_local
fi
if [ -f $HOME/.bash_env ]; then
. $HOME/.bash_env
fi
if [ -f $HOME/.bash_prompt ]; then
. $HOME/.bash_prompt
elif [ "${TERM}x" == "dumbx" ]; then
export PS1="\u@\h:\w > "
elif [ $( type -t __makePS1 ) ]; then
export PROMPT_COMMAND=__makePS1
else
export PS1="\u@\h:\w > "
fi

99
static/bash/bash.helpers Normal file
View File

@ -0,0 +1,99 @@
#!/usr/bin/env bash
function __makeTerminalTitle() {
local title=''
local CURRENT_DIR="${PWD/#$HOME/\~}"
if [ -n "${SSH_CONNECTION}" ] || [ $UID -eq 0 ]; then
title+="`hostname`:${CURRENT_DIR} [`whoami`@`hostname -f`]"
else
title+="${CURRENT_DIR} [`whoami`]"
fi
echo -en '\033]2;'${title}'\007'
}
function __getMachineId() {
if [ -f /etc/machine-id ]; then
echo $((0x$(cat /etc/machine-id | head -c 15)))
elif [ -x "$(which hostid 2>&1)" ]; then
echo $(( (${#HOSTNAME}+0x$(hostid))))
else
echo "00000000"
fi
}
function __makePS1() {
local EXIT="$?"
if [ ! -n "${HOST_COLOR}" ]; then
local H=$(__getMachineId)
HOST_COLOR=$(tput setaf $((H%5 + 2))) # foreground
fi
PS1=''
if [ ${USER} == root ]; then
PS1+="\[${Red}\]" # root
elif [ ${USER} != ${LOGNAME} ]; then
PS1+="\[${Blue}\]" # normal user
else
PS1+="\[${Green}\]" # normal user
fi
PS1+="\u\[${Color_Off}\]"
if [ -n "${SSH_CONNECTION}" ] || [ $UID -eq 0 ]; then
PS1+="\[${Purple}\]@\[${Color_Off}\]"
PS1+="\[${UWhite}${HOST_COLOR}\]\h\[${Color_Off}\]" # host displayed only if ssh connection
fi
PS1+="\[${Purple}\]:\w" # working directory
# screen sessions
local SCREEN_PATHS="/var/run/screens/S-`whoami` /var/run/screen/S-`whoami` /var/run/uscreens/S-`whoami`"
for screen_path in ${SCREEN_PATHS}; do
if [ -d ${screen_path} ]; then
SCREEN_JOBS=`ls ${screen_path} | wc -w`
if [ ${SCREEN_JOBS} != 0 ]; then
local current_screen="$(echo ${STY} | cut -d '.' -f 1)"
if [ -n "${current_screen}" ]; then
current_screen=":${current_screen}"
fi
PS1+=" \[${BGreen}\][s${SCREEN_JOBS}${current_screen}]\[${Color_Off}\]"
fi
break
fi
done
# git branch
if [ -x "`which git 2>&1`" ]; then
local branch="$(git name-rev --name-only HEAD 2>/dev/null)"
if [ -n "${branch}" ]; then
local git_status="$(git status --porcelain -b 2>/dev/null)"
local letters="$( echo "${git_status}" | grep --regexp=' \w ' | sed -e 's/^\s\?\(\w\)\s.*$/\1/' )"
local untracked="$( echo "${git_status}" | grep -F '?? ' | sed -e 's/^\?\(\?\)\s.*$/\1/' )"
local status_line="$( echo -e "${letters}\n${untracked}" | sort | uniq | tr -d '[:space:]' )"
PS1+=" \[${Blue}\](git: ${branch}"
if [ -n "${status_line}" ]; then
PS1+=" ${status_line}"
fi
PS1+=")\[${Color_Off}\]"
fi
fi
PS1+="\n"
# exit code
if [ ${EXIT} != 0 ]; then
PS1+="\[${BRed}\][!${EXIT}]\[${Color_Off}\]"
else
PS1+="\[${Green}\][${EXIT}]\[${Color_Off}\]"
fi
PS1+="\[${Purple}\]->\[${Color_Off}\] " # prompt
__makeTerminalTitle
}

View File

@ -6,28 +6,7 @@ let
in {
programs = {
bash = {
enable = true;
shellAliases = {
".." = "cd ..";
"..." = "cd ../..";
la = "ls -a";
ll = "ls -l";
lla = "ls -la";
rm = "rm --one-file-system --preserve-root";
};
initExtra = ''
case $TERM in
screen|xterm*|rxvt*)
shopt -s checkwinsize
;;
*)
export LS_OPTIONS=""
;;
esac
'';
};
bash = { enable = true; };
git = {
enable = true;