From 7c3e313cfec6c67b8ea15afe92d18896393eec59 Mon Sep 17 00:00:00 2001 From: "Simen A. W. Olsen" Date: Sat, 26 Sep 2026 22:12:36 +0200 Subject: feat(home): commit and push flake.lock from update --- modules/home/zsh.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 "") + '' -- cgit v1.3.1