This thread shows up on Google, so responding for future reference: the nixosTest
function is being deprecated as of 2024: testers.nixosTest: Deprecate by roberth · Pull Request #293891 · NixOS/nixpkgs · GitHub
Instead, runNixOSTest
should be used, which coincidentally makes working with nixosConfigurations easier. This tester specifically helps you with the pkgs argument, which it tries to derive automatically. And, if you have overlay applied in your flake, you can use node.pkgsReadOnly = false;
to pass the overlayed pkgs definition into your test.
A full example here with flake.parts: flake: add nixos tests by jhvst · Pull Request #92 · ponkila/homestaking-infra · GitHub
Moreover, in the diffset above, it’s possible to test a nixosConfiguration by doing a let binding for a nixosSystem
before opening the flake schema. Take a look at the rest of the PR flake.nix for an example ponkila-ephemeral-sigma
. You can test the full host by defining the imports = ponkila-ephemeral-sigma.modules;
inside of the testable machine.