This commit is contained in:
Hadi
2024-08-18 23:29:08 +02:00
parent 246b5b6c8e
commit 7fab715859
14 changed files with 75 additions and 743 deletions

View File

@@ -1,30 +0,0 @@
#!/usr/bin/env bash
# This script is used to copy my own configuration to the `./hosts/guest` one, and changing some settings
[[ -d "./hosts" ]] || (
echo "Folder ./hosts not found"
exit 1
)
LAPTOP_CONFIG="./hosts/laptop"
GUEST_CONFIG="./hosts/guest"
# Remove the NVIDIA driver import
config=$(cat "$LAPTOP_CONFIG/configuration.nix")
config=$(echo "$config" | sed 's/..\/modules\/nvidia/# ..\/modules\/nvidia/')
config=$(echo "$config" | sed 's/..\/modules\/prime/# ..\/modules\/prime/')
echo "$config" >"$GUEST_CONFIG/configuration.nix"
variables=$(cat "$LAPTOP_CONFIG/variables.nix")
variables=$(echo "$variables" | sed 's/112569860+anotherhadi@users.noreply.github.com/your_email/')
variables=$(echo "$variables" | sed 's/hadi/your_username/')
variables=$(echo "$variables" | sed 's/Hadi/your_username/')
variables=$(echo "$variables" | sed 's/sops = true/sops = false/')
variables=$(echo "$variables" | sed 's/obsidian = true/obsidian = false/')
variables=$(echo "$variables" | sed 's/tailscale = true/tailscale = false/')
echo "$variables" >"$GUEST_CONFIG/variables.nix"
home=$(cat "$LAPTOP_CONFIG/home.nix")
home=$(echo "$home" | sed 's/\.\/secrets/# .\/secrets/')
echo "$home" >"$GUEST_CONFIG/home.nix"

View File

@@ -1,78 +0,0 @@
#!/usr/bin/env bash
# https://github.com/anotherhadi/nixy
# Installation script: Should be run on fresh nixos install.
printf "\n\e[0;92m- \e[0m\e[1;77mNixy's Installation Script\e[0;96m [anotherhadi/nixy]\e[0m"
# Check if we're on the good directory
[[ -f "./docs/scripts/install.sh" ]] || (
printf "\n\e[0;91mx \e[0m\e[1;77mNot in the project root directory\e[0m"
exit 1
)
DIR=$PWD
# Create a new configuration
read -rp $'\n\e[0;92m+\e[0m\e[1;77m Username: \e[0;96m' username
read -rp $'\n\e[0;92m+\e[0m\e[1;77m Hostname: \e[0;96m' hostname
HOST_DIR="./hosts/$hostname"
mkdir "$HOST_DIR"
nixos-generate-config --show-hardware-config >"$HOST_DIR/hardware-configuration.nix"
printf "\n\e[0;92m? \e[0m\e[1;77mInstall Nvidia drivers?\e[0;96m [y/N]\e[0m"
read -r yn
yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]')
if [[ $yn == "y" || $yn == "yes" ]]; then
nvidia=true
else
nvidia=false
fi
printf "\n\e[0;92m? \e[0m\e[1;77mInstall prime?\e[0;96m [y/N]\e[0m"
read -r yn
yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]')
if [[ $yn == "y" || $yn == "yes" ]]; then
prime=true
else
prime=false
fi
cp "$LAPTOP_CONFIG/configuration.nix" "$HOST_DIR/configuration.nix"
cp "$LAPTOP_CONFIG/variables.nix" "$HOST_DIR/variables.nix"
config=$(cat "$LAPTOP_CONFIG/configuration.nix")
if [[ $nvidia == false ]]; then
config=$(echo "$config" | sed 's/..\/shared\/nvidia/# ..\/shared\/nvidia/')
fi
if [[ $prime == false ]]; then
config=$(echo "$config" | sed 's/..\/shared\/prime/# ..\/shared\/prime/')
fi
echo "$config" >"$HOST_DIR/configuration.nix"
variables=$(cat "$LAPTOP_CONFIG/variables.nix")
variables=$(echo "$variables" | sed 's/112569860+anotherhadi@users.noreply.github.com/your_email/')
variables=$(echo "$variables" | sed "s/hadi/$username/")
variables=$(echo "$variables" | sed "s/nixy/$hostname/") # FIXME: Host name can be mixed with themes
variables=$(echo "$variables" | sed "s/Hadi/$username/")
variables=$(echo "$variables" | sed 's/sops = true/sops = false/')
variables=$(echo "$variables" | sed 's/obsidian = true/obsidian = false/')
variables=$(echo "$variables" | sed 's/tailscale = true/tailscale = false/')
echo "$variables" >"$HOST_DIR/variables.nix"
# Add it to the git index
git add .
printf "\n\e[0;92m+ \e[0m\e[1;77mHost added!\e[0m"
# REBUILD
printf "\n\e[0;92m? \e[0m\e[1;77mDo you want to rebuild?\e[0;96m [y/N]\e[0m"
read -r yn
yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]')
if [[ $yn == "y" || $yn == "yes" ]]; then
sudo nixos-rebuild switch --flake "$DIR"#"$hostname"
fi
printf "\n\e[0;92m✓ \e[0m\e[1;77mDone!\e[0m"