feat: add NixOS support, Go, and Ruby on Rails; remove Rust

- Add nixos/ directory with declarative flake.nix and home.nix for NixOS
- Make all setup scripts NixOS-aware with proper detection and early exit
- Update bashrc, zshrc, and aliases with Go, Ruby on Rails, and Nix profile paths
- Replace Rust/Cargo references in shell configs with rbenv/Ruby on Rails
- Update README with NixOS quick start and full documentation
This commit is contained in:
Blake Ridgway
2026-07-30 20:13:13 -05:00
parent 5efb3dab48
commit 0b1e7b7f51
11 changed files with 776 additions and 50 deletions

View File

@@ -2,26 +2,40 @@
# Main setup script
# Calls other scripts to perform post-installation tasks.
# Supports NixOS (declarative via flake + home-manager) and
# traditional distros (Fedora, Ubuntu, Debian, Pop!_OS).
# --- Global Variables & Helper Functions ---
# SCRIPT_ROOT_DIR will be the directory where main-setup.sh is located
export SCRIPT_ROOT_DIR
SCRIPT_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
SCRIPT_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &>/dev/null && pwd)"
export SCRIPTS_DIR="${SCRIPT_ROOT_DIR}/scripts"
# Function to detect the Linux distribution
detect_linux_distro() {
# NixOS detection (must come first — no /etc/os-release on some older
# versions, but modern NixOS has it with ID=nixos)
if [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
echo "$ID"
elif [ -f /etc/lsb-release ]; then
return
fi
if [ -f /etc/NIXOS ]; then
echo "nixos"
return
fi
if [ -f /etc/lsb-release ]; then
# shellcheck disable=SC1091
. /etc/lsb-release
echo "$DISTRIBUTOR_ID"
elif [ -f /etc/debian_version ]; then
return
fi
if [ -f /etc/debian_version ]; then
echo "debian"
elif [ -f /etc/redhat-release ]; then
return
fi
if [ -f /etc/redhat-release ]; then
if grep -qi "fedora" /etc/redhat-release; then
echo "fedora"
elif grep -qi "centos" /etc/redhat-release; then
@@ -31,16 +45,16 @@ detect_linux_distro() {
else
echo "redhat"
fi
else
echo "unknown"
return
fi
echo "unknown"
}
# Function to prompt user for yes/no
prompt_yes_no() {
local prompt_text="$1"
local response
while true; do
read -r -p "$prompt_text (y/n): " response
case "$response" in
@@ -55,7 +69,7 @@ prompt_yes_no() {
run_script() {
local script_path="$1"
local script_name="$(basename "$script_path")"
if ! bash "$script_path"; then
echo "ERROR: $script_name failed."
return 1
@@ -69,6 +83,9 @@ DISTRO=$(detect_linux_distro)
export PACKAGE_MANAGER
case "$DISTRO" in
nixos)
PACKAGE_MANAGER="nix"
;;
fedora|rhel|centos)
PACKAGE_MANAGER="dnf"
;;
@@ -87,8 +104,65 @@ echo "Script Root Directory: $SCRIPT_ROOT_DIR"
echo "--------------------------------------------------"
echo ""
# --- Prompt for Setup Options ---
# --- NixOS special path: use nixos-rebuild + home-manager ---
if [ "$DISTRO" == "nixos" ]; then
echo "NixOS detected! Using declarative flake-based setup."
echo ""
echo "The recommended way to configure NixOS is through the flake"
echo "in the nixos/ directory. This script provides a guided"
echo "workflow for that approach."
echo ""
prompt_yes_no "Rebuild NixOS system from nixos/flake.nix (nixos-rebuild switch)?" && RUN_NIXOS_REBUILD=1 || RUN_NIXOS_REBUILD=0
prompt_yes_no "Apply home-manager config from nixos/home.nix (home-manager switch)?" && RUN_HOME_MANAGER=1 || RUN_HOME_MANAGER=0
prompt_yes_no "Install ad-hoc user packages via 'nix profile install'?" && RUN_NIX_PROFILE=1 || RUN_NIX_PROFILE=0
prompt_yes_no "Run config symlinks setup (04-config-symlinks.sh)?" && RUN_CONFIG_SYMLINKS=1 || RUN_CONFIG_SYMLINKS=0
echo ""
echo "--------------------------------------------------"
echo ""
if [ $RUN_NIXOS_REBUILD -eq 1 ]; then
echo "--- Running nixos-rebuild switch ---"
cd "$SCRIPT_ROOT_DIR/nixos" && sudo nixos-rebuild switch --flake .#nixos
echo "NixOS system rebuilt."
echo "--------------------------------------------------"
fi
if [ $RUN_HOME_MANAGER -eq 1 ]; then
echo "--- Running home-manager switch ---"
cd "$SCRIPT_ROOT_DIR/nixos" && home-manager switch --flake .#blake
echo "Home-manager configuration applied."
echo "--------------------------------------------------"
fi
if [ $RUN_NIX_PROFILE -eq 1 ]; then
echo "--- Installing ad-hoc packages via nix profile ---"
echo "Most packages are already in flake.nix / home.nix."
echo "Installing a few extras that are handy to have always available..."
nix profile install nixpkgs#btop nixpkgs#fastfetch nixpkgs#httpie
echo "Ad-hoc packages installed."
echo "--------------------------------------------------"
fi
if [ $RUN_CONFIG_SYMLINKS -eq 1 ]; then
echo "Executing 04-config-symlinks.sh..."
if ! run_script "${SCRIPTS_DIR}/04-config-symlinks.sh"; then
echo "WARNING: 04-config-symlinks.sh had issues."
fi
echo "--------------------------------------------------"
fi
echo ""
echo "#####################################"
echo "# NixOS setup finished! #"
echo "# Remember to review the flake and #"
echo "# home.nix for your exact needs. #"
echo "#####################################"
exit 0
fi
# --- Traditional distro path (Fedora / Ubuntu / Debian / Pop!_OS) ---
echo "Select which setup tasks to run:"
echo ""
@@ -96,6 +170,7 @@ prompt_yes_no "Run system preparation (00-system-prep.sh)?" && RUN_SYSTEM_PREP=1
prompt_yes_no "Run package installation (01-package-install.sh)?" && RUN_PKG_INSTALL=1 || RUN_PKG_INSTALL=0
prompt_yes_no "Run dev tools setup (02-dev-tools-setup.sh)?" && RUN_DEV_TOOLS=1 || RUN_DEV_TOOLS=0
# On Fedora, offer the .NET setup; on other distros it's skipped.
if [ "$DISTRO" == "fedora" ]; then
prompt_yes_no "Run Fedora .NET setup (03-fedora-dotnet-setup.sh)?" && RUN_DOTNET=1 || RUN_DOTNET=0
else
@@ -160,4 +235,4 @@ echo "#####################################"
echo "Please review the output for any manual steps or errors."
echo "You may need to restart your terminal or log out/log in for all changes to take effect."
exit 0
exit 0