FODONUTs: fixed-output derivations for operating network-utilizing tests

This post explains how you can use fixed-output derivations (FODs) for running tests that require internet access.

This is somewhat of a useful technique I haven’t seen described in detail anywhere, so I thought I would put together a write-up about it. It should hopefully be relatively accessible to even advanced beginners and intermediate Nix users.


Something I feel is not mentioned quite explicitly is that normal derivations can have local networking which is a better choice for 99% of test cases (e.g. for a wget test suite). A local server to test against eliminates all the unreliabilities of the internet (maybe is almost perfectly reliable, but your internet connection is likely not).


I sort of touch on this in two of the footnotes:

Yeah, if you can get away without accessing the internet in your tests, you should definitely just be doing that!


I want a stdenv.mkDonut function now. Is there a repo providing generic test builder functions somewhere yet?

1 Like

I considered putting together some sort of library to easily make a FODONUT, but I wasn’t sure exactly what to do with the API of the library. I think I’d like to see a few more examples of FODONUTs in the wild before deciding on how to generalize the technique in a function like mkDonut.

I do really like the name mkDonut though :slight_smile:

1 Like