Store
NixOS
Overview
NixOS is a free, open source Linux distribution based on the Nix package manager, known for its declarative configuration and reproducibility. NixOS defines the entire system state, including software packages, system services, and user configurations, through a configuration file (usually /etc/nixos/configuration.nix), ensuring that the system is consistent and rollable on different devices. NixOS is suitable for developers, system administrators, and researchers, and is widely used in development environments, server management, and academic experiments.
History and Development
- Origin:
- NixOS originated in 2003 and was developed by Eelco Dolstra at Delft University of Technology in the Netherlands. It is based on the Nix package manager and aims to solve the dependency conflicts and non-reproducibility problems of traditional package management.
- In 2004, the first NixOS version was released, introducing a declarative configuration model.
- Development History:
- 2004-2010: NixOS established core features such as atomic upgrades, rollbacks, and isolated environments.
- 2015: Introducing NixOps to support declarative cloud deployment.
- 2020-2025: NixOS 24.11 (November 2024) optimizes Flakes (version locking mechanism), enhances reproducibility, and supports containers (such as Podman) and desktop environments (such as Hyprland).
- Community projects: Home Manager (managing user configuration) and Colmena (multi-host deployment) extend NixOS functionality.
- Community and support:
- Maintained by the NixOS community, hosted at nixos.org and GitHub.
- Provides Chinese documentation (wiki.nixos.org) and forums (such as Discourse).
- Open source license: GNU Lesser GPL v2.1 (LGPL) is adopted, which allows free use and modification, and derivative works must be open source.
Main features
NixOS is based on its declarative configuration and Nix package manager, suitable for development and production environments. The following are its main features:
- Declarative configuration
- Configuration model:
- Define the system state through /etc/nixos/configuration.nix or Flakes, including software packages, services, and user settings.
- Use sudo nixos-rebuild switch to apply configuration and generate a new system state.
- Configuration model:
- Reproducibility and isolation
- Nix package manager:
- Use functional package management to isolate the dependencies of each package.
- Packages are installed in /nix/store (such as /nix/store/...-python3-3.11) to avoid conflicts.
- Reproducibility:
- The same Nix configuration generates a consistent environment on different devices, suitable for team collaboration.
- Nix package manager:
- Atomic upgrade and rollback
- Atomic upgrade:
- Use sudo nixos-rebuild switch to upgrade the system, and failure will not affect the current state.
- Rollback:
- The GRUB menu retains historical configurations and allows rolling back to the old state.
- X users say "Rollback makes me not afraid of system crashes."
- Atomic upgrade:
- Flexible package management
- Nixpkgs:
- Contains 80,000+ software packages (such as Python, Django, PostgreSQL), community maintained.
- Use nix-env -iA nixos.python3 to install packages.
- Flakes:
- Provides version locking to ensure reproducible configuration.
- Nixpkgs:
- Cross-platform and tools
- Supported systems: support x86_64, ARM, VirtualBox.
- Tools:
- NixOps: declarative cloud deployment (AWS, VirtualBox).
- Home Manager: manage user configuration (such as .bashrc).
- Podman: Run Arch Linux containers to solve non-Nix package problems.
Advantages and limitations
Advantages
- Declarative configuration:
- Simplify deployment through a single configuration file management system.
- X post said "configuration.nix makes system management like code".
- Reproducibility:
- Ensure consistent development environment, suitable for team collaboration projects.
- Atomic upgrade and rollback:
- Safe upgrade, rollback on failure, suitable for experimental development (such as Hyprland).
- Isolate environment:
- Avoid dependency conflicts, suitable for running PostgreSQL/SQLite.
- Community support:
- Active community (wiki.nixos.org), GitHub and X.
Limitations
- Learning curve:
- Nix language and declarative configuration are complex for novices and need to be learned.
- Solution: Refer to nixos.org/learn and X tutorials.
- Dynamic data limitations:
- Cannot manage dynamic data (such as PostgreSQL database content).
- Resource usage:
- /nix/store stores multiple package versions, which takes up disk space (about 5GB+).
- Solution: Clean up regularly (nix-collect-garbage) or optimize with antiX.
- Non-mainstream experience:
- NixOS configuration is complex.
- Solution: Test NixOS in VirtualBox and deploy after getting familiar with it.
Summary
NixOS is an open source Linux distribution based on the Nix package manager, known for declarative configuration, reproducibility, and atomic upgrades, suitable for development environments, server management, and academic research. Its isolated environment, rollback function, and Flakes make it a powerful platform. NixOS is more suitable for projects that require consistency and reproducibility.