I am trying to write some integration tests for my machines in a flake.nix, however I seem to have run into an issue. The nixosTest function and underlying make-test-python.nix seem to expect a nixos module, but the flakes nixosConfigurations output wants a system that has already been evaluated by eval-config.nix.
I don’t think you can do it at this level. However you can have your nixos modules list in variable and pass it to both nixosSystem { modules = myModules; } and nixosTest { nodes.machine = {...}: { imports = myModules;};}
I tried following your advice, but I run into an infinite recursion which I don’t fully understand, which I believe is related to access to config._module.args.
Any suggestions for how to test a nixosConfiguration with the testing framework?
Ive been down this rabbit hole myself and recently found a solution that fits my needs similar to you. Below is a link to a function that builds a nixosTest. I hope it helps and let me know if you are confused as to what is going on below.