1
0
Fork 0
nixconf/nixcp.sh

24 lines
711 B
Bash
Executable file

#!/bin/bash
# Get the directory where the script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Define the target directory
TARGET_DIR="/etc/nixos"
# Check if the script is being run with sudo privileges (since /etc/nixos requires elevated permissions)
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run with sudo or as root."
exit 1
fi
# Copy all .nix files from the script's directory to the /etc/nixos directory
for file in "$SCRIPT_DIR"/*.nix; do
if [ -f "$file" ]; then
# Copy the file, replacing the existing one
cp -f "$file" "$TARGET_DIR/"
echo "Copied $file to $TARGET_DIR/"
fi
done
echo "All .nix files have been copied to $TARGET_DIR."