mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
Add modules
This commit is contained in:
parent
5cc656fffc
commit
f40362898a
19 changed files with 1045 additions and 0 deletions
20
modules/lib-bash/activation-init.sh
Normal file
20
modules/lib-bash/activation-init.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
if [[ -v VERBOSE ]]; then
|
||||
export VERBOSE_ECHO=echo
|
||||
export VERBOSE_ARG="--verbose"
|
||||
else
|
||||
export VERBOSE_ECHO=true
|
||||
export VERBOSE_ARG=""
|
||||
fi
|
||||
|
||||
if [[ -v DRY_RUN ]] ; then
|
||||
echo "This is a dry run"
|
||||
export DRY_RUN_CMD=echo
|
||||
else
|
||||
$VERBOSE_ECHO "This is a live run"
|
||||
export DRY_RUN_CMD=""
|
||||
fi
|
||||
|
||||
if [[ -v VERBOSE ]]; then
|
||||
echo -n "Using Nix version: "
|
||||
nix --version
|
||||
fi
|
||||
37
modules/lib-bash/color-echo.sh
Normal file
37
modules/lib-bash/color-echo.sh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# The check for terminal output and color support is heavily inspired
|
||||
# by https://unix.stackexchange.com/a/10065.
|
||||
|
||||
function setupColors() {
|
||||
normalColor=""
|
||||
errorColor=""
|
||||
warnColor=""
|
||||
noteColor=""
|
||||
|
||||
# Check if stdout is a terminal.
|
||||
if [[ -t 1 ]]; then
|
||||
# See if it supports colors.
|
||||
local ncolors
|
||||
ncolors=$(tput colors)
|
||||
|
||||
if [[ -n "$ncolors" && "$ncolors" -ge 8 ]]; then
|
||||
normalColor="$(tput sgr0)"
|
||||
errorColor="$(tput bold)$(tput setaf 1)"
|
||||
warnColor="$(tput setaf 3)"
|
||||
noteColor="$(tput bold)$(tput setaf 6)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
setupColors
|
||||
|
||||
function errorEcho() {
|
||||
echo "${errorColor}$*${normalColor}"
|
||||
}
|
||||
|
||||
function warnEcho() {
|
||||
echo "${warnColor}$*${normalColor}"
|
||||
}
|
||||
|
||||
function noteEcho() {
|
||||
echo "${noteColor}$*${normalColor}"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue