diff options
author | Soispha <soispha@vhack.eu> | 2023-04-15 14:39:17 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-05-09 19:30:40 +0200 |
commit | d59d2b8c8e487d97b44ecf8219433df06b336991 (patch) | |
tree | 612d502385b8568f82ab9fbe84dc9f332d69853c /home-manager | |
parent | Feat(flake): Add shellcheck to the development env (diff) | |
download | nixos-config-d59d2b8c8e487d97b44ecf8219433df06b336991.tar.gz nixos-config-d59d2b8c8e487d97b44ecf8219433df06b336991.zip |
Fix(hm/pkgs/scr/update): Reset branch after update
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)"; |