Add Ansible configuration and remove NixOS
All checks were successful
Nix Format Check / check-format (pull_request) Successful in 39s
All checks were successful
Nix Format Check / check-format (pull_request) Successful in 39s
This commit is contained in:
64
setup.sh
64
setup.sh
@ -301,7 +301,7 @@ install_nix() {
|
||||
fi
|
||||
|
||||
log_success "Nix has been installed. Please open a new shell and re-run the script."
|
||||
log_info "`~/dotfiles/setup.sh --continue` to continue setup."
|
||||
log_info "'~/dotfiles/setup.sh --continue' to continue setup."
|
||||
exit 0
|
||||
}
|
||||
|
||||
@ -335,8 +335,6 @@ setup_symlinks() {
|
||||
|
||||
# Verify symlinks
|
||||
confirm_symlink "$HOME/.config/home-manager" "Failed to set up home-manager symlink"
|
||||
confirm_symlink "/etc/nixos/configuration.nix" "Failed to set up nixos configuration symlink"
|
||||
|
||||
log_success "Symlinks set up successfully."
|
||||
}
|
||||
|
||||
@ -347,13 +345,23 @@ install_home_manager() {
|
||||
fi
|
||||
|
||||
log_info "Installing Home Manager..."
|
||||
if ! command -v nix-channel >/dev/null 2>&1; then
|
||||
nix-channel --add "https://github.com/nix-community/home-manager/archive/release-$NIXOS_RELEASE.tar.gz" home-manager || \
|
||||
die "Failed to add home-manager channel"
|
||||
else
|
||||
sudo nix-channel --add "https://github.com/nix-community/home-manager/archive/release-$NIXOS_RELEASE.tar.gz" home-manager || \
|
||||
die "Failed to add home-manager channel"
|
||||
fi
|
||||
|
||||
if ! command -v nix-channel >/dev/null 2>&1; then
|
||||
nix-channel --update || die "Failed to update channels"
|
||||
else
|
||||
sudo nix-channel --update || die "Failed to update channels"
|
||||
fi
|
||||
|
||||
sudo nix-channel --add "https://github.com/nix-community/home-manager/archive/release-$NIXOS_RELEASE.tar.gz" home-manager || \
|
||||
die "Failed to add home-manager channel"
|
||||
|
||||
sudo nix-channel --update || die "Failed to update channels"
|
||||
|
||||
sudo nix-shell '<home-manager>' -A install || die "Failed to install home-manager (sudo)"
|
||||
if command -v nix-shell >/dev/null 2>&1; then
|
||||
sudo nix-shell '<home-manager>' -A install || die "Failed to install home-manager (sudo)"
|
||||
fi
|
||||
nix-shell '<home-manager>' -A install || die "Failed to install home-manager"
|
||||
}
|
||||
|
||||
@ -365,15 +373,6 @@ prepare_hostname() {
|
||||
if [ -f "$hostname_file" ]; then
|
||||
hostname=$(cat "$hostname_file")
|
||||
log_success "Hostname already found in $hostname_file. Using $hostname."
|
||||
|
||||
if command -v nixos-version >/dev/null 2>&1; then
|
||||
if [ ! -f "$DOTFILES_DIR/config/nixos/hardware/$hostname.nix" ]; then
|
||||
die "No hardware configuration found for $hostname. Please create a hardware configuration for this machine."
|
||||
fi
|
||||
|
||||
log_success "Hardware configuration found for $hostname. Continuing setup..."
|
||||
fi
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
@ -389,19 +388,8 @@ prepare_hostname() {
|
||||
log_error "Invalid hostname. Please enter a valid hostname:"
|
||||
done
|
||||
|
||||
if [ ! command -v nixos-version >/dev/null 2>&1 ]; then
|
||||
log_info "Setting hostname to $hostname..."
|
||||
sudo hostnamectl set-hostname "$hostname" || die "Failed to set hostname"
|
||||
fi
|
||||
|
||||
if [ command -v nixos-version >/dev/null 2>&1 ]; then
|
||||
if [ ! -f "$DOTFILES_DIR/config/nixos/hardware/$hostname.nix" ]; then
|
||||
log_info "No hardware configuration found for $hostname."
|
||||
create_hardware_config "$hostname"
|
||||
else
|
||||
log_success "Hardware configuration found for $hostname. Continuing setup..."
|
||||
fi
|
||||
fi
|
||||
log_info "Setting hostname to $hostname..."
|
||||
sudo hostnamectl set-hostname "$hostname" || die "Failed to set hostname"
|
||||
|
||||
echo "$hostname" > "$hostname_file" || die "Failed to save hostname"
|
||||
log_success "Hostname set successfully."
|
||||
@ -422,11 +410,6 @@ warning_prompt() {
|
||||
}
|
||||
|
||||
check_selinux() {
|
||||
# Only on Non-NixOS based systems
|
||||
if command -v nixos-version >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check if getenforce is returning Enforcing
|
||||
if [ "$(getenforce)" = "Enforcing" ]; then
|
||||
log_warning "SELinux is enabled. Adjusting SELinux to permissive mode..."
|
||||
@ -480,16 +463,9 @@ main() {
|
||||
local hostname
|
||||
hostname=$(cat "$HOME/.hostname") || die "Failed to read hostname"
|
||||
|
||||
# Rebuild NixOS but only on NixOS systems
|
||||
if command -v nixos-version >/dev/null 2>&1; then
|
||||
cd "$DOTFILES_DIR/config/nixos" || die "Failed to change to nixos config directory"
|
||||
sudo nixos-rebuild switch --flake ".#$hostname" --impure || \
|
||||
die "Failed to rebuild NixOS"
|
||||
fi
|
||||
|
||||
# Rebuild Home Manager
|
||||
cd "$DOTFILES_DIR/config/home-manager" || die "Failed to change to home-manager config directory"
|
||||
NIXPKGS_ALLOW_UNFREE=1 home-manager switch --flake ".#$hostname" --impure || \
|
||||
NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_INSECURE=1 home-manager switch --extra-experimental-features flakes --extra-experimental-features nix-command --flake ".#$hostname" --impure -b backup || \
|
||||
die "Failed to rebuild Home Manager"
|
||||
|
||||
# Create setup marker
|
||||
|
Reference in New Issue
Block a user