fix: copy all .nix files before rebuild

This commit is contained in:
spy4x 2024-03-06 22:47:41 +08:00
parent 3a66a152e7
commit e648053771

View File

@ -4,7 +4,7 @@
set -e
# Define the path to the system configuration file
NIXOS_CONFIG_PATH="/etc/nixos/configuration.nix"
NIXOS_CONFIG_PATH="/etc/nixos"
echo "Checking for sudo access..."
# Ensure the script is being run with superuser privileges
@ -12,11 +12,11 @@ sudo -v
echo "Backing up current configuration..."
# Create a backup of the current configuration file with a timestamp
sudo cp "${NIXOS_CONFIG_PATH}" "${NIXOS_CONFIG_PATH}-backup-$(date +%F-%H-%M-%S)"
sudo cp "${NIXOS_CONFIG_PATH}/configuration.nix" "${NIXOS_CONFIG_PATH}/configuration.nix-backup-$(date +%F-%H-%M-%S)"
echo "Copying new configuration..."
# Copy the local configuration.nix to the system configuration location
sudo cp ./configuration.nix "${NIXOS_CONFIG_PATH}"
sudo cp ./*.nix "${NIXOS_CONFIG_PATH}"
echo "Rebuilding NixOS configuration..."
# Rebuild the NixOS configuration and make the changes effective