nix-community/nix-unit

Unit testing for Nix code [maintainer=@adisbladis]

C++

142

685 commits

updated Sep 18, 2026

See the code

README

nix-unit

This project runs an attribute set of tests compatible with lib.debug.runTests while allowing individual attributes to fail.

Why use nix-unit?

  • Simple structure compatible with lib.debug.runTests

  • Allows individual test attributes to fail individually.

Rather than evaluating the entire test suite in one go, serialise & compare nix-unit uses the Nix evaluator C++ API. Meaning that we can catch test failures individually, even if the failure is caused by an evaluation error.

  • Fast.

No additional processing and coordination overhead caused by the external process approach.

Comparison with other tools

This comparison matrix was originally taken from Unit test your Nix code but has been adapted. Pythonix is excluded as it's unmaintained.

ToolCan test eval failuresTests defined in Nixin nixpkgssnapshot testing(1)Supports Lix
Nix-unityesyesyesnono
Lix-unityesyesnonoyes (2)
runTestsnoyesyesnoyes
Nixtnoyesnonoyes
Namakanoyesyesyes?
  1. Snapshot testing
  2. While lix-unit supports Lix, it does not support Nix, and vice versa.

Using with Lix instead of Nix

The Lix codebase has gone through significant changes, and it's not tenable to have a single code base that supports both implementations. Therefore nix-unit has been forked into lix-unit

Documentation

https://nix-community.github.io/nix-unit/

Contributors

adisbladis

172 commits

Mic92

155 commits

mergify[bot]

105 commits

nix-community/nix-unit

Unit testing for Nix code [maintainer=@adisbladis]

C++

142

685 commits

updated Sep 18, 2026

See the code

README

nix-unit

This project runs an attribute set of tests compatible with lib.debug.runTests while allowing individual attributes to fail.

Why use nix-unit?

  • Simple structure compatible with lib.debug.runTests

  • Allows individual test attributes to fail individually.

Rather than evaluating the entire test suite in one go, serialise & compare nix-unit uses the Nix evaluator C++ API. Meaning that we can catch test failures individually, even if the failure is caused by an evaluation error.

  • Fast.

No additional processing and coordination overhead caused by the external process approach.

Comparison with other tools

This comparison matrix was originally taken from Unit test your Nix code but has been adapted. Pythonix is excluded as it's unmaintained.

ToolCan test eval failuresTests defined in Nixin nixpkgssnapshot testing(1)Supports Lix
Nix-unityesyesyesnono
Lix-unityesyesnonoyes (2)
runTestsnoyesyesnoyes
Nixtnoyesnonoyes
Namakanoyesyesyes?
  1. Snapshot testing
  2. While lix-unit supports Lix, it does not support Nix, and vice versa.

Using with Lix instead of Nix

The Lix codebase has gone through significant changes, and it's not tenable to have a single code base that supports both implementations. Therefore nix-unit has been forked into lix-unit

Documentation

https://nix-community.github.io/nix-unit/

Contributors

adisbladis

172 commits

Mic92

155 commits

mergify[bot]

105 commits

Languages

C++

44.0%

Nix

34.8%

Python

19.4%

Meson

1.8%