How to test a NixOS module from a PR?

Hello,

I would like to test a PR by integrating it into my system flake. Namely, I want to test nixos/writefreely: add support for email smtp password + minor fixes by jbgi · Pull Request #458481 · NixOS/nixpkgs · GitHub which make changes in the writefreely NixOS module. I would like to incorporate it into my flake in a way that only swaps this module from my flake, not the rest.

Is there a way to achieve that ?

Add the PR branch as a flake input, then add the module toimports. You’ll also need to disable the existing module (if it’s an existing module):

{ modulesPath, inputs, ... }:
{
  imports = [ "${inputs.nixpkgs-pr}/nixos/modules/.../whatever.nix"` ];
  disabledModules = [ "${modulesPath}/.../whatever.nix" ]; # note that "/nixos/modules" isn't added on here
}
1 Like

Thanks for the help, I will try that.