From 7a39c2c9625633b515dc67a7a01fe53f69107e15 Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Wed, 22 Jan 2025 15:39:49 +0100 Subject: [PATCH] refactor: remove NixOS specific configuration and update installation messages for broader compatibility --- setup.sh | 76 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 73 deletions(-) diff --git a/setup.sh b/setup.sh index 9647bb6..10f33a4 100755 --- a/setup.sh +++ b/setup.sh @@ -81,65 +81,6 @@ validate_hostname() { return 0 } -update_nixos_flake() { - local hostname="$1" - local isServer="$2" - local isWorkstation="$3" - local flake_file="$DOTFILES_DIR/config/nixos/flake.nix" - - # Determine which common module to use - local common_module="./common/workstation.nix" - if [ "$isServer" = "true" ]; then - common_module="./common/server.nix" - fi - - # Create new configuration entry - local new_config=" \"$hostname\" = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - ./hardware/$hostname.nix - $common_module - ./configuration.nix - ]; - specialArgs = { - inherit pkgs-unstable; - isWorkstation = $isWorkstation; - isServer = $isServer; - }; - }; - " - - # Create temporary file - local temp_file=$(mktemp) - - # Find the line number where nixosConfigurations = { appears - local config_line=$(grep -n "nixosConfigurations = {" "$flake_file" | cut -d: -f1) - - if [ -z "$config_line" ]; then - rm "$temp_file" - die "Could not find nixosConfigurations in flake.nix" - fi - - # Copy the file up to the line after nixosConfigurations = { - head -n "$config_line" "$flake_file" > "$temp_file" - - # Add the new configuration - echo "$new_config" >> "$temp_file" - - # Add the rest of the file starting from the line after nixosConfigurations = { - tail -n +"$((config_line + 1))" "$flake_file" >> "$temp_file" - - # Validate the new file - if ! nix-shell -p nixfmt --run "nixfmt $temp_file"; then - rm "$temp_file" - return 1 - fi - - # Replace original file - mv "$temp_file" "$flake_file" || return 1 - log_success "NixOS Flake configuration added successfully." -} - update_home_manager_flake() { local hostname="$1" local isServer="$2" @@ -190,11 +131,11 @@ update_home_manager_flake() { install_nix() { if command -v nix-channel >/dev/null 2>&1; then - log_success "Detected NixOS, skipping Nix setup." + log_success "Detected Nix, skipping Nix setup." return 0 fi - log_info "NixOS not detected, installing Nix..." + log_info "Nix not detected, installing Nix..." if ! sh <(curl -L https://nixos.org/nix/install) --daemon; then die "Failed to install Nix" fi @@ -221,17 +162,6 @@ setup_symlinks() { ln -s "$DOTFILES_DIR/config/home-manager" "$HOME/.config/home-manager" || \ die "Failed to create home-manager symlink" - # Handle NixOS configuration with proper sudo permissions - if [ -d "/etc/nixos" ]; then - if [ -f "/etc/nixos/configuration.nix" ]; then - backup_file "/etc/nixos/configuration.nix" true - fi - - log_info "Linking /etc/nixos/configuration.nix to $DOTFILES_DIR/config/nixos/configuration.nix..." - sudo ln -s "$DOTFILES_DIR/config/nixos/configuration.nix" "/etc/nixos/configuration.nix" || \ - die "Failed to create nixos configuration symlink" - fi - # Verify symlinks confirm_symlink "$HOME/.config/home-manager" "Failed to set up home-manager symlink" log_success "Symlinks set up successfully." @@ -298,7 +228,7 @@ warning_prompt() { log_success "This script will set up your machine using Menno's Dotfiles repository.\n" log_error "Please ensure you have a backup of your data before proceeding." log_error "This script will modify system files and may require sudo permissions.\n" - log_info "This script works best on a fresh NixOS/Fedora installation." + log_info "This script works best on a fresh Fedora, Ubuntu or Arch Linux installation." log_info "Type 'continue' to continue or Ctrl+C to exit." read -r -p "> " continue < /dev/tty if [ "$continue" != "continue" ]; then