Write conf. file as module

Hello! I have encountered some difficulties with configuration files. There is a file configuration.nix and a module nixvim.nix that I am trying to write in the following form:


{ config, pkgs, lib, ... }: {

  options = {
    THE_MODULE.enable = lib.mkEnableOption "Enables THE_MODULE";
  };

  config = lib.mkIf config.THE_MODULE.enable {
    # Here is some configuration
  };
}

And here is the nixvim.nix file:


{ pkgs, lib, ... }:
let
  nixvim = import (builtins.fetchGit {
    url = "https://github.com/nix-community/nixvim";
    ref = "nixos-24.05";
  });
in
{
  imports = [
    nixvim.nixosModules.nixvim
  ];

  programs.nixvim.enable = true;
}

Currently, I am simply importing nixvim.nix in configuration.nix. I would like to make it more modular. Can you help me combine these two scripts?