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

@@ -1,16 +1,39 @@
# Fresh Install # Fresh Install
This is a collection of scripts and dotfiles I use when setting up a fresh Linux installation. This is a collection of scripts and dotfiles I use when setting up a fresh Linux installation.
Now compatible with **NixOS** (declarative via flakes + home-manager), as well as traditional
distributions like Fedora, Ubuntu, Debian, and Pop!_OS.
## Quick Start ## Quick Start
### Traditional Distros (Fedora / Ubuntu / Debian / Pop!_OS)
Run the main setup script to install software, configure development tools, and symlink dotfiles: Run the main setup script to install software, configure development tools, and symlink dotfiles:
```bash ```bash
./main-setup.sh ./main-setup.sh
``` ```
The script will automatically detect your Linux distribution (Fedora, Ubuntu, Debian, etc.) and use the appropriate package manager. The script will automatically detect your Linux distribution and use the appropriate package manager.
### NixOS
On NixOS, packages and configuration are managed **declaratively** using the flake in the `nixos/` directory.
Run the main script for a guided workflow:
```bash
./main-setup.sh
```
Or apply the flake directly:
```bash
# Rebuild system configuration
sudo nixos-rebuild switch --flake ~/dotfiles/nixos#nixos
# Apply user-level configuration
home-manager switch --flake ~/dotfiles/nixos#blake
```
## What Gets Installed ## What Gets Installed
@@ -27,8 +50,10 @@ The script will automatically detect your Linux distribution (Fedora, Ubuntu, De
- **Neovim** (latest version from GitHub) - **Neovim** (latest version from GitHub)
- **Hack Nerd Font** for terminal - **Hack Nerd Font** for terminal
- **Oh My Zsh** shell framework - **Oh My Zsh** shell framework
- **Starship** prompt - **Oh My Posh** prompt
- **Rust** toolchain via rustup - **Go** (Golang) with `gopls` language server and `delve` debugger
- **Ruby on Rails** — Ruby via rbenv, Bundler, Rails gem, Node.js
- **Python** development tools (pip, virtualenv, pynvim)
### Fedora-Specific (.NET Development) ### Fedora-Specific (.NET Development)
On Fedora systems, additional packages are installed: On Fedora systems, additional packages are installed:
@@ -37,13 +62,16 @@ On Fedora systems, additional packages are installed:
- **PostgreSQL** server and tools - **PostgreSQL** server and tools
- **Docker** (moby-engine) with Docker Compose - **Docker** (moby-engine) with Docker Compose
### Flatpak Applications ### Flatpak Applications (Traditional Distros Only)
- Bitwarden - Bitwarden
- Discord
- Flatseal - Flatseal
- Steam - Podman Desktop
- ProtonUp-Qt - ProtonUp-Qt
- Rider - Signal
- Veloren Airshipper - Steam
- Teams for Linux
- Thunderbird
- Visual Studio Code - Visual Studio Code
- VLC Media Player - VLC Media Player
@@ -51,10 +79,11 @@ On Fedora systems, additional packages are installed:
The setup is broken down into focused scripts: The setup is broken down into focused scripts:
- `00-system-prep.sh` - System updates and Flathub setup - `00-system-prep.sh` - System updates and Flathub setup (NixOS-aware)
- `01-package-install.sh` - Core packages and Flatpak apps - `01-package-install.sh` - Core packages and Flatpak apps (NixOS-aware)
- `02-dev-tools-setup.sh` - Development tools (Neovim, Go, Rust, Helm, kubectx, stern, dive, trivy, AWS CLI) - `02-dev-tools-setup.sh` - Development tools: Neovim, Hack Nerd Font, Go, Ruby on Rails,
- `03-fedora-dotnet-setup.sh` - Fedora-specific .NET environment Oh My Posh, Helm, kubectx, stern, dive, trivy, AWS CLI (NixOS-aware)
- `03-fedora-dotnet-setup.sh` - Fedora-specific .NET environment (skipped on NixOS)
- `04-config-symlinks.sh` - Dotfile symlinking - `04-config-symlinks.sh` - Dotfile symlinking
You can run individual scripts if you only need specific components. You can run individual scripts if you only need specific components.
@@ -112,10 +141,31 @@ After running the setup, remember to:
## Supported Distributions ## Supported Distributions
- **NixOS** — Declarative via `nixos/flake.nix` + `nixos/home.nix`
- **Fedora** (with full .NET development environment) - **Fedora** (with full .NET development environment)
- **Ubuntu/Debian** (core packages and development tools) - **Ubuntu/Debian** (core packages and development tools)
- **Pop!_OS** (core packages and development tools) - **Pop!_OS** (core packages and development tools)
## NixOS Setup (nixos/)
The `nixos/` directory contains a declarative flake-based configuration:
### Files
- **`nixos/flake.nix`** — NixOS system configuration:
- System packages (Go, Ruby, Python, Kubernetes tools, networking tools)
- Docker, Flatpak, and virt-manager services
- Zsh as default shell
- Hack & FiraCode Nerd Fonts
- Neovim as default editor
- **`nixos/home.nix`** — Home-manager user configuration:
- User packages (Go tooling, Ruby on Rails, shell tools, cloud tools)
- Zsh aliases and environment (Go, Ruby/Rails, Kubernetes, Docker, AWS, Terraform)
- Git configuration with template and includes
- Dotfile symlinks (bashrc, zshrc, aliases, gitconfig, gitignore)
- Oh My Posh theme and Nushell config
## Customization ## Customization
Feel free to fork this repository and modify the scripts/dotfiles to suit your needs. The modular structure makes it easy to add, remove, or modify specific components. Feel free to fork this repository and modify the scripts/dotfiles to suit your needs. The modular structure makes it easy to add, remove, or modify specific components.

View File

@@ -34,6 +34,25 @@ alias py3='python3'
alias python='python3' alias python='python3'
alias pip='pip3' alias pip='pip3'
# ── Go ──────────────────────────────────────────────────
alias gorun='go run'
alias gobuild='go build'
alias gotest='go test ./...'
alias gotidy='go mod tidy'
alias gofmt='go fmt ./...'
# ── Ruby on Rails ──────────────────────────────────────
alias be='bundle exec'
alias bi='bundle install'
alias bu='bundle update'
alias rdm='rails db:migrate'
alias rdr='rails db:rollback'
alias rds='rails db:seed'
alias rrg='rails generate'
alias rrc='rails console'
alias rrs='rails server'
alias rroutes='rails routes'
# Pretty print the path # Pretty print the path
alias path='echo $PATH | tr -s ":" "\n"' alias path='echo $PATH | tr -s ":" "\n"'

View File

@@ -24,7 +24,7 @@ alias nah="git reset --hard; git clean -df;"
alias grr="git remote remove origin" alias grr="git remote remove origin"
alias gra="git remote add origin " alias gra="git remote add origin "
# Python # ── Python ──────────────────────────────────────────────
alias initvenv='python3 -m venv venv' alias initvenv='python3 -m venv venv'
alias startvenv='source venv/bin/activate' alias startvenv='source venv/bin/activate'
alias stopvenv='deactivate' alias stopvenv='deactivate'
@@ -34,6 +34,25 @@ alias py3='python3'
alias python='python3' alias python='python3'
alias pip='pip3' alias pip='pip3'
# ── Go ──────────────────────────────────────────────────
alias gorun='go run'
alias gobuild='go build'
alias gotest='go test ./...'
alias gotidy='go mod tidy'
alias gofmt='go fmt ./...'
# ── Ruby on Rails ──────────────────────────────────────
alias be='bundle exec'
alias bi='bundle install'
alias bu='bundle update'
alias rdm='rails db:migrate'
alias rdr='rails db:rollback'
alias rds='rails db:seed'
alias rrg='rails generate'
alias rrc='rails console'
alias rrs='rails server'
alias rroutes='rails routes'
# Pretty print the path # Pretty print the path
alias path='echo $PATH | tr -s ":" "\n"' alias path='echo $PATH | tr -s ":" "\n"'

15
bashrc
View File

@@ -10,6 +10,11 @@ DEFAULT_USER="$USER"
# ── Editor ───────────────────────────────────────────── # ── Editor ─────────────────────────────────────────────
export EDITOR='nvim' export EDITOR='nvim'
# ── Nix profile ────────────────────────────────────────
if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
fi
# ── PATH additions ───────────────────────────────────── # ── PATH additions ─────────────────────────────────────
export GOPATH="$HOME/go" export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin:/usr/local/go/bin" export PATH="$PATH:$GOPATH/bin:/usr/local/go/bin"
@@ -17,14 +22,18 @@ export PATH="$PATH:$HOME/.local/bin"
export PATH="$PATH:$HOME/.pulumi/bin" export PATH="$PATH:$HOME/.pulumi/bin"
export CPLUS_INCLUDE_PATH=/usr/local/include export CPLUS_INCLUDE_PATH=/usr/local/include
# ── Go ──────────────────────────────────────────────────
# Go is available via Nix profile, home-manager, or /usr/local/go
# ── Ruby on Rails (rbenv) ──────────────────────────────
export PATH="$PATH:$HOME/.rbenv/bin"
eval "$(rbenv init - bash 2>/dev/null || true)"
# ── NVM ──────────────────────────────────────────────── # ── NVM ────────────────────────────────────────────────
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
# ── Rust/Cargo ─────────────────────────────────────────
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
# ── SSH agent ────────────────────────────────────────── # ── SSH agent ──────────────────────────────────────────
if [ -z "$SSH_AGENT_PID" ] || ! kill -0 "$SSH_AGENT_PID" 2>/dev/null; then if [ -z "$SSH_AGENT_PID" ] || ! kill -0 "$SSH_AGENT_PID" 2>/dev/null; then
eval "$(ssh-agent -s)" eval "$(ssh-agent -s)"

View File

@@ -2,26 +2,40 @@
# Main setup script # Main setup script
# Calls other scripts to perform post-installation tasks. # 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 --- # --- Global Variables & Helper Functions ---
# SCRIPT_ROOT_DIR will be the directory where main-setup.sh is located # SCRIPT_ROOT_DIR will be the directory where main-setup.sh is located
export SCRIPT_ROOT_DIR 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" export SCRIPTS_DIR="${SCRIPT_ROOT_DIR}/scripts"
# Function to detect the Linux distribution # Function to detect the Linux distribution
detect_linux_distro() { 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 if [ -f /etc/os-release ]; then
# shellcheck disable=SC1091 # shellcheck disable=SC1091
. /etc/os-release . /etc/os-release
echo "$ID" 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 # shellcheck disable=SC1091
. /etc/lsb-release . /etc/lsb-release
echo "$DISTRIBUTOR_ID" echo "$DISTRIBUTOR_ID"
elif [ -f /etc/debian_version ]; then return
fi
if [ -f /etc/debian_version ]; then
echo "debian" echo "debian"
elif [ -f /etc/redhat-release ]; then return
fi
if [ -f /etc/redhat-release ]; then
if grep -qi "fedora" /etc/redhat-release; then if grep -qi "fedora" /etc/redhat-release; then
echo "fedora" echo "fedora"
elif grep -qi "centos" /etc/redhat-release; then elif grep -qi "centos" /etc/redhat-release; then
@@ -31,9 +45,9 @@ detect_linux_distro() {
else else
echo "redhat" echo "redhat"
fi fi
else return
echo "unknown"
fi fi
echo "unknown"
} }
# Function to prompt user for yes/no # Function to prompt user for yes/no
@@ -69,6 +83,9 @@ DISTRO=$(detect_linux_distro)
export PACKAGE_MANAGER export PACKAGE_MANAGER
case "$DISTRO" in case "$DISTRO" in
nixos)
PACKAGE_MANAGER="nix"
;;
fedora|rhel|centos) fedora|rhel|centos)
PACKAGE_MANAGER="dnf" PACKAGE_MANAGER="dnf"
;; ;;
@@ -87,8 +104,65 @@ echo "Script Root Directory: $SCRIPT_ROOT_DIR"
echo "--------------------------------------------------" echo "--------------------------------------------------"
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 "Select which setup tasks to run:"
echo "" 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 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 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 if [ "$DISTRO" == "fedora" ]; then
prompt_yes_no "Run Fedora .NET setup (03-fedora-dotnet-setup.sh)?" && RUN_DOTNET=1 || RUN_DOTNET=0 prompt_yes_no "Run Fedora .NET setup (03-fedora-dotnet-setup.sh)?" && RUN_DOTNET=1 || RUN_DOTNET=0
else else

167
nixos/flake.nix Normal file
View File

@@ -0,0 +1,167 @@
{
description = "Blake's NixOS configuration with dev tooling";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in {
# ── System-level configuration ──────────────────────────
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules = [
({ pkgs, ... }: {
# ---- Core system ----
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos";
networking.networkmanager.enable = true;
time.timeZone = "America/Chicago";
i18n.defaultLocale = "en_US.UTF-8";
# ── Users ──────────────────────────────────────────
users.users.blake = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "docker" "libvirtd" ];
shell = pkgs.zsh;
};
# ── System packages ────────────────────────────────
environment.systemPackages = with pkgs; [
# Shell & terminal
zsh
zsh-completions
tmux
oh-my-posh
nushell
eza
bat
fzf
zoxide
ripgrep
fd
jq
tldr
unzip
wget
curl
# Development - Go
go
gopls
delve
# Development - Ruby on Rails
ruby
bundler
nodejs
yarn
rbenv
# Development - Python
python3
python3Packages.pip
python3Packages.virtualenv
# Cloud / DevOps
kubectl
k9s
minikube
terraform
helm
kubectx
stern
dive
trivy
ansible
awscli2
direnv
# Networking
nmap
mtr
tcpdump
socat
whois
iperf3
traceroute
bind
# System
btop
fastfetch
virt-manager
flatpak
docker
docker-compose
# HTTP
httpie
# Git
git
gh
# Neovim
neovim
];
# ── Flatpak ────────────────────────────────────────
services.flatpak.enable = true;
# ── Docker ─────────────────────────────────────────
virtualisation.docker.enable = true;
# ── Virtualisation (virt-manager) ──────────────────
virtualisation.libvirtd.enable = true;
# ── Fonts ──────────────────────────────────────────
fonts.packages = with pkgs; [
nerd-fonts.hack
nerd-fonts.fira-code
];
# ── Programs ───────────────────────────────────────
programs.fish.enable = true; # some scripts may need /bin/fish
programs.zsh.enable = true;
programs.direnv.enable = true;
# ── Nix settings ───────────────────────────────────
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# ── Security ───────────────────────────────────────
services.openssh.enable = true;
# ── Neovim default editor ──────────────────────────
environment.variables.EDITOR = "nvim";
system.stateVersion = "24.11";
})
];
};
# ── Home-manager user configuration ────────────────────
homeConfigurations.blake = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
./home.nix
];
};
};
}

267
nixos/home.nix Normal file
View File

@@ -0,0 +1,267 @@
{ config, pkgs, ... }:
{
# ── Home-manager: user-level packages & config ──────────
home.username = "blake";
home.homeDirectory = "/home/blake";
home.stateVersion = "24.11";
# ── User packages (installed via home-manager) ──────────
home.packages = with pkgs; [
# Development - Go tooling
go
gopls
delve
golangci-lint
# Development - Ruby on Rails
ruby
bundler
nodejs
yarn
rbenv
rubyPackages.rails
# Development - Python
python3
python3Packages.pip
python3Packages.virtualenv
python3Packages.pynvim
# Shell tools
oh-my-posh
eza
bat
fzf
ripgrep
fd
jq
zoxide
tldr
unzip
wget
curl
# Cloud / DevOps
kubectl
k9s
terraform
helm
kubectx
stern
dive
trivy
ansible
awscli2
direnv
# Networking
nmap
mtr
tcpdump
socat
whois
iperf3
traceroute
# System
btop
fastfetch
httpie
gh
git
tmux
# Neovim
neovim
];
# ── Git configuration ────────────────────────────────────
programs.git = {
enable = true;
userName = "Blake Ridgway";
userEmail = "blake@blakeridgway.com";
signing = {
# signByDefault = true;
# key = "...";
};
extraConfig = {
init.defaultBranch = "main";
core.editor = "nvim";
pull.rebase = true;
commit.template = "~/dotfiles/commit-conventions.txt";
};
includes = [
{ path = "~/dotfiles/.gitconfig-advancedmetrics"; condition = "gitdir:~/dev/AdvancedMetrics/"; }
];
};
# ── Shell: Zsh ───────────────────────────────────────────
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
# Unix
ll = "ls -la";
ln = "ln -v";
mkdir = "mkdir -p";
e = "nvim";
v = "nvim";
# System
cpu = "btop";
mem = "btop";
# Git
ga = "git add";
gaa = "git add .";
gc = "git commit";
gp = "git push -u origin \"$(git symbolic-ref --short HEAD)\"";
gs = "git status";
nah = "git reset --hard; git clean -df;";
grr = "git remote remove origin";
gra = "git remote add origin";
# Python
initvenv = "python3 -m venv venv";
startvenv = "source venv/bin/activate";
stopvenv = "deactivate";
pyinstall = "python3 -m pip install -r requirements.txt";
py = "python3";
py3 = "python3";
python = "python3";
pip = "pip3";
# Go
gorun = "go run";
gobuild = "go build";
gotest = "go test ./...";
gotidy = "go mod tidy";
gofmt = "go fmt ./...";
# Ruby on Rails
rails = "rails";
rake = "rake";
bundle = "bundle";
be = "bundle exec";
bi = "bundle install";
bu = "bundle update";
rdm = "rails db:migrate";
rdr = "rails db:rollback";
rds = "rails db:seed";
rrg = "rails generate";
rrc = "rails console";
rrs = "rails server";
rroutes = "rails routes";
# Kubernetes
k = "kubectl";
kg = "kubectl get";
kgp = "kubectl get pods";
kgs = "kubectl get svc";
kgd = "kubectl get deployments";
kgn = "kubectl get nodes";
kd = "kubectl describe";
kl = "kubectl logs";
klf = "kubectl logs -f";
kx = "kubectx";
kn = "kubens";
# Terraform
tf = "terraform";
tfi = "terraform init";
tfa = "terraform apply";
tfp = "terraform plan";
tfd = "terraform destroy";
tff = "terraform fmt -recursive";
tfv = "terraform validate";
tfo = "terraform output";
# AWS
awsl = "aws ec2 describe-instances --query \"Reservations[*].Instances[*].[InstanceId,State.Name,Tags[?Key=='Name'].Value|[0]]\" --output table";
# Docker
d = "docker";
dc = "docker compose";
dcu = "docker compose up -d";
dcd = "docker compose down";
dps = "docker ps --format \"table {{.ID}}\\t{{.Names}}\\t{{.Status}}\\t{{.Ports}}\"";
# Networking
ports = "ss -tlnp";
myip = "curl -4 icanhazip.com";
listening = "ss -tlnp";
# Config
vimrc = "nvim ~/.config/nvim/init.lua";
ealias = "nvim ~/dotfiles/aliases.zsh";
zshrc = "nvim ~/.zshrc";
bashrc = "nvim ~/.bashrc";
path = "echo $PATH | tr -s ':' '\\n'";
};
initExtra = ''
# Nix profile paths
if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
fi
# Go
export GOPATH="$HOME/go"
export PATH="$PATH:/usr/local/go/bin:$GOPATH/bin"
# Ruby on Rails (rbenv)
export PATH="$PATH:$HOME/.rbenv/bin"
eval "$(rbenv init - zsh 2>/dev/null || true)"
# Local binaries
export PATH="$PATH:$HOME/.local/bin:$HOME/bin"
# Editor
export EDITOR="nvim"
# SSH agent
if [ -z "$SSH_AGENT_PID" ]; then
eval "$(ssh-agent -s)" >/dev/null 2>&1
ssh-add -A 2>/dev/null || true
fi
# Key timeout
export KEYTIMEOUT=1
# Oh My Posh prompt
if command -v oh-my-posh &>/dev/null; then
eval "$(oh-my-posh init zsh --config ~/.config/oh-my-posh/theme.omp.json)"
fi
'';
};
# ── Neovim config (managed separately via dotfiles) ──────
# The nvim config lives in ~/dotfiles/nvim/ and is symlinked
# by the dotfiles setup script (04-config-symlinks.sh).
# ── Starship / Oh My Posh theme symlink ──────────────────
home.file.".config/oh-my-posh/theme.omp.json".source =
../terminal/posh-theme.omp.json;
# ── Nushell config symlink ───────────────────────────────
home.file.".config/nushell".source = ../terminal/nushell;
# ── Dotfile symlinks ─────────────────────────────────────
home.file.".bashrc".source = ../bashrc;
home.file.".zshrc".source = ../zshrc;
home.file.".aliases.bash".source = ../aliases.bash;
home.file.".aliases.zsh".source = ../aliases.zsh;
home.file.".gitconfig".source = ../gitconfig;
home.file.".gitignore".source = ../gitignore;
home.file.".agignore".source = ../agignore;
home.file.".commit-conventions.txt".source = ../commit-conventions.txt;
# Let home-manager manage itself
programs.home-manager.enable = true;
}

View File

@@ -3,6 +3,7 @@
# 00-system-prep.sh # 00-system-prep.sh
# Updates system and sets up Flathub. # Updates system and sets up Flathub.
# Relies on DISTRO and PACKAGE_MANAGER being set by the caller. # Relies on DISTRO and PACKAGE_MANAGER being set by the caller.
# Supports NixOS, Fedora (dnf), and Debian/Ubuntu (apt).
echo "--- Starting System Preparation ---" echo "--- Starting System Preparation ---"
@@ -11,23 +12,32 @@ if [ -z "$DISTRO" ] || [ -z "$PACKAGE_MANAGER" ]; then
exit 1 exit 1
fi fi
# Update system before installing packages # ── NixOS path: system updates are declarative via flake ──
echo "Updating system packages..." if [ "$DISTRO" == "nixos" ]; then
if [ "$PACKAGE_MANAGER" == "dnf" ]; then echo "NixOS detected: system updates are managed declaratively via flake.nix."
sudo dnf update -y && sudo dnf upgrade -y echo "Run 'nixos-rebuild switch --flake ~/dotfiles/nixos#nixos' to apply changes."
elif [ "$PACKAGE_MANAGER" == "apt" ]; then echo "Skipping imperative system update."
sudo apt update && sudo apt upgrade -y
else
echo "WARNING: Unknown package manager '$PACKAGE_MANAGER'. Skipping system update."
fi fi
# Setup Flatpak # ── 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..." echo "Setting up Flathub repository..."
if command -v flatpak &> /dev/null; then if command -v flatpak &> /dev/null; then
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
else else
echo "WARNING: flatpak command not found. Skipping Flathub setup." echo "WARNING: flatpak command not found. Skipping Flathub setup."
echo "Ensure Flatpak is installed via 01-package-install.sh or manually." echo "Ensure Flatpak is installed via your package manager or flake.nix."
fi fi
echo "--- System Preparation Finished ---" echo "--- System Preparation Finished ---"

View File

@@ -3,6 +3,7 @@
# 01-package-install.sh # 01-package-install.sh
# Installs system packages and Flatpak applications. # Installs system packages and Flatpak applications.
# Relies on DISTRO and PACKAGE_MANAGER being set by the caller. # Relies on DISTRO and PACKAGE_MANAGER being set by the caller.
# Supports NixOS (nix profile), Fedora (dnf), and Debian/Ubuntu (apt).
echo "--- Starting Package Installation ---" echo "--- Starting Package Installation ---"
@@ -11,6 +12,26 @@ if [ -z "$DISTRO" ] || [ -z "$PACKAGE_MANAGER" ]; then
exit 1 exit 1
fi fi
# ── NixOS path ─────────────────────────────────────────────
if [ "$DISTRO" == "nixos" ]; then
echo "NixOS detected: packages are managed declaratively via nixos/flake.nix"
echo "and nixos/home.nix. Run the main-setup.sh workflow or apply manually."
echo ""
echo " sudo nixos-rebuild switch --flake ~/dotfiles/nixos#nixos"
echo " home-manager switch --flake ~/dotfiles/nixos#blake"
echo ""
echo "If you want imperative ad-hoc packages, uncomment the lines below"
echo "or run manually:"
echo ""
echo " nix profile install nixpkgs#<package>"
echo ""
echo "Skipping imperative package installation."
echo "--- Package Installation Finished ---"
exit 0
fi
# ── Traditional distro path (Fedora / Ubuntu / Debian) ─────
# Define base package list # Define base package list
BASE_PACKAGE_LIST=( BASE_PACKAGE_LIST=(
ansible ansible

View File

@@ -2,9 +2,43 @@
# 02-dev-tools-setup.sh # 02-dev-tools-setup.sh
# Installs various development tools and utilities. # Installs various development tools and utilities.
# Supports NixOS (declarative via flake), Fedora, and Debian/Ubuntu.
# Relies on DISTRO and PACKAGE_MANAGER being set by the caller.
echo "--- Starting Development Tools Setup ---" echo "--- Starting Development Tools Setup ---"
if [ -z "$DISTRO" ] || [ -z "$PACKAGE_MANAGER" ]; then
echo "ERROR: DISTRO and PACKAGE_MANAGER must be set in the environment."
exit 1
fi
# ── NixOS path ─────────────────────────────────────────────
if [ "$DISTRO" == "nixos" ]; then
echo "NixOS detected: development tools are managed declaratively"
echo "via nixos/flake.nix and nixos/home.nix."
echo ""
echo "The following packages are already configured in the flake:"
echo " - Go (go, gopls, delve)"
echo " - Ruby on Rails (ruby, bundler, rails, rbenv, nodejs)"
echo " - Python (python3, pip, virtualenv)"
echo " - Neovim (latest)"
echo " - Cloud/DevOps (kubectl, k9s, terraform, helm, awscli2)"
echo " - Other tools (oh-my-posh, fzf, bat, eza, ripgrep, fd)"
echo ""
echo "Run the main-setup.sh NixOS workflow or apply manually:"
echo ""
echo " sudo nixos-rebuild switch --flake ~/dotfiles/nixos#nixos"
echo " home-manager switch --flake ~/dotfiles/nixos#blake"
echo ""
echo "Skipping imperative dev tools setup."
echo "--- Development Tools Setup Finished ---"
exit 0
fi
# ═══════════════════════════════════════════════════════════
# TRADITIONAL DISTRO PATH (Fedora / Ubuntu / Debian / Pop)
# ═══════════════════════════════════════════════════════════
# Setup NVIM # Setup NVIM
echo "Setting up Neovim..." echo "Setting up Neovim..."
_nvim_asset_name() { _nvim_asset_name() {
@@ -140,21 +174,68 @@ else
echo "✔ Oh-My-Posh already installed: $(oh-my-posh --version | head -n1)" echo "✔ Oh-My-Posh already installed: $(oh-my-posh --version | head -n1)"
fi fi
# Install Rust Up # ── Ruby on Rails ──────────────────────────────────────────
echo "Installing Rust via rustup..." echo ""
if command -v rustc &>/dev/null; then echo "--- Setting up Ruby on Rails ---"
echo "Rust (rustc) already installed."
if ! command -v ruby &>/dev/null; then
echo "➤ Installing Ruby via rbenv..."
# Install rbenv
if [ ! -d "$HOME/.rbenv" ]; then
git clone https://github.com/rbenv/rbenv.git "$HOME/.rbenv"
git clone https://github.com/rbenv/ruby-build.git "$HOME/.rbenv/plugins/ruby-build"
echo 'export PATH="$PATH:$HOME/.rbenv/bin"' >> "$HOME/.bashrc"
echo 'export PATH="$PATH:$HOME/.rbenv/bin"' >> "$HOME/.zshrc"
echo 'eval "$(rbenv init -)"' >> "$HOME/.bashrc"
echo 'eval "$(rbenv init -)"' >> "$HOME/.zshrc"
echo "rbenv installed. A new shell is needed or run:"
echo " export PATH=\"\$PATH:\$HOME/.rbenv/bin\" && eval \"\$(rbenv init -)\""
else
echo "rbenv already installed."
fi
# Install Ruby latest stable via rbenv
export PATH="$PATH:$HOME/.rbenv/bin"
eval "$(rbenv init - bash 2>/dev/null || true)"
if command -v rbenv &>/dev/null; then
RUBY_LATEST=$(rbenv install -l 2>/dev/null | grep -v - | tail -1)
if [ -n "$RUBY_LATEST" ]; then
echo "➤ Installing Ruby ${RUBY_LATEST} (this may take a while)..."
rbenv install "$RUBY_LATEST"
rbenv global "$RUBY_LATEST"
echo "Ruby ${RUBY_LATEST} installed and set as global version."
fi
fi
else else
# The -y flag automates the installation, --no-modify-path prevents it from altering .profile/.bashrc directly echo "✔ Ruby already installed: $(ruby --version 2>/dev/null | head -n1)"
# You'll need to source "$HOME/.cargo/env" or add it to your shell's config manually fi
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
echo "Rust installed via rustup. Source \"\$HOME/.cargo/env\" or add it to your shell config." # Install Bundler
echo "For the current session, you can run: source \"\$HOME/.cargo/env\"" if command -v gem &>/dev/null; then
if ! command -v bundler &>/dev/null; then
echo "➤ Installing Bundler..."
gem install bundler
echo "Bundler installed."
else
echo "✔ Bundler already installed."
fi
# Install Rails
if ! command -v rails &>/dev/null; then
echo "➤ Installing Rails..."
gem install rails
rbenv rehash 2>/dev/null || true
echo "Rails installed."
else
echo "✔ Rails already installed: $(rails --version 2>/dev/null | head -n1)"
fi
fi fi
echo "--- Development Tools Setup Finished ---" echo "--- Development Tools Setup Finished ---"
# --- Helm (Kubernetes package manager) --- # ── Helm (Kubernetes package manager) ──────────────────────
echo "" echo ""
echo "--- Installing Helm ---" echo "--- Installing Helm ---"
if command -v helm &>/dev/null; then if command -v helm &>/dev/null; then

16
zshrc
View File

@@ -8,6 +8,11 @@ plugins=(git)
# Editor # Editor
export EDITOR='nvim' export EDITOR='nvim'
# Nix profile
if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
fi
# Go # Go
export GOPATH=$HOME/go export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
@@ -15,14 +20,15 @@ export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
# Local bin # Local bin
export PATH="$PATH:$HOME/.local/bin:$HOME/bin" export PATH="$PATH:$HOME/.local/bin:$HOME/bin"
# Ruby on Rails (rbenv)
export PATH="$PATH:$HOME/.rbenv/bin"
eval "$(rbenv init - zsh 2>/dev/null || true)"
# Node.js and NVM configuration # Node.js and NVM configuration
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# Rust/Cargo
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh
source $HOME/dotfiles/aliases.zsh source $HOME/dotfiles/aliases.zsh
@@ -42,4 +48,6 @@ export CPLUS_INCLUDE_PATH=/usr/local/include
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Oh My Posh prompt # Oh My Posh prompt
eval "$(oh-my-posh init zsh --config ~/.config/oh-my-posh/theme.omp.json)" if command -v oh-my-posh &>/dev/null; then
eval "$(oh-my-posh init zsh --config ~/.config/oh-my-posh/theme.omp.json)"
fi