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 google.com is almost perfectly reliable, but your internet connection is likely not).
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.