What is a .nix file?
Nix Expression File · Code and data · Eelco Dolstra / NixOS project · 2003
A .nix file is a Nix expression: code in a small functional language that describes packages, development environments or entire systems for the Nix package manager and NixOS, reproducibly.
What is a .nix file used for?
Nix treats builds as pure functions: the same .nix input yields bit-for-bit the same environment, which is why developers use shell.nix or flake.nix to pin a project's exact toolchain, and why NixOS defines a whole OS in configuration.nix.
The language is lazy and functional, closer to a mini Haskell than to YAML, which gives it a learning curve. Flakes (flake.nix) are the modern entry point that also pins all inputs.
How to open a .nix file
The .nix format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .nix file.
Windows
- VS Code (Nix IDE), via WSL
- any text editor
macOS
- VS Code (Nix IDE)
- any text editor
Linux
- VS Code (Nix IDE)
- any text editor
.nix file signature (magic bytes)
Programs recognise a .nix file by the bytes at the start of the file, not by its name. These are the signatures for Nix.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | plain text; no fixed magic bytes |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .nix file?
A .nix file is a Nix expression: code in a small functional language that describes packages, development environments or entire systems for the Nix package manager and NixOS, reproducibly.
What is a flake.nix file?
The modern standard entry point of a Nix project: it declares inputs (pinned dependencies) and outputs (packages, dev shells, systems), making builds fully reproducible.
What is the difference between Nix and NixOS?
Nix is the package manager and language; NixOS is a Linux distribution built on it where the entire system is declared in .nix files.
How do I open a .nix file?
Any text editor; it is plain text. Using it requires the Nix package manager, which runs on Linux and macOS (and Windows via WSL).
Related formats
Sources
Details on this page were checked against authoritative references: