#!/usr/bin/env bash # Nomarchy Environment Update Script # 1. Runs the pre-flight state migration # 2. Applies user-level Home Manager changes set -e # Detect the repository location if [ -f "/etc/nixos/flake.nix" ]; then REPO_DIR="/etc/nixos" elif [ -f "/etc/nomarchy/flake.nix" ]; then REPO_DIR="/etc/nomarchy" else echo "Error: Nomarchy flake repository not found in /etc/nixos or /etc/nomarchy." exit 1 fi # Use the pre-flight migration script to ensure the state is synced before evaluation if command -v nomarchy-preflight-migration >/dev/null 2>&1; then nomarchy-preflight-migration fi # Apply changes via nixos-rebuild (since home-manager is integrated as a NixOS module) echo "Applying user-level changes from $REPO_DIR using nixos-rebuild..." sudo nixos-rebuild switch --flake "$REPO_DIR#default" --impure echo "Environment update complete."