What is Declarative Configuration in NixOS? Understanding Declarative vs Imperative Approaches?
What is Declarative Configuration in NixOS? Understanding Declarative vs Imperative Approaches?

#NixOS of Beginner

What is Declarative Configuration in NixOS? Understanding Declarative vs Imperative Approaches?

Rajdeep Singh
The Linux
Published in
3 min readOct 1, 2024

--

NixOS is an open-source Linux distribution based on the Nix package manager. NixOS uses a declarative configuration system (approach) that allows reproducibility and portability.

In NixOS, you follow tutorials on YouTube and read blogs; you know nixos uses a declarative configuration system to configure NixOS, such as installing and managing packages and services.

To install the Package, add and remove the services you need to mention in your nixos configuration.nix file and rebuild your nixos.

In the Linux distro world, there are two types of distro:

  1. Declarative Approach
  2. Imperative Approach

The Imperative type is the most common distro in linux ecosystem.

Declarative Approach

In the declarative approach, we use a file (such as a YAML, JSON, and Nix) to describe the configuration for hardware and software components such as systems, networking, users, services (like with systems), and more.

--

--

Rajdeep Singh
The Linux

Follow me if you learn more about JavaScript | TypeScript | React.js | Next.js | Linux | NixOS | https://linktr.ee/officialrajdeepsingh