Unit tests for nix functions

How are you testing your nix functions? I’m writing some helper nix functions and I’d like to add some tests, but I didn’t find much about testing nix functions.

I found this project: https://github.com/nix-community/nixt
It looks promising, but I don’t understand how to write a test with it

1 Like

There is a runTests function in nixpkgs/lib/debug.nix. It seems many (all?) nixpkgs/lib/tests are using that.

1 Like

thanks @bjornfor, I need to get my head around about how to run them. But the docs:


and this example:


are a good starting point :slight_smile:

1 Like