diff --git a/home-manager/home-manager b/home-manager/home-manager index 41089f872..39c5e1e27 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -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 ;; diff --git a/modules/activation-init.sh b/modules/activation-init.sh index 91ad79107..51c359686 100755 --- a/modules/activation-init.sh +++ b/modules/activation-init.sh @@ -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" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 7e3775cd3..07e9a1dfc 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -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 diff --git a/modules/systemd.nix b/modules/systemd.nix index c703ccb08..57c819e01 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -119,7 +119,6 @@ in && ! cmp --quiet \ "$oldUserServicePath/$f" \ "$newUserServicePath/$f" ; then - echo "Adding '$f' to restart list"; toRestart+=("$f") fi done