This seems like it calls for taking a step back and reconsidering how you want to go about things at a higher level. You’re trying to build nix code in an environment where you have access to only part of the codebase… do you really need to do that? Can you build the generation locally, then copy the resultant closure to the cloud? Or give the cloud machine access to the entire codebase?
A better way to approach this would be to make it into a flake. And then the flake will make sure that the related files are also present when you’re doing the system evaluation.