Make home-update-flake a script in scripts git

This commit is contained in:
Julian Mutter 2024-03-06 15:41:18 +01:00
parent 5d8219dba1
commit 84680a5793
2 changed files with 0 additions and 42 deletions

View File

@ -65,7 +65,6 @@ config, ... }: {
## My scripts
pkgs.frajul.deploy-to-pianopi
pkgs.frajul.edit-config
pkgs.frajul.home-update-flake
];
home.file = {

View File

@ -1,41 +0,0 @@
{
# 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
'';
}