Correct way to pass nixos module from nixpkgs into flake-based nixos config

Hi there. I have a flake that provides a nixos configuration:

nixosConfigurations.quaver = nixpkgs.lib.nixosSystem {
  system = "x86_64-linux";
  modules = [
    "${nixpkgs}/nixos/modules/virtualisation/openstack-config.nix"
    ./configuration.nix
  ];
};

However, I would prefer for the openstack config module to be imported in the imports list of configuration.nix, in order to keep things self contained. Pre-flakes, this could be done like this:

# configuration.nix
{
  imports = [ <nixpkgs/nixos/modules/virtualisation/openstack-config.nix> ];
}

But this is of course impure. What’s the right way to do it?

Like this:

{ modulesPath, ... }: {
  imports = [ (modulesPath + "/virtualisation/openstack-config.nix") ];
}
1 Like

It works! Thanks very much.

1 Like

More info here for posterity
https://nixos.wiki/wiki/NixOS_modules#modulesPath