mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
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
|
||||
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
|
||||
;;
|
||||
|
|
|
@ -29,18 +29,26 @@ setupVars
|
|||
|
||||
echo "Starting home manager activation"
|
||||
|
||||
if [[ $DRY_RUN ]] ; then
|
||||
echo "This is a dry run"
|
||||
export DRY_RUN_CMD=echo
|
||||
if [[ $VERBOSE ]]; then
|
||||
export VERBOSE_ECHO=echo
|
||||
export VERBOSE_ARG="--verbose"
|
||||
else
|
||||
echo "This is a live run"
|
||||
unset DRY_RUN_CMD
|
||||
export VERBOSE_ECHO=true
|
||||
unset VERBOSE_ARG
|
||||
fi
|
||||
|
||||
echo "Activation variables:"
|
||||
echo " oldGenNum=$oldGenNum"
|
||||
echo " newGenNum=$newGenNum"
|
||||
echo " oldGenPath=$oldGenPath"
|
||||
echo " newGenPath=$newGenPath"
|
||||
echo " newGenProfilePath=$newGenProfilePath"
|
||||
echo " newGenGcPath=$newGenGcPath"
|
||||
if [[ $DRY_RUN ]] ; then
|
||||
$VERBOSE_ECHO "This is a dry run"
|
||||
export DRY_RUN_CMD=echo
|
||||
else
|
||||
$VERBOSE_ECHO "This is a live run"
|
||||
unset DRY_RUN_CMD
|
||||
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
|
||||
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
|
||||
|
|
|
@ -119,7 +119,6 @@ in
|
|||
&& ! cmp --quiet \
|
||||
"$oldUserServicePath/$f" \
|
||||
"$newUserServicePath/$f" ; then
|
||||
echo "Adding '$f' to restart list";
|
||||
toRestart+=("$f")
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue