1# Replace Modules {#sec-replace-modules}
2
3Modules that are imported can also be disabled. The option declarations,
4config implementation and the imports of a disabled module will be
5ignored, allowing another to take it\'s place. This can be used to
6import a set of modules from another channel while keeping the rest of
7the system on a stable release.
8
9`disabledModules` is a top level attribute like `imports`, `options` and
10`config`. It contains a list of modules that will be disabled. This can
11either be the full path to the module or a string with the filename
12relative to the modules path (eg. \<nixpkgs/nixos/modules> for nixos).
13
14This example will replace the existing postgresql module with the
15version defined in the nixos-unstable channel while keeping the rest of
16the modules and packages from the original nixos channel. This only
17overrides the module definition, this won\'t use postgresql from
18nixos-unstable unless explicitly configured to do so.
19
20```nix
21{ config, lib, pkgs, ... }:
22
23{
24 disabledModules = [ "services/databases/postgresql.nix" ];
25
26 imports =
27 [ # Use postgresql service from nixos-unstable channel.
28 # sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
29 <nixos-unstable/nixos/modules/services/databases/postgresql.nix>
30 ];
31
32 services.postgresql.enable = true;
33}
34```
35
36This example shows how to define a custom module as a replacement for an
37existing module. Importing this module will disable the original module
38without having to know it\'s implementation details.
39
40```nix
41{ config, lib, pkgs, ... }:
42
43with lib;
44
45let
46 cfg = config.programs.man;
47in
48
49{
50 disabledModules = [ "services/programs/man.nix" ];
51
52 options = {
53 programs.man.enable = mkOption {
54 type = types.bool;
55 default = true;
56 description = "Whether to enable manual pages.";
57 };
58 };
59
60 config = mkIf cfg.enabled {
61 warnings = [ "disabled manpages for production deployments." ];
62 };
63}
64```