1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

Add configurable verbosity during activation

This commit is contained in:
Robert Helgesson 2017-01-21 12:27:50 +01:00
parent 64d6a66324
commit deaa6d3dd4
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
4 changed files with 32 additions and 20 deletions

View file

@ -76,6 +76,7 @@ function doHelp() {
echo "Options"
echo
echo " -f FILE The home configuration file. Default is ~/.nixpkgs/home.nix"
echo " -v Verbose output"
echo " -n Do a dry run, only prints what actions would be taken"
echo " -h Print this help"
echo
@ -89,11 +90,14 @@ function doHelp() {
CONFIG_FILE="$HOME/.nixpkgs/home.nix"
while getopts f:nh opt; do
while getopts f:vnh opt; do
case $opt in
f)
CONFIG_FILE=$OPTARG
;;
v)
export VERBOSE=1
;;
n)
export DRY_RUN=1
;;

View file

@ -29,18 +29,26 @@ setupVars
echo "Starting home manager activation"
if [[ $VERBOSE ]]; then
export VERBOSE_ECHO=echo
export VERBOSE_ARG="--verbose"
else
export VERBOSE_ECHO=true
unset VERBOSE_ARG
fi
if [[ $DRY_RUN ]] ; then
echo "This is a dry run"
$VERBOSE_ECHO "This is a dry run"
export DRY_RUN_CMD=echo
else
echo "This is a live run"
$VERBOSE_ECHO "This is a live run"
unset DRY_RUN_CMD
fi
echo "Activation variables:"
echo " oldGenNum=$oldGenNum"
echo " newGenNum=$newGenNum"
echo " oldGenPath=$oldGenPath"
echo " newGenPath=$newGenPath"
echo " newGenProfilePath=$newGenProfilePath"
echo " newGenGcPath=$newGenGcPath"
$VERBOSE_ECHO "Activation variables:"
$VERBOSE_ECHO " oldGenNum=$oldGenNum"
$VERBOSE_ECHO " newGenNum=$newGenNum"
$VERBOSE_ECHO " oldGenPath=$oldGenPath"
$VERBOSE_ECHO " newGenPath=$newGenPath"
$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath"
$VERBOSE_ECHO " newGenGcPath=$newGenGcPath"

View file

@ -228,8 +228,8 @@ in
for sourcePath in "$@" ; do
relativePath="$(realpath --relative-to "$newGenFiles" "$sourcePath")"
targetPath="$HOME/$relativePath"
$DRY_RUN_CMD mkdir -vp "$(dirname "$targetPath")"
$DRY_RUN_CMD ln -vsf "$sourcePath" "$targetPath"
$DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")"
$DRY_RUN_CMD ln -sf $VERBOSE_ARG "$sourcePath" "$targetPath"
done
'';
@ -245,8 +245,9 @@ in
echo " exists"
else
echo " gone (deleting)"
$DRY_RUN_CMD rm -v "$targetPath"
$DRY_RUN_CMD rmdir --ignore-fail-on-non-empty -v -p "$(dirname "$targetPath")"
$DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath"
$DRY_RUN_CMD rmdir --ignore-fail-on-non-empty \
$VERBOSE_ARG -p "$(dirname "$targetPath")"
fi
done
'';
@ -274,8 +275,8 @@ in
}
if [[ "$oldGenPath" != "$newGenPath" ]] ; then
$DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenProfilePath"
$DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenGcPath"
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath"
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath"
linkNewGen
cleanOldGen
else

View file

@ -119,7 +119,6 @@ in
&& ! cmp --quiet \
"$oldUserServicePath/$f" \
"$newUserServicePath/$f" ; then
echo "Adding '$f' to restart list";
toRestart+=("$f")
fi
done