feat(core): professionalize state migration via Nix activation

- Move state migration logic from shell scripts to Home Manager activation
- Ensure migrations run automatically during rebuilds
- Delete obsolete bin/nomarchy-migrate and migrations/ directory
This commit is contained in:
Bernardo Magri
2026-04-04 10:35:02 +01:00
parent 6032ab1815
commit 4020ad5878
4 changed files with 97 additions and 150 deletions

View File

@@ -1,14 +0,0 @@
#!/bin/bash
# Creates a new Nomarchy migration named after the unix timestamp of the last commit.
# Only intended for Nomarchy developers.
cd ~/.local/share/nomarchy
migration_file="$HOME/.local/share/nomarchy/migrations/$(git log -1 --format=%cd --date=unix).sh"
touch $migration_file
if [[ $1 != "--no-edit" ]]; then
nvim $migration_file
fi
echo $migration_file

View File

@@ -1,29 +0,0 @@
#!/bin/bash
# Run all pending migrations to bring the system in line with the installed version.
# Where we store an empty file for each migration that has already been performed.
STATE_DIR="$HOME/.local/state/nomarchy/migrations"
mkdir -p "$STATE_DIR"
# Skipped migrations are tracked separately
mkdir -p "$STATE_DIR/skipped"
# Run any pending migrations
for file in ~/.local/share/nomarchy/migrations/*.sh; do
filename=$(basename "$file")
if [[ ! -f $STATE_DIR/$filename && ! -f $STATE_DIR/skipped/$filename ]]; then
echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m"
if bash $file; then
touch "$STATE_DIR/$filename"
else
if gum confirm "Migration ${filename%.sh} failed. Skip and continue?"; then
touch "$STATE_DIR/skipped/$filename"
else
exit 1
fi
fi
fi
done