- 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
45 lines
1.6 KiB
Bash
Executable File
45 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 00-system-prep.sh
|
|
# Updates system and sets up Flathub.
|
|
# Relies on DISTRO and PACKAGE_MANAGER being set by the caller.
|
|
# Supports NixOS, Fedora (dnf), and Debian/Ubuntu (apt).
|
|
|
|
echo "--- Starting System Preparation ---"
|
|
|
|
if [ -z "$DISTRO" ] || [ -z "$PACKAGE_MANAGER" ]; then
|
|
echo "ERROR: DISTRO and PACKAGE_MANAGER must be set in the environment."
|
|
exit 1
|
|
fi
|
|
|
|
# ── NixOS path: system updates are declarative via flake ──
|
|
if [ "$DISTRO" == "nixos" ]; then
|
|
echo "NixOS detected: system updates are managed declaratively via flake.nix."
|
|
echo "Run 'nixos-rebuild switch --flake ~/dotfiles/nixos#nixos' to apply changes."
|
|
echo "Skipping imperative system update."
|
|
fi
|
|
|
|
# ── Traditional distro path ────────────────────────────────
|
|
if [ "$DISTRO" != "nixos" ]; then
|
|
echo "Updating system packages..."
|
|
if [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
|
sudo dnf update -y && sudo dnf upgrade -y
|
|
elif [ "$PACKAGE_MANAGER" == "apt" ]; then
|
|
sudo apt update && sudo apt upgrade -y
|
|
else
|
|
echo "WARNING: Unknown package manager '$PACKAGE_MANAGER'. Skipping system update."
|
|
fi
|
|
fi
|
|
|
|
# Setup Flatpak (works on NixOS too if enabled in flake.nix)
|
|
echo "Setting up Flathub repository..."
|
|
if command -v flatpak &> /dev/null; then
|
|
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
else
|
|
echo "WARNING: flatpak command not found. Skipping Flathub setup."
|
|
echo "Ensure Flatpak is installed via your package manager or flake.nix."
|
|
fi
|
|
|
|
echo "--- System Preparation Finished ---"
|
|
|