diff options
| -rw-r--r-- | modules/home/zsh.nix | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/home/zsh.nix b/modules/home/zsh.nix index 73e4b93..3cef29d 100644 --- a/modules/home/zsh.nix +++ b/modules/home/zsh.nix @@ -119,7 +119,16 @@ in '' + (if pkgs.stdenv.isDarwin then '' alias tailscale='/Applications/Tailscale.app/Contents/MacOS/Tailscale' alias rebuild='sudo darwin-rebuild switch --flake ~/ghq/simenandre.no/dotfiles#${flakeAttr}' - alias update='nix flake update --flake ~/ghq/simenandre.no/dotfiles && sudo darwin-rebuild switch --flake ~/ghq/simenandre.no/dotfiles#${flakeAttr}' + function update() { + local flake=~/ghq/simenandre.no/dotfiles + nix flake update --flake "$flake" || return + sudo darwin-rebuild switch --flake "$flake#${flakeAttr}" || return + # Commit only after a switch succeeds, and only flake.lock, so unrelated + # work in the tree stays uncommitted. + git -C "$flake" diff --quiet HEAD -- flake.lock && return 0 + git -C "$flake" commit -m 'chore(flake): update inputs' -- flake.lock || return + git -C "$flake" push || echo 'update: lock committed but push failed' + } alias nix-gc='sudo nix-collect-garbage --delete-older-than 14d && nix-collect-garbage --delete-older-than 14d && nix store gc' '' else "") + '' |
