removed nginx and altered caddy (build script changes too)

This commit is contained in:
2025-10-12 13:57:35 -05:00
parent d58262a043
commit 5168f5fc3e
24 changed files with 63 additions and 557 deletions

View File

@@ -1,26 +1,37 @@
#!/usr/bin/env bash
set -e
pushd ~/.nix
# nvim flake.nix
# alejandra . &>/dev/null
# git diff -U0 *.nix
set -euo pipefail
# your hostname (flake target)
hostname="$(hostname)"
old_gen=$(nixos-rebuild list-generations | grep current | awk '{print $1}')
gen=$((old_gen + 1))
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
nix_dir="$HOME/.nix"
logfile="$nix_dir/.nixos-switch-log"
# add generation comment to flake.nix
gen=$(nixos-rebuild list-generations | grep current)
pushd "$nix_dir" >/dev/null
# function to get current nixos generation
get_current_generation() {
nixos-rebuild list-generations
}
echo "diffs:"
git diff
git status --short
read -rp "commit message: " commit_msg
echo "rebuilding nixos with flake.nix..."
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/" flake.nix
sed -i "3s|^# generation:.*|# generation: $gen, timestamp: $timestamp|" flake.nix
else
# insert comment on line 3
sed -i "3i# generation: $gen" flake.nix
sed -i "3i# generation: $gen, timestamp: $timestamp" flake.nix
fi
echo "committing..."
git commit -m "$commit_msg"
echo "flake rebuild and commit fin"
git diff -U0 $(find . -name '*.nix')
echo "nixos rebuilding..."
#sudo nixos-rebuild switch --flake ~/.nix#snowbelle &>.nixos-switch-log || (
# cat .nixos-switch-log | grep --color error && false)
sudo nixos-rebuild switch --flake ~/.nix#snowbelle 2>&1 | tee .nixos-switch-log | grep --color=always -E "error|$" && true
git commit -am "$gen"
popd