Nixos flake configuration for server running on dellprecisionM4800
- Nix 100%
| modules | ||
| secrets | ||
| .gitignore | ||
| configuration.nix | ||
| flake.lock | ||
| flake.nix | ||
| hardware-configuration.nix | ||
| README.md | ||
nixos-dellprecisionM4800
NixOS flake configuration for a home server running Docker containers, Caddy reverse proxy, and Cloudflare DDNS.
Structure
nixos/
├── flake.nix # Entry point — pins nixpkgs
├── flake.lock # Lockfile (commit this!)
├── configuration.nix # Top-level system config
├── modules/
│ ├── docker.nix # Docker daemon + container definitions
│ ├── caddy.nix # Reverse proxy virtual hosts
│ └── cloudflare-ddns.nix # DDNS updater systemd service/timer
├── README.md # README.md for entire repo
├── secrets/
| |── README.md # How to provision secrets (files git-ignored)
│ └── files/
| └── cf_api_token # Cloudflare API token (plain text)
└── .gitignore
First-time deployment
1. Prepare the PC
Boot into your existing NixOS image and SSH in. Then:
2. Copy this repo to the PC
# From your dev machine
scp -r nixos_dell/ admin@192.168.1.11:/home/admin
# Then copy the files into /etc/nixos/ from within the server
sudo rsync -av nixos_dell/ /etc/nixos/ # Copies folder contents, preserving internal structure w/o copying parent folder
# Or clone from git once you've pushed it:
# git clone https://github.com/you/nixos /etc/nixos
3. Apply the configuration
cd /etc/nixos
sudo nixos-rebuild switch --flake /etc/nixos#nixos-dellprecisionM4800
Updating
# Pull latest changes
cd /etc/nixos && git pull
# Update nixpkgs pin
nix flake update
# Apply
sudo nixos-rebuild switch --flake /etc/nixos#nixos-dellprecisionM4800
Adding a new container + subdomain
- Add a block to
containersinmodules/docker.nix - Add a matching
virtualHostsentry inmodules/caddy.nix - Rebuild the configuration
Useful commands
# Check systemd service status
systemctl status docker-uptime-kuma
systemctl status caddy
systemctl status cloudflare-ddns.timer
# View DDNS logs
journalctl -u cloudflare-ddns -f
# Force a DDNS update now
systemctl start cloudflare-ddns
# Garbage-collect old Nix generations
sudo nix-collect-garbage -d