This guide explains how to install my NixOS configuration.
install-config.nixEdit install-config.nix at the root of this repository:
{
# Disk configuration
disk = {
# Device to use (null = auto-detect first disk during installation)
# Set to specific device if needed, e.g., "/dev/nvme0n1"
device = null;
# Filesystem type: "btrfs" or "ext4"
filesystem = "btrfs";
# Enable LUKS encryption (true/false)
useLuks = true;
# Partition sizes
swapSize = "32G"; # Swap partition size
efiSize = "512M"; # EFI partition size
# Encryption settings (only used if useLuks = true)
luks = {
name = "crypted"; # Name for the encrypted volume
};
};
# Btrfs settings (only used if filesystem = "btrfs")
btrfs = {
filesystemLabel = "nixos";
subvolumes = {
"/" = { };
"/home" = {
compression = "zstd";
};
"/nix" = {
options = [ "noatime" "compress-force=zstd:1" "nodatacow" ];
};
"/var/log" = {
compression = "zstd";
};
};
};
# Ext4 settings (only used if filesystem = "ext4")
ext4 = {
filesystemLabel = "nixos";
mountOptions = [ "noatime" ];
};
# Tmpfs configuration
tmpfs = {
enable = true;
size = "4G";
mode = "1777";
};
}
Note: The hostname should be set in hosts/<your-host>/default.nix, NOT in install-config.nix.
Common configurations:
useLuks = false;filesystem = "ext4";swapSize = "16G";Download and flash the latest NixOS minimal ISO:
# Download NixOS ISO
wget https://channels.nixos.org/latest-nixos-minimal-x86_64-linux.iso
# Flash to USB (replace /dev/sdX with your USB device)
sudo dd if=nixos-minimal-x86_64-linux.iso of=/dev/sdX bs=4M conv=fsync status=progress
Boot from the USB and ensure you have internet:
# Test internet connection
ping google.com
# Clone this repository
git clone https://github.com/jokyv/nixos-config.git /tmp/nixos-config
cd /tmp/nixos-config
Edit hosts/jokyv/default.nix and set your hostname:
networking.hostname = "nixos"; # Change to your preferred hostname
IMPORTANT: For installation ONLY, temporarily add disko to your host config:
In hosts/jokyv/default.nix, add these lines to the imports array:
imports = [
inputs.disko.nixosModules.disko
../../disks/universal-config.nix
# ... rest of your imports
];
You must remove these after installation! See Post-Installation below.
Choose one of these methods:
Option A: Temporary password (simple)
# In hosts/jokyv/default.nix, add:
users.users.jokyv.initialPassword = "changeme";
Remove this line after first boot and set a proper password with passwd.
Option B: sops-nix (secure, recommended)
# Import sops module
import = [ inputs.sops-nix.nixosModules.sops ]
# Define the secret
sops.secrets."pass_jokyv" = { };
# Use it for user password
users.users.jokyv.passwordFile = config.sops.secrets."pass_jokyv".path;
The universal installer will automatically detect the first disk:
# Format and install NixOS
sudo nix run --experimental-features "nix-command flakes" github:nix-community/disko -- --mode disko --flake .#nixos
The installer will automatically format and partition the first available disk.
sudo nixos-install --no-root-password --flake .#nixos
sudo reboot
Remove the USB stick when the computer turns off.
If you need to select a specific disk or use a legacy configuration:
lsblk to identify the disk namedisks/ directory:
disk-config-btrfs-luks.nix - Btrfs with LUKS encryptiondisk-config-btrfs.nix - Btrfs without encryptionAfter booting into your new system, you must remove disko from the host configuration to prevent issues with future rebuilds:
# Edit hosts/jokyv/default.nix
nano ~/nixos-config/hosts/jokyv/default.nix
Remove these lines from the imports array:
inputs.disko.nixosModules.disko
../../disks/universal-config.nix
Then verify the configuration works:
sudo nixos-rebuild switch --flake .#nixos
Check that disko has set up everything correctly:
# Verify tmpfs is mounted
findmnt /tmp
# Verify /var subvolume
findmnt /var
# List all btrfs subvolumes
sudo btrfs subvolume list /
# Clone the repository
git clone git@github.com:jokyv/nixos-config.git ~/nixos-config
cd ~/nixos-config
# Install home-manager temporarily
nix shell -p home-manager
# Apply Home Manager configuration
home-manager switch --flake .#jokyv
# Or use just (if you have justfile installed)
just home
After installation, you may want to:
aider-chat.config - for example, ruff.toml for Python lintingIf you see this error during installation:
lsblk/dev/disk/by-diskseq/If the issue persists, manually specify the disk in install-config.nix:
disk = {
device = "/dev/nvme0n1"; # or /dev/sda
...
};
The installer uses /dev/disk/by-diskseq/1 (first disk) by default. To select a different disk, edit install-config.nix:
disk.device = "/dev/nvme0n1"; # Your specific disk
The universal installer handles the first disk. For multi-disk setups, use the legacy configurations in disks/disk-config-*.nix.
lsblkmount | grep /bootlsblk -fnixos-config/
├── install-config.nix # Installation configuration (disk, fs, encryption)
├── disks/
│ └── universal-config.nix # Auto-detecting disk config (for installation only)
├── hosts/
│ └── jokyv/
│ ├── default.nix # Host configuration (does NOT import universal-config)
│ └── hardware-configuration.nix # Generated hardware config with mount points
└── docs/
└── installation.md # This file
Important: universal-config.nix is ONLY used during installation. Normal rebuilds use hardware-configuration.nix for filesystem mounts.
To add a new host:
hosts/new-host/default.nixhosts/jokyv/default.nixnetworking.hostname to the new hostnameinputs.disko.nixosModules.disko and ../../disks/universal-config.nix to imports, then remove after installationinstall-config.nix before installing (disk, filesystem, encryption settings)Then add to flake.nix:
nixosConfigurations = {
jokyv = nixpkgs.lib.nixosSystem { modules = [ ./hosts/jokyv/default.nix ... ]; };
new-host = nixpkgs.lib.nixosSystem { modules = [ ./hosts/new-host/default.nix ... ]; };
};