Getting started

Nix is a package manager and build system built on one central idea. You describe the result you want declaratively, and Nix builds exactly that result the same way on every machine. NixOS applies that idea to a whole Linux system, so your entire machine is defined by configuration files instead of accumulated manual changes. Home Manager applies the same idea to a single user's packages and dotfiles, and it runs on NixOS or on any other Linux or macOS system.

Ternix writes those configuration files for you. This page gets a machine ready to use them.

What Ternix produces

Two files do the work.

  • flake.nix is the entry point. It references nixpkgs and declares your system as a named output that Nix knows how to build. The exact commit is recorded in flake.lock, which the Flakes guide covers in full.
  • configuration.nix holds the system description, covering packages, options, and services you selected in the builder.

A Home Manager build adds a home.nix (instead of, or alongside, configuration.nix) describing a single user's packages and dotfiles. A devShell build defines a sandboxed shell preloaded with specific packages. Enter it with nix develop, and it disappears when you exit.

Prerequisites

You need the nix command with flakes support enabled. Flakes are still labelled experimental, so you opt in explicitly. This is the one step that trips up almost everyone, so get it out of the way first.

On an existing NixOS system

Add the option in your configuration.nix and rebuild.

{
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
}
sudo nixos-rebuild switch

On any other Linux or macOS system

Install Nix if you have not already, using either the official installer from nixos.org/download or the Determinate Nix Installer from Determinate Systems. Either one sets up a multi-user install and creates /nix/store for you.

Once Nix is installed, enable flakes for your user.

mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf

Open a new terminal (or run exec $SHELL) so the updated config takes effect.

Confirm it works

nix --version
nix flake --help

If nix flake --help prints usage text rather than an error about an experimental feature, you are ready. If you see the experimental-feature error, the config change has not taken effect yet. Double-check the file path and restart your shell.

The mental model

Everything Nix builds goes into /nix/store under a path derived from a hash of all its inputs. Because the path depends on the inputs, the same inputs always produce the same output and two builds never collide with each other. A NixOS "generation" is just one such build of your whole system. Switching configurations swaps which generation is active, so changes are atomic and rollbacks are instant. If a change breaks something, reboot and select the previous generation from the bootloader menu.

This is what makes Ternix's output safe to apply to a real machine. The configuration describes a complete, reproducible state, not a patch on top of whatever the machine currently looks like.

Advanced

Managing many machines. Enable flakes through your configuration management rather than by hand on each host. Keep nix.settings in a shared NixOS module that every host imports, so the feature flag stays consistent across your hosts.

Non-NixOS hosts. The same experimental-features value can be set system-wide in /etc/nix/nix.conf instead of per user, which is useful for shared build machines or CI environments where you control the system-level Nix config.

Pinning nixpkgs. The flake.lock file that Nix creates the first time you build records the exact nixpkgs commit used. Commit flake.lock alongside flake.nix in version control so every rebuild uses the same package versions, regardless of when or where it runs.

Updating. Run nix flake update in your config directory to advance nixpkgs to the latest commit. Review the release notes for breaking NixOS option renames before switching. The NixOS release notes list module incompatibilities by release.

Next steps

Read the Nix language primer so the generated files are easy to follow, then work through Using a config to apply your first Ternix output to a machine. The official tutorials at nix.dev are the most thorough companion reference for everything on this page.