Hard requirements: - python3: required by appctl and gitops_dispatcher.py Shell enhancements (via programs.* for automatic shell init): - programs.zoxide.enable: smart cd with bash/zsh init wired automatically - programs.starship.enable: cross-shell prompt, configured via /etc/bashrc Additional utilities: - eza: modern ls replacement - ripgrep (rg): fast grep - fd: fast find - tree: directory tree viewer - jq: JSON processor sops and age were already present — SOPS secret decryption is covered.
135 lines
6.1 KiB
Nix
135 lines
6.1 KiB
Nix
# 🌐 Server NixOS Configuration — Turnkey Headless Homelab Appliance
|
|
# Standalone declarative configuration for the roadtotech.me homelab server.
|
|
# No Home Manager. No shared desktop modules.
|
|
# Goal: wipe & restore from any NixOS installation via `nixos-install --flake ~/Core#server`
|
|
|
|
{ config, lib, pkgs, inputs, ... }:
|
|
|
|
{
|
|
imports = [
|
|
./hardware-configuration.nix # Server-specific disk and CPU configuration
|
|
./modules/homeserver.nix # Core services: systemd units, Authelia, SOPS secrets
|
|
./modules/traefik-deployments.nix # Traefik deployment secrets and env templates
|
|
./modules/dynu.nix # Dynu DDNS smart IP monitor service
|
|
];
|
|
|
|
# ── SOPS secrets configuration ──────────────────────────────────────────────
|
|
# Set once here to avoid duplicate-option conflicts across submodules
|
|
sops.defaultSopsFile = ./secrets.yaml;
|
|
sops.defaultSopsFormat = "yaml";
|
|
|
|
# ── Nix settings ─────────────────────────────────────────────────────────────
|
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
|
|
# Pin nixpkgs registry to the flake input (avoids GitHub API calls from the CLI)
|
|
nix.registry.nixpkgs.flake = inputs.nixpkgs;
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
# ── Regional & locale settings ───────────────────────────────────────────────
|
|
time.timeZone = "America/Bogota";
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
# ── Console ──────────────────────────────────────────────────────────────────
|
|
console = {
|
|
font = "Lat2-Terminus16";
|
|
keyMap = "us";
|
|
};
|
|
|
|
# ── Bootloader ───────────────────────────────────────────────────────────────
|
|
boot.loader.systemd-boot.enable = true;
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
# ── Network ──────────────────────────────────────────────────────────────────
|
|
networking.hostName = "server";
|
|
networking.networkmanager.enable = true;
|
|
|
|
# ── User account ─────────────────────────────────────────────────────────────
|
|
users.users.kiskaadee = {
|
|
isNormalUser = true;
|
|
openssh.authorizedKeys.keys = [
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICAVPPMk+WApUd/fo78+lsRGnLKSlY4GDZiNGKwBAifD"
|
|
];
|
|
extraGroups = [
|
|
"wheel" # sudo access
|
|
"docker" # run docker without sudo
|
|
"networkmanager" # modify network settings
|
|
];
|
|
};
|
|
|
|
# ── SSH ──────────────────────────────────────────────────────────────────────
|
|
services.openssh = {
|
|
enable = true;
|
|
ports = [ 22 ];
|
|
settings.PermitRootLogin = "no";
|
|
};
|
|
|
|
# ── Virtualisation ───────────────────────────────────────────────────────────
|
|
virtualisation.docker.enable = true;
|
|
|
|
# ── Dynamic binary support ───────────────────────────────────────────────────
|
|
programs.nix-ld = {
|
|
enable = true;
|
|
libraries = with pkgs; [
|
|
stdenv.cc.cc.lib
|
|
zlib
|
|
glib
|
|
];
|
|
};
|
|
|
|
# ── Headless optimizations ───────────────────────────────────────────────────
|
|
# Disable peripheral hardware & desktop services not needed on a headless server
|
|
services.pipewire.enable = false;
|
|
services.printing.enable = false;
|
|
hardware.bluetooth.enable = false;
|
|
|
|
# Disable power-saving sleep/suspend to keep the homelab always active
|
|
systemd.targets.sleep.enable = false;
|
|
systemd.targets.suspend.enable = false;
|
|
systemd.targets.hibernate.enable = false;
|
|
systemd.targets.hybrid-sleep.enable = false;
|
|
|
|
# Kernel-level power management tuning
|
|
powerManagement.powertop.enable = true;
|
|
|
|
# ── CLI tools ────────────────────────────────────────────────────────────────
|
|
# Minimal server-appropriate tooling (no desktop apps or user dotfiles)
|
|
programs.tmux.enable = true;
|
|
programs.neovim = {
|
|
enable = true;
|
|
defaultEditor = true;
|
|
};
|
|
|
|
# Shell enhancements — NixOS-level options handle both install and shell init
|
|
programs.zoxide.enable = true; # smart cd; initialises in bash/zsh automatically
|
|
programs.starship.enable = true; # cross-shell prompt
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
# Monitoring & diagnostics
|
|
htop
|
|
iotop
|
|
iftop
|
|
ncdu
|
|
# Secrets tooling (required for sops-nix secret decryption and manual re-encryption)
|
|
sops
|
|
age
|
|
# Python runtime (hard requirement for appctl and gitops_dispatcher.py)
|
|
python3
|
|
# Modern shell utilities
|
|
eza # ls replacement
|
|
ripgrep # rg — fast grep
|
|
fd # fast find
|
|
tree # directory tree viewer
|
|
# Network & transfer
|
|
git
|
|
curl
|
|
wget
|
|
rclone
|
|
jq
|
|
];
|
|
|
|
# ── State version ─────────────────────────────────────────────────────────────
|
|
# Do not modify this value after the first install.
|
|
system.stateVersion = "26.05";
|
|
}
|