added null check to hm-cli
This commit is contained in:
parent
5edad8b957
commit
4b5426885c
1 changed files with 9 additions and 5 deletions
|
|
@ -23,9 +23,9 @@ pkgs.writeShellScriptBin "hm" ''
|
||||||
|
|
||||||
Environment Variables:
|
Environment Variables:
|
||||||
HM_PATH Override default flake path (~/.config/home-manager)
|
HM_PATH Override default flake path (~/.config/home-manager)
|
||||||
Currently set to "$(echo $HM_PATH)"
|
Currently set to "''${HM_PATH:-<not set>}"
|
||||||
HM_USER Override default user output ("$(whoami)@$(hostname)")
|
HM_USER Override default user output ("$(whoami)@$(hostname)")
|
||||||
Currently set to "$(echo $HM_USER)"
|
Currently set to "''${HM_USER:-<not set>}"
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,10 +58,14 @@ pkgs.writeShellScriptBin "hm" ''
|
||||||
"$HM" remove-generations "$@"
|
"$HM" remove-generations "$@"
|
||||||
;;
|
;;
|
||||||
rollback)
|
rollback)
|
||||||
"$HM" generations | \
|
PREV_GEN=$("$HM" generations | \
|
||||||
sed -n 's/^[[:space:]]*id \([0-9]\+\).*/\1/p' | \
|
sed -n 's/^[[:space:]]*id \([0-9]\+\).*/\1/p' | \
|
||||||
head -n 2 | tail -n 1 | \
|
head -n 2 | tail -n 1)
|
||||||
xargs -I {} "$HM" switch --flake "$FLAKE_PATH" --switch-generation {}
|
if [[ -z "$PREV_GEN" ]]; then
|
||||||
|
echo "Error: could not determine previous generation (possibly only one generation exists)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
"$HM" switch --flake "$FLAKE_PATH" --switch-generation "$PREV_GEN"
|
||||||
;;
|
;;
|
||||||
switch)
|
switch)
|
||||||
if [[ $# -ne 3 ]]; then
|
if [[ $# -ne 3 ]]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue