Similar post by different author https://fmnxl.com/blog/setting-up-nix-binary-cache/
You can also serve the cache directly from the local Nix store on NixOS. This is useful if you are self-hosting the cache on the same machine that builds it. I do this for my home-server, which is relatively powerful compared to my ultrabook, and so I do most builds on it, which automatically gives me free cache, without having to manually push.
The linked tweet contains links to my Nix configuration.
Somewhat related: https://blog.ipfs.io/2020-09-08-nix-ipfs-milestone-1/