diff options
Diffstat (limited to '')
-rw-r--r-- | home-manager/packages/scripts.nix | 4 | ||||
-rwxr-xr-x | home-manager/packages/scripts/small_functions/update.sh (renamed from home-manager/packages/scripts/small_functions/update) | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/home-manager/packages/scripts.nix b/home-manager/packages/scripts.nix index 19592905..4eed51dc 100644 --- a/home-manager/packages/scripts.nix +++ b/home-manager/packages/scripts.nix @@ -45,9 +45,9 @@ dependencies = builtins.attrValues {inherit (pkgs) ncmpc procps;}; # TODO add mymocp }; update-scr = write_script { - name = "update"; + name = "update.sh"; path = "small_functions"; - dependencies = builtins.attrValues {inherit (pkgs) git nixos-rebuild sudo openssh;}; + dependencies = builtins.attrValues {inherit (pkgs) git nixos-rebuild sudo openssh coreutils mktemp;}; }; backsnap-scr = write_script { diff --git a/home-manager/packages/scripts/small_functions/update b/home-manager/packages/scripts/small_functions/update.sh index 7b7b2e01..a8a838e8 100755 --- a/home-manager/packages/scripts/small_functions/update +++ b/home-manager/packages/scripts/small_functions/update.sh @@ -10,7 +10,8 @@ help() { EOF exit "$1"; } - +tmp=$(mktmp); +git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' > $tmp & BRANCH=""; while [ "$#" -gt 0 ];do @@ -36,6 +37,7 @@ done cd /etc/nixos || die "No /etc/nixos" -[ "$BRANCH" = "" ] || git switch "$BRANCH"; git pull --rebase +[ "$BRANCH" = "" ] || git switch "$BRANCH"; nixos-rebuild switch +git switch "$(cat $tmp)"; |