NixOS 22.05- Starting fresh

3 min read 12 hours ago
Published on Dec 25, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the process of starting fresh with NixOS 22.05. NixOS is a powerful Linux distribution known for its declarative configuration model and package management system. This step-by-step guide aims to help you set up NixOS on your system, ensuring a smooth installation and configuration experience.

Step 1: Prepare Your Environment

  • Download NixOS ISO:

    • Visit the official NixOS website at nixos.org.
    • Select the version 22.05 and download the appropriate ISO image for your hardware (64-bit or 32-bit).
  • Create a Bootable USB:

    • Use a tool like Rufus (for Windows) or Etcher (for Windows, macOS, Linux) to create a bootable USB drive.
    • Ensure to select the downloaded NixOS ISO file and the correct USB drive.
  • Backup Important Data:

    • Before proceeding, back up any important data on your computer, as the installation process may overwrite existing data on the target disk.

Step 2: Boot from the USB Drive

  • Restart Your Computer:

    • Insert the bootable USB drive and restart your computer.
  • Access BIOS/UEFI Settings:

    • Enter the BIOS/UEFI settings by pressing the designated key (usually F2, F10, DEL) during boot.
  • Set USB as Boot Device:

    • Change the boot order to prioritize the USB drive.
    • Save changes and exit the BIOS/UEFI settings.

Step 3: Start the NixOS Installer

  • Select NixOS Installer:

    • When the NixOS boot menu appears, select the "NixOS installer" option.
  • Choose Language and Keyboard Layout:

    • Follow the prompts to select your preferred language and keyboard layout.

Step 4: Configure Disk Partitions

  • Open a Terminal:

    • Once the installer loads, open a terminal to manage disk partitions.
  • Use fdisk or parted:

    • You can use either fdisk or parted to create partitions. A basic setup might include:
      • A root partition (/) for the NixOS installation.
      • A swap partition (optional).

    Example command to create a new partition:

    fdisk /dev/sda
    
  • Format Partitions:

    • Format your partitions using the following command:
    mkfs.ext4 /dev/sda1  # For root partition
    mkswap /dev/sda2     # For swap partition
    

Step 5: Install NixOS

  • Mount the Filesystem:

    • Mount the root partition:
    mount /dev/sda1 /mnt
    
  • Generate the NixOS Configuration:

    • Run the following command to generate the default configuration files:
    nixos-generate-config --root /mnt
    
  • Edit Configuration File:

    • Open the configuration file located at /mnt/etc/nixos/configuration.nix using a text editor (e.g., nano).
    • Customize settings such as:
      • Hostname
      • Users
      • Network configuration
      • Packages to install
  • Install NixOS:

    • Execute the installation command:
    nixos-install
    

Step 6: Reboot and Post-Installation Setup

  • Reboot the System:

    • Once the installation completes, reboot your system:
    reboot
    
  • Remove USB Drive:

    • Ensure to remove the USB drive during the reboot to boot from the hard disk.
  • Log In:

    • Log in using the user account you created during the configuration.

Conclusion

You have now completed the fresh installation of NixOS 22.05. This guide covered downloading the ISO, creating a bootable USB, configuring disk partitions, and installing the operating system. To further explore NixOS, consider diving into the NixOS manual for advanced configurations and package management. Happy exploring!