nixpkgs/nixos/doc/manual/development/importing-modules.section.md
Robert Hensing 5f197bf5d0 nixos/eval-config: Deprecate NIXOS_EXTRA_MODULE_PATH
This gets rid of a potentially confusing behavior that doesn't need to
be in NixOS, and nobody ever bothered to add a test for it.
Let's keep things simple!
The suggested snippet is better than this feature ever was, and will be
in the user's face, where it belongs, kindly.

Tested with

    nix-instantiate nixos/lib/eval-config.nix --arg modules '[{fileSystems."/".device="x";boot.loader.grub.enable=false;}]' -A config.system.build.toplevel
    NIXOS_EXTRA_MODULE_PATH=$HOME/whatever.nix nix-instantiate nixos/lib/eval-config.nix --arg modules '[{fileSystems."/".device="x";boot.loader.grub.enable=false;}]' -A config.system.build.toplevel
2024-10-18 17:04:35 +02:00

384 B

Importing Modules

Sometimes NixOS modules need to be used in configuration but exist outside of Nixpkgs. These modules can be imported:

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

{
  imports =
    [ # Use a locally-available module definition in
      # ./example-module/default.nix
        ./example-module
    ];

  services.exampleModule.enable = true;
}