{ # Snowfall Lib provides a customized `lib` instance with access to your flake's library # as well as the libraries available from your flake's inputs. lib, # You also have access to your flake's inputs. inputs, # All other arguments come from NixPkgs. You can use `pkgs` to pull packages or helpers # programmatically or you may add the named attributes as arguments here. pkgs, stdenv, ... }: pkgs.writeShellApplication { name = "home-update-flake"; runtimeInputs = with pkgs; [ ]; text = '' # Exit when errors occur set -e echo "Updating flake..." nix flake update ~/.dotfiles set +e git -C ~/.dotfiles diff --quiet flake.lock LOCK_FILE_CHANGED=$? set -e if [[ $LOCK_FILE_CHANGED == 1 ]]; then CURRENT_GENERATION=$(home-manager generations | head -n 1 | cut -d " " -f 5) echo "found current gen" MESSAGE="Update flake at home-manager generation $CURRENT_GENERATION" git -C ~/.dotfiles commit flake.lock -m "$MESSAGE" echo "Updated flake.lock file committed to git!" else echo "No updates available." fi ''; }