tweag / nix-hour

Questions for the weekly Nix Hour
MIT License
78 stars 3 forks source link

Testing derivations #4

Closed infinisil closed 2 years ago

infinisil commented 2 years ago

How do I write tests for a derivation? How do I run a built binary in the derivation itself? Which phase should I use for tests? Should I use a separate derivation for tests? What about tests that require e.g. a postgresql database? When should I use a NixOS test instead? How do I run separate tests for a derivation?

infinisil commented 2 years ago

We covered this partially in the last Nix Hour :). Something I didn't mention there was the postgresql thing, but I think this manual section contains everything necesary: https://nixos.org/manual/nixpkgs/stable/#sec-postgresqlTestHook. Also remember to grep through nixpkgs for lots of examples!