Without the change the eval fails as:
$ nix build --no-link -f. apacheKafka.tests
error:
… while evaluating the attribute 'nixos'
at pkgs/servers/apache-kafka/default.nix:94:9:
93| inherit (versionInfo) jre; # Used by the NixOS module to select the supported JRE
94| tests.nixos = versionInfo.nixosTest;
| ^
95| };
… while evaluating the attribute 'nixosTest'
at pkgs/servers/apache-kafka/default.nix:22:7:
21| jre = jdk17_headless;
22| nixosTest = nixosTests.kafka.kafka_4_0;
| ^
23| };
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: attribute 'kafka_4_0' missing
at pkgs/servers/apache-kafka/default.nix:22:19:
21| jre = jdk17_headless;
22| nixosTest = nixosTests.kafka.kafka_4_0;
| ^
23| };