NixOS Installation Process for GMKtec

Summary

The procedure for deploying the Sokrates NixOS configuration onto GMKtec hardware (specifically the sokrates-dev profile). This process involves booting from a live installer, partitioning the internal NVMe drive, generating hardware-specific configurations, and executing a flake-based installation.

Details

The installation of NixOS on the GMKtec (sokrates-dev) appliance follows a standard NixOS installation workflow but requires specific steps to handle the project’s flake-based configuration and hardware variations.

1. Initial Boot and Environment Setup

The process begins by booting the GMKtec from a standard NixOS live USB. Once in the live TTY environment, networking must be established (usually via DHCP) to allow for cloning the repository or fetching dependencies.

2. Disk Partitioning and Formatting

The internal drive is typically identified as /dev/nvme0n1. There are two methods for preparing the disk:

Automated Partitioning with Disko

If using the project’s Disko configuration, the setup can be automated. However, because the disk.nix module often expects standard NixOS module arguments, it is best run through the flake:

sudo nix run github:nix-community/disko -- --mode disko --flake /path/to/sokrates/nixos#sokrates-dev

This command partitions the disk (512MB EFI + remainder as ext4) and mounts the volumes to /mnt automatically.

Manual Partitioning

If Disko is unavailable or fails, manual partitioning using parted is required:

# Create GPT label
sudo parted /dev/nvme0n1 -- mklabel gpt
 
# Create EFI partition (512MB)
sudo parted /dev/nvme0n1 -- mkpart ESP fat32 1MiB 513MiB
sudo parted /dev/nvme0n1 -- set 1 esp on
 
# Create Root partition (Remainder)
sudo parted /dev/nvme0n1 -- mkpart primary ext4 513MiB 100%
 
# Format and Mount
sudo mkfs.fat -F 32 /dev/nvme0n1p1
sudo mkfs.ext4 /dev/nvme0n1p2
sudo mount /dev/nvme0n1p2 /mnt
sudo mkdir -p /mnt/boot
sudo mount /dev/nvme0n1p1 /mnt/boot

3. Hardware Configuration Generation

To ensure the system correctly identifies the GMKtec’s specific hardware (controllers, kernel modules, etc.), a hardware configuration must be generated from the live environment and integrated into the repository:

sudo nixos-generate-config --root /mnt --show-hardware-config > /path/to/sokrates/nixos/modules/hardware-gmktec.nix

This file must maintain the standard module header: { config, lib, pkgs, modulesPath, ... }:.

4. Flake Installation

The final installation is performed using nixos-install. It is critical to point the --flake flag to the specific directory containing the flake.nix file (the nixos/ subdirectory in the Sokrates repository) and specify the sokrates-dev output.

sudo nixos-install --flake /path/to/sokrates/nixos#sokrates-dev

Common Pitfalls

  • Command Syntax: The parted command requires -- before the subcommand (e.g., mklabel) to prevent the shell from misinterpreting the command as a flag.
  • Flake Paths: The installation will fail if the flake path points to the repository root instead of the subdirectory where the NixOS configurations are defined.
  • Persistence: The installer TTY is a throwaway environment. All configuration changes must be committed to the repository or written to the mounted disk at /mnt before rebooting.