Declarative Disk Partitioning and Base NixOS Setup with Disko
Manual disk partitioning, typically performed with utilities like fdisk or parted, is a common ritual for anyone installing Linux. This process involves creating partition tables, formatting filesystems (e.g., btrfs/ext4), creating subvolumes, and manually mounting everything into /mnt. While this approach is feasible for NixOS, it fundamentally contradicts the system’s core philosophy: everything should be described declaratively in code.
Relying on manual disk partitioning significantly hinders the user experience with NixOS, especially when attempting to replicate an identical configuration on different hardware. Instead of executing a single command, users are forced to repeat the entire manual process, recalling precise mounting flags. To address this, the prominent utility Disko is employed to enable declarative disk layout descriptions.
Setting Up a Minimal Working NixOS Configuration
Following the implementation of declarative disk partitioning via Disko, the next critical step involves establishing a minimal working configuration for the system. This setup focuses on core, essential components required for NixOS functionality, without a graphical environment or advanced user-specific customizations.
This configuration process will cover the following elements:
- Bootloader: Ensuring the operating system boots correctly.
- Networking: Configuring network connections for internet and local resource access.
- User: Creating and setting up the primary system user.
- Sound: Initializing the sound subsystem.
- Localization: Setting language and regional parameters.
- Disko-config.nix Integration: Connecting the previously created Disko configuration file to manage disk partitions.
This approach facilitates the creation of reproducible and easily portable NixOS configurations, aligning perfectly with the principles of declarative system management.
While the idea of declarative disk partitioning with Disko for NixOS is certainly appealing for reproducibility, I wonder about its practical implications for less common or complex hardware setups. Does it truly simplify things, or could it introduce new layers of abstraction that are difficult to debug when something goes wrong? I can see the benefits for standard configurations, but what about the learning curve and potential pitfalls for unique partitioning schemes or edge cases?