NixOS is a Linux distro built around the Nix package manager, where every system state — packages, services, users — is defined declaratively in configuration.nix. Atomic upgrades, rollback in seconds, reproducible across machines. The trade-off is the learning curve.
Prerequisites
- A VM or physical host with 2 vCPU, 4 GiB RAM, 20 GiB disk.
nixos-minimal-x.yy-x86_64-linux.isofromnixos.org/download.- UEFI recommended.
Step 1: Boot the ISO
Boot from USB/CD. You drop to a root shell with networking, ssh, and a curated tool set already in place.
sudo -i
loadkeys us
Confirm internet:
ping -c 2 nixos.org
For wifi:
systemctl start wpa_supplicant
wpa_cli # then `add_network`, `set_network 0 ssid "..."`, etc.
Step 2: Partition (UEFI + ext4)
parted /dev/nvme0n1 -- mklabel gpt
parted /dev/nvme0n1 -- mkpart ESP fat32 1MiB 512MiB
parted /dev/nvme0n1 -- set 1 esp on
parted /dev/nvme0n1 -- mkpart primary 512MiB 100%
mkfs.fat -F32 -n boot /dev/nvme0n1p1
mkfs.ext4 -L nixos /dev/nvme0n1p2
mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
Step 3: Generate the starting config
nixos-generate-config --root /mnt
ls /mnt/etc/nixos
# configuration.nix hardware-configuration.nix
hardware-configuration.nix is auto-detected (CPU, disks, filesystems) — leave it alone. Edit configuration.nix:
nano /mnt/etc/nixos/configuration.nix
A minimal server-shaped config:
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos-host";
networking.networkmanager.enable = true;
time.timeZone = "Asia/Riyadh";
i18n.defaultLocale = "en_US.UTF-8";
users.users.ops = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" ];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAA... your@workstation"
];
};
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
environment.systemPackages = with pkgs; [
vim git htop curl tmux
];
networking.firewall.allowedTCPPorts = [ 22 ];
system.stateVersion = "24.05";
}
Step 4: Install
nixos-install
nixos-install builds the entire system from your config, copies it to /mnt, and asks for the root password at the end. This takes 10–20 minutes the first time.
When it finishes, reboot:
reboot
Remove the USB during POST.
Step 5: First boot and ssh in
Log in as root with the password you set, then passwd ops to set the operator's password, and verify ssh from your workstation:
ssh ops@nixos-host
sudo nixos-version
Verify
nixos-version
nixos-rebuild list-generations
systemctl --failed
journalctl -p err -b
Conclusion
A working NixOS host in two files (configuration.nix + hardware-configuration.nix) — every package, every user, every service explicit. The first install is slow because Nix is downloading a closure; subsequent rebuilds are fast.
Next steps
- Manage system state via configuration.nix declaratively.
- For more conventional distros see Install Debian 12 or Install Arch Linux.
- For container-shaped declarative deploys see Kubernetes k3s.
Comments
0 total · 0 threads