Pinning a service to a specific git revision

To ease a migration, I would like to pin services.nextcloud to an older version, the one available in the git revision 702f645aa8d. How can I do that? I have read some documentation on Modules on the Nix wiki but don’t understand it.

If you are using channels, I guess the simplest solution is to make a fake channel to that commit so that you can import this specific module in your configuration:

As root:

nix-channel --add stable-nextcloud
nix-channel --update

Then, in your configuration.nix file:

{ ... }:
  imports = [

  # Disable current module
  disabledModules = [ "services/web-apps/nextcloud.nix" ];

Keep in mind this configuration will use the old module with the new version of the nextcloud package. In case you need to pin the program too, you will have to add an overlay.