Passthru config to help debug nixos-generators.nixosGenerate

I’ve been trying to modify nixos-generators’ flake.nix’s nixosGenerate function so that it includes its internal nixos config as passthru.config:

       in
-        image.config.system.build.${image.config.formatAttr};
+        (image.config.system.build.${image.config.formatAttr}.overrideAttrs (old: {
+          passthru = (old.passthru or {}) // {
+            # give repl access to config
+            inherit (image) config;
+          };
+        }));
     }

This works for some of the generator’s formats, like “iso”:

$  echo '(nixosGenerate { format = "iso"; system = "aarch64-linux"; }).passthru' | nix repl .
...
{
  config = { ... };
}

But others fail, like the one I’m actually using, “qcow-efi”:

$ echo '(nixosGenerate { format = "qcow-efi"; system = "aarch64-linux"; }).passthru' | nix repl .
...
error: attribute 'overrideAttrs' missing
       at /nix/store/3v0zn96dfs6p00vandzw0hiyyyka074s-source/flake.nix:107:10:
          106|       in
          107|         (image.config.system.build.${image.config.formatAttr}.overrideAttrs (old: {
             |          ^
          108|           passthru = (old.passthru or {}) // {

I believe this is because the “qcow-efi” format’s implementation uses make-disk-image.nix:

system.build.qcow-efi = import "${toString modulesPath}/../lib/make-disk-image.nix" {

Which, in turn, calls pkgs.vmTools.runInLinuxVM on a pkgs.runCommand derivation and runInLinuxVM itself calls lib.overrideDerivation on that derivation.

As I understand it, lib.overrideDerivation strips off the input derivation’s overrideAttrs and leads to the error above.

At this point I’m in pretty far over my head on my Nix knowledge and am wondering if there’s a way to accomplish my original goal: debugging the NixOS configuration that is being used to build my image (temporarily switching to a different format, like “iso”, has gotten me part of the way, but some settings are format-specific)?

Thanks for any thoughts, it’s been a bit frustrating, but I do feel like it’s expanding my Nix/NixOS knowledge.