#!/usr/bin/env bash # Bootstrap script for NixOS with Hyprland configuration # Run this on a fresh NixOS install to pull and apply your configuration set -e echo "================================================" echo "NixOS Hyprland Configuration Bootstrap" echo "================================================" echo "" # Configuration variables GIT_REPO="https://git.cribdev.com/crib/nixos-config.git" CONFIG_DIR="$HOME/.config/nixos" HOSTNAME=$(cribnix) # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${YELLOW}Step 1: Installing Git (if not already installed)${NC}" if ! command -v git &> /dev/null; then nix-shell -p git --run "echo 'Git temporarily available'" fi echo "" echo -e "${YELLOW}Step 2: Cloning configuration from ${GIT_REPO}${NC}" if [ -d "$CONFIG_DIR" ]; then echo -e "${RED}Configuration directory already exists at $CONFIG_DIR${NC}" read -p "Do you want to remove it and clone fresh? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -rf "$CONFIG_DIR" else echo "Aborting..." exit 1 fi fi mkdir -p "$HOME/.config" git clone "$GIT_REPO" "$CONFIG_DIR" echo "" echo -e "${YELLOW}Step 3: Copying hardware configuration${NC}" if [ -f /etc/nixos/hardware-configuration.nix ]; then cp /etc/nixos/hardware-configuration.nix "$CONFIG_DIR/hardware-configuration.nix" echo -e "${GREEN}Hardware configuration copied${NC}" else echo -e "${RED}Warning: /etc/nixos/hardware-configuration.nix not found!${NC}" echo "You'll need to generate it with: nixos-generate-config" fi echo "" echo -e "${YELLOW}Step 4: Updating hostname in configuration${NC}" echo "Current hostname: $HOSTNAME" read -p "Press enter to use this hostname, or type a new one: " NEW_HOSTNAME if [ ! -z "$NEW_HOSTNAME" ]; then HOSTNAME="$NEW_HOSTNAME" fi # Update hostname in flake.nix and configuration.nix sed -i "s/myhost/$HOSTNAME/g" "$CONFIG_DIR/flake.nix" sed -i "s/myhost/$HOSTNAME/g" "$CONFIG_DIR/configuration.nix" echo "" echo -e "${YELLOW}Step 5: Update username${NC}" read -p "Enter your username: " USERNAME sed -i "s/yourusername/$USERNAME/g" "$CONFIG_DIR/flake.nix" sed -i "s/yourusername/$USERNAME/g" "$CONFIG_DIR/configuration.nix" sed -i "s/yourusername/$USERNAME/g" "$CONFIG_DIR/home/home.nix" echo "" echo -e "${YELLOW}Step 6: Creating wallpapers directory${NC}" mkdir -p "$HOME/wallpapers" echo "Place your wallpaper at ~/wallpapers/default.jpg" echo "" echo -e "${GREEN}Configuration ready!${NC}" echo "" echo "Next steps:" echo "1. Review the configuration files in $CONFIG_DIR" echo "2. Edit configuration.nix to set your timezone and locale" echo "3. Edit home/home.nix to configure your git name/email" echo "4. Run: sudo nixos-rebuild switch --flake $CONFIG_DIR#$HOSTNAME" echo "" echo -e "${YELLOW}Would you like to build now? (y/N):${NC}" read -p "" -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "Building NixOS configuration..." sudo nixos-rebuild switch --flake "$CONFIG_DIR#$HOSTNAME" echo "" echo -e "${GREEN}Build complete! Please reboot your system.${NC}" else echo "You can build later with:" echo "sudo nixos-rebuild switch --flake $CONFIG_DIR#$HOSTNAME" fi