This is not intended to be a NixOS configuration guide.
For berevity, I assume you have a fresh NixOS installation. To learn Nix and NixOS, read this guide.

This guide is flake agnostic.
I use flakes for my personal setup, but everything in the self-sufficiency notes uses classic modules.
You can find my setup here.

With a fresh NixOS installation, the configuration.nix should be in /etc/nixos/. Inside that directory, we can make a folder modules

$ mkdir modules

and make a file default.nix inside that folder.

$ touch modules/default.nix

then we can just add that to our configuration.nix

# /etc/nixos/configuration.nix
#...
imports = [
  #...
  ./modules
  #...
];
#...

Inside this modules/ folder is where we will write all the services.