Docs at `man gethostbyname`
Here's an example:
> cat hosts
198.51.100.33 test.tld
2001:db8::33 test.tld
198.51.100.12 test4.tld
2001:db8::12 test6.tld
> LD_PRELOAD=/nix/store/sw2r0gpi9c9rsvqgvi4906yxh948ydsv-nss_wrapper-1.1.16/lib/libnss_wrapper.so NSS_WRAPPER_HOSTS=hosts getent ahosts test.tld
198.51.100.33 DGRAM test.tld
198.51.100.33 STREAM test.tld
2001:db8::33 DGRAM
2001:db8::33 STREAM
> LD_PRELOAD=/nix/store/sw2r0gpi9c9rsvqgvi4906yxh948ydsv-nss_wrapper-1.1.16/lib/libnss_wrapper.so NSS_WRAPPER_HOSTS=hosts getent ahosts test4.tld
198.51.100.12 DGRAM test4.tld
198.51.100.12 STREAM test4.tld
> LD_PRELOAD=/nix/store/sw2r0gpi9c9rsvqgvi4906yxh948ydsv-nss_wrapper-1.1.16/lib/libnss_wrapper.so NSS_WRAPPER_HOSTS=hosts getent ahosts test6.tld
2001:db8::12 DGRAM test6.tld
2001:db8::12 STREAM test6.tld
> LD_PRELOAD=/nix/store/sw2r0gpi9c9rsvqgvi4906yxh948ydsv-nss_wrapper-1.1.16/lib/libnss_wrapper.so NSS_WRAPPER_HOSTS=hosts curl -v test.tld
* Host test.tld:80 was resolved.
* IPv6: 2001:db8::33
* IPv4: 198.51.100.33
* Trying [2001:db8::33]:80...
* Trying 198.51.100.33:80...
[0] https://cwrap.org/nss_wrapper.htmlThis looks like a great project!
My approach is evolving due to NixOS and home-manager with vibe coding to do the lifting. I increasing lean on vibe coding to handle simple details to safely write shell scripts (escaping strings, fml) and C/C++ apps. The complexity is minimized, allowing me to almost one-shot small utilities, and Nix handles long-term maintenance.
With NixOS, a simple C/C++ application can often replace a Python one. Nix manages reading the source, pulling dependencies, and effectively eliminating the overhead that used to favor scripting languages while marking marginal power savings during everyday use.