mirror of
https://github.com/Ascyii/nixos.git
synced 2026-01-01 06:44:26 -05:00
Initial commit unclean
This commit is contained in:
46
install.sh
Executable file
46
install.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Script to link the configuration of a host to the current directory
|
||||
# to the root to make access easier
|
||||
#
|
||||
# This does not need to be used when flakes is enabled
|
||||
# Yes need for nvim integration of nixos
|
||||
|
||||
cd $HOME/configuration/nixos
|
||||
|
||||
directory="hosts"
|
||||
|
||||
# List all folder names in the specified directory
|
||||
echo "Known hosts:"
|
||||
folders=()
|
||||
counter=1
|
||||
for folder in "$directory"/*/; do
|
||||
if [ -d "$folder" ]; then
|
||||
folder_name=$(basename "$folder")
|
||||
folders+=("$folder_name")
|
||||
echo "$counter: $folder_name"
|
||||
((counter++))
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Please select a host (number):"
|
||||
read -p "> " folder_number
|
||||
|
||||
# Validate the selection
|
||||
if ! echo "$folder_number" | grep -Eq '^[1-9][0-9]*$'; then
|
||||
echo "Invalid selection: You must enter a positive integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
folder_index=$((folder_number - 1))
|
||||
if [ "$folder_index" -lt 0 ] || [ "$folder_index" -ge "${#folders[@]}" ]; then
|
||||
echo "Invalid selection: Number out of range."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
selected_folder="${folders[$folder_index]}" # Use the 0-based index
|
||||
selected_folder_path="$directory/$selected_folder"
|
||||
|
||||
ln -sf "$selected_folder_path/configuration.nix" "configuration.nix"
|
||||
echo "Switched to host configuration in the current directory."
|
||||
|
||||
Reference in New Issue
Block a user