Binary refuse to build in 'localhost' hostname

I’m trying to nixify a horrendous Control-M Agent install.

The process is a bunch of chained script shells, and java jobs. Well, I’m finally able to make it finish installation into a devshell. But when i make a nix build one of the checks fails because in build env the hostname is localhost. I have tried all of the following:

  • Fake /etc/hosts; /etc/resolv.conf; /etc/hostname
  • Wrap uname binary to parse localhost with sed
  • Change hostname binary to "echo fakehost" using workaround ($NIX_REDIRECTS).

But seems like java is not using OS related tools to check the hostname. I strace it and this is the suspicious line:

[pid 269466] uname({sysname="Linux", nodename="localhost", ...}) = 0

Next step is get a chance building and preloading this library

But I prefer ask here about some known alternative to this.