Add configurable verbosity during activation
This commit is contained in:
parent
64d6a66324
commit
deaa6d3dd4
4 changed files with 32 additions and 20 deletions
|
@ -76,6 +76,7 @@ function doHelp() {
|
||||||
echo "Options"
|
echo "Options"
|
||||||
echo
|
echo
|
||||||
echo " -f FILE The home configuration file. Default is ~/.nixpkgs/home.nix"
|
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 " -n Do a dry run, only prints what actions would be taken"
|
||||||
echo " -h Print this help"
|
echo " -h Print this help"
|
||||||
echo
|
echo
|
||||||
|
@ -89,11 +90,14 @@ function doHelp() {
|
||||||
|
|
||||||
CONFIG_FILE="$HOME/.nixpkgs/home.nix"
|
CONFIG_FILE="$HOME/.nixpkgs/home.nix"
|
||||||
|
|
||||||
while getopts f:nh opt; do
|
while getopts f:vnh opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
f)
|
f)
|
||||||
CONFIG_FILE=$OPTARG
|
CONFIG_FILE=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
v)
|
||||||
|
export VERBOSE=1
|
||||||
|
;;
|
||||||
n)
|
n)
|
||||||
export DRY_RUN=1
|
export DRY_RUN=1
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -29,18 +29,26 @@ setupVars
|
||||||
|
|
||||||
echo "Starting home manager activation"
|
echo "Starting home manager activation"
|
||||||
|
|
||||||
if [[ $DRY_RUN ]] ; then
|
if [[ $VERBOSE ]]; then
|
||||||
echo "This is a dry run"
|
export VERBOSE_ECHO=echo
|
||||||
export DRY_RUN_CMD=echo
|
export VERBOSE_ARG="--verbose"
|
||||||
else
|
else
|
||||||
echo "This is a live run"
|
export VERBOSE_ECHO=true
|
||||||
unset DRY_RUN_CMD
|
unset VERBOSE_ARG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Activation variables:"
|
if [[ $DRY_RUN ]] ; then
|
||||||
echo " oldGenNum=$oldGenNum"
|
$VERBOSE_ECHO "This is a dry run"
|
||||||
echo " newGenNum=$newGenNum"
|
export DRY_RUN_CMD=echo
|
||||||
echo " oldGenPath=$oldGenPath"
|
else
|
||||||
echo " newGenPath=$newGenPath"
|
$VERBOSE_ECHO "This is a live run"
|
||||||
echo " newGenProfilePath=$newGenProfilePath"
|
unset DRY_RUN_CMD
|
||||||
echo " newGenGcPath=$newGenGcPath"
|
fi
|
||||||
|
|
||||||
|
$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"
|
||||||
|
|
|
@ -228,8 +228,8 @@ in
|
||||||
for sourcePath in "$@" ; do
|
for sourcePath in "$@" ; do
|
||||||
relativePath="$(realpath --relative-to "$newGenFiles" "$sourcePath")"
|
relativePath="$(realpath --relative-to "$newGenFiles" "$sourcePath")"
|
||||||
targetPath="$HOME/$relativePath"
|
targetPath="$HOME/$relativePath"
|
||||||
$DRY_RUN_CMD mkdir -vp "$(dirname "$targetPath")"
|
$DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")"
|
||||||
$DRY_RUN_CMD ln -vsf "$sourcePath" "$targetPath"
|
$DRY_RUN_CMD ln -sf $VERBOSE_ARG "$sourcePath" "$targetPath"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -245,8 +245,9 @@ in
|
||||||
echo " exists"
|
echo " exists"
|
||||||
else
|
else
|
||||||
echo " gone (deleting)"
|
echo " gone (deleting)"
|
||||||
$DRY_RUN_CMD rm -v "$targetPath"
|
$DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath"
|
||||||
$DRY_RUN_CMD rmdir --ignore-fail-on-non-empty -v -p "$(dirname "$targetPath")"
|
$DRY_RUN_CMD rmdir --ignore-fail-on-non-empty \
|
||||||
|
$VERBOSE_ARG -p "$(dirname "$targetPath")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
@ -274,8 +275,8 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$oldGenPath" != "$newGenPath" ]] ; then
|
if [[ "$oldGenPath" != "$newGenPath" ]] ; then
|
||||||
$DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenProfilePath"
|
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath"
|
||||||
$DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenGcPath"
|
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath"
|
||||||
linkNewGen
|
linkNewGen
|
||||||
cleanOldGen
|
cleanOldGen
|
||||||
else
|
else
|
||||||
|
|
|
@ -119,7 +119,6 @@ in
|
||||||
&& ! cmp --quiet \
|
&& ! cmp --quiet \
|
||||||
"$oldUserServicePath/$f" \
|
"$oldUserServicePath/$f" \
|
||||||
"$newUserServicePath/$f" ; then
|
"$newUserServicePath/$f" ; then
|
||||||
echo "Adding '$f' to restart list";
|
|
||||||
toRestart+=("$f")
|
toRestart+=("$f")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue