diff options
author | Soispha <soispha@vhack.eu> | 2023-04-16 08:05:25 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-05-09 19:30:48 +0200 |
commit | 7fc0ece8c257e4f3a8db0445e46d35ff3b0560f0 (patch) | |
tree | dbe38ca4faaaa070cd9cdb8f4ea5451883f06c98 /home-manager/packages/scripts/small_functions/update | |
parent | Fix(hm/conf/mbsync): Hide .mbsyncrc config file (diff) | |
download | nixos-config-7fc0ece8c257e4f3a8db0445e46d35ff3b0560f0.tar.gz nixos-config-7fc0ece8c257e4f3a8db0445e46d35ff3b0560f0.zip |
Feat(hm/pkgs/scr/update): Add a cleaner cli interface
Diffstat (limited to '')
-rwxr-xr-x | home-manager/packages/scripts/small_functions/update | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/home-manager/packages/scripts/small_functions/update b/home-manager/packages/scripts/small_functions/update index 23408327..cbe994c6 100755 --- a/home-manager/packages/scripts/small_functions/update +++ b/home-manager/packages/scripts/small_functions/update @@ -5,14 +5,14 @@ help() { cat << EOF - This is an Nixos flake update manager. +This is a Nixos flake update manager. - Usage: - "$name" [--branch <branchname>] [--help] +Usage: + $name [--branch <branchname>] [--help] - Options: - --branch | -b [branchname] select a branch to update from. - --help | -h output this help. +Options: + --branch | -b [branchname] select a branch to update from. + --help | -h output this help. EOF exit "$1"; } @@ -43,13 +43,20 @@ done cd /etc/nixos || die "No /etc/nixos"; -git pull --rebase > /dev/null; -if [ "$BRANCH" = "" ];then - git switch "$BRANCH" > /dev/null; - git pull --rebase; +msg "Starting system update..."; +git remote update origin --prune > /dev/null 2>&1; +if ! [ "$BRANCH" = "" ];then + git switch "$BRANCH" > /dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'"; fi +msg2 "Updating git repository..."; +git pull --rebase; + git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' > $tmp & + +msg2 "Updating system..."; nixos-rebuild switch; -git switch "$(cat $tmp)" > /dev/null; + +git switch "$(cat $tmp)" > /dev/null 2>&1 && msg2 "Switched to branch '$(cat $tmp)'"; +msg "Finished Update!"; # vim: ft=sh |