topgrade: Add script to update flake and continue on failed step
This commit is contained in:
parent
a565b20c30
commit
e5ed273561
@ -65,6 +65,7 @@ config, ... }: {
|
||||
## My scripts
|
||||
pkgs.frajul.deploy-to-pianopi
|
||||
pkgs.frajul.edit-config
|
||||
pkgs.frajul.home-update-flake
|
||||
];
|
||||
|
||||
home.file = {
|
||||
|
@ -31,6 +31,9 @@ in {
|
||||
misc.no_self_update = true;
|
||||
misc.pre_sudo = true; # Cache sudo password for 5 more minutes
|
||||
misc.assume_yes = true;
|
||||
misc.no_retry = true;
|
||||
|
||||
pre_commands."Update dotfiles flake" = "home-update-flake";
|
||||
|
||||
git = {
|
||||
# Additional git repositories to pull
|
||||
|
41
packages/home-update-flake/default.nix
Normal file
41
packages/home-update-flake/default.nix
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
# 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
|
||||
'';
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user