Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/bash/home-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,26 @@ function _iVerbose() {
# Runs the given command on live run, otherwise prints the command to standard
# output.
#
# If given the command line option `--quiet`, then the command's standard output
# is sent to `/dev/null` on a live run.
#
# If given the command line option `--silence`, then the command's standard and
# error output is sent to `/dev/null` on a live run.
#
# The `--silence` and `--quiet` flags are mutually exclusive.
function run() {
if [[ $1 == '--silence' ]]; then
if [[ $1 == '--quiet' ]]; then
local quiet=1
shift
elif [[ $1 == '--silence' ]]; then
local silence=1
shift
fi

if [[ -v DRY_RUN ]] ; then
echo "$@"
elif [[ -v quiet ]] ; then
"$@" > /dev/null
elif [[ -v silence ]] ; then
"$@" > /dev/null 2>&1
else
Expand Down
2 changes: 1 addition & 1 deletion modules/files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ in
run nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath"
fi

run --silence nix-store --realise "$newGenPath" --add-root "$newGenGcPath"
run --quiet nix-store --realise "$newGenPath" --add-root "$newGenGcPath" --indirect
if [[ -e "$legacyGenGcPath" ]]; then
run rm $VERBOSE_ARG "$legacyGenGcPath"
fi
Expand Down
6 changes: 6 additions & 0 deletions modules/home-environment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,17 @@ in
: Runs the given command on live run, otherwise prints the command to
standard output.

{command}`run --quiet {command}`
: Runs the given command on live run and sends its standard output to
{file}`/dev/null`, otherwise prints the command to standard output.

{command}`run --silence {command}`
: Runs the given command on live run and sends its standard and error
output to {file}`/dev/null`, otherwise prints the command to standard
output.

The `--quiet` and `--silence` flags are mutually exclusive.

A script block should also respect the {var}`VERBOSE` variable, and if
set print information on standard out that may be useful for debugging
any issue that may arise. The variable {var}`VERBOSE_ARG` is set to
Expand Down
2 changes: 1 addition & 1 deletion modules/lib-bash/activation-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function nixProfileRemove() {
nixProfileList "$1" | xargs -rt $DRY_RUN_CMD nix profile remove $VERBOSE_ARG
else
if nix-env -q | grep -q "^$1$"; then
run --silence nix-env -e "$1"
run --quiet nix-env -e "$1"
fi
fi
}
Expand Down