The nixpkgs library provides a module system for Nix expressions. To learn it, see our tutorial: Introduction to module system.
NixOS
NixOS makes use of the module system to provide various functionality including services and programs. See https://search.nixos.org/options for a list of all available options.
Flakes
This module system is not natively supported in Flakes. However, flakes can define and use modules using flake-parts.