NixOS is a Linux distribution built on top of the Nix package manager, known for its declarative configuration and reproducibility.
This post documents my journey of installing and configuring NixOS from scratch.
Preparation#
- Download the NixOS minimal ISO
- Create a bootable USB (I used
dd) - Back up your data (important!)
Partitioning and Installation#
# List disks
lsblk
# Partition (using /dev/nvme0n1 as example)
parted /dev/nvme0n1 -- mklabel gpt
parted /dev/nvme0n1 -- mkpart primary 512MiB -8GiB
parted /dev/nvme0n1 -- mkpart primary linux-swap -8GiB 100%
# Format
mkfs.ext4 -L nixos /dev/nvme0n1p1
mkswap -L swap /dev/nvme0n1p2configuration.nix#
Here’s my basic configuration:
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos-desktop";
time.timeZone = "Asia/Shanghai";
i18n.defaultLocale = "en_US.UTF-8";
users.users.yourname = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" ];
packages = with pkgs; [ firefox git ];
};
environment.systemPackages = with pkgs; [
vim
wget
git
];
system.stateVersion = "24.11";
}Next Steps#
- Migrate to Flakes
- Configure Home Manager
- Set up devShells
- Remote build cache
Configuration is a work in progress. Feedback welcome.