finallyy?

This commit is contained in:
2025-10-12 20:11:00 -05:00
parent 3acd59d938
commit c1e56790c5
2 changed files with 18 additions and 17 deletions

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
echo "searching generations"
#echo "searching generations"
# your hostname (flake target)
hostname="$(hostname)"
old_gen=$(nixos-rebuild list-generations | grep current | awk '{print $1}')
gen=$((old_gen + 1))
echo "gen $old_gen --> gen $gen"
#old_gen=$(nixos-rebuild list-generations | grep current | awk '{print $1}')
#gen=$((old_gen + 1))
#echo "gen $old_gen --> gen $gen"
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
nix_dir="$HOME/.nix"
logfile="$nix_dir/.nixos-switch-log"
@@ -15,9 +15,9 @@ logfile="$nix_dir/.nixos-switch-log"
pushd "$nix_dir" >/dev/null
# function to get current nixos generation
get_current_generation() {
nixos-rebuild list-generations
}
#get_current_generation() {
# nixos-rebuild list-generations
#}
echo "diffs:"
git diff
@@ -30,13 +30,13 @@ if ! sudo nixos-rebuild switch --flake .#"$hostname" 2>&1 | tee "$logfile"; then
echo "rebuild failed; exited with no commit"
exit 1
fi
if sed -n '3p' flake.nix | grep -q '^# generation:'; then
# replace the comment on line 3
sed -i "3s|^# generation:.*|# generation: $gen, timestamp: $timestamp|" flake.nix
else
# insert comment on line 3
sed -i "3i# generation: $gen, timestamp: $timestamp" flake.nix
fi
#if sed -n '3p' flake.nix | grep -q '^# generation:'; then
# # replace the comment on line 3
# sed -i "3s|^# generation:.*|# generation: $gen, timestamp: $timestamp|" flake.nix
#else
# # insert comment on line 3
# sed -i "3i# generation: $gen, timestamp: $timestamp" flake.nix
#fi
echo "committing..."
git add $nix_dir
git commit -m "$commit_msg"