How can I spawn a redis instance within a nix-build?

If you can start server with a socket interface, then you may go that way. I hope redis supports socket path in REDIS_HOST

I also believe it is possible to bind loopback interface in “fixed-output derivations”. For inspiration:

1 Like