This basically implements nss-myhostname, but natively in systemd-resolved, so that the logic becomes available also for clients using the local DNS stub for resolution or the D-Bus or Varlink APIs.