|
|
| Line 84: |
Line 84: |
| === Modularizing your configuration with modules === <!--T:13--> | | === Modularizing your configuration with modules === <!--T:13--> |
|
| |
|
| <!--T:14-->
| | {{main|NixOS system configuration#Modularizing your configuration with modules}} |
| The <code>configuration.nix</code> file itself is an instance of a [[NixOS modules|NixOS module]], and the NixOS module system makes it straightforward to split your configuration into multiple files for better organization and reusability. Modules can:
| |
| | |
| <!--T:15-->
| |
| * Import other modules
| |
| * Declare new configuration options
| |
| * Provide values for existing options (this is what most of a standard configuration.nix does)
| |
| * Reference option values from other modules (via the <code>config</code> attribute passed to all modules)
| |
| | |
| <!--T:16-->
| |
| By declaring options for any values you wish to share between modules, you can structure your configuration into as many files as you like, importing them directly or indirectly from your root <code>configuration.nix</code> file. This makes it easier to manage large or complex configurations by keeping related settings together.
| |
| | |
| Additionally, you can import modules from remote sources if desired, for example using </code>builtins.fetchTarball</code> or similar functions, which is particularly useful for sharing configurations across multiple machines or pulling in reusable modules maintained elsewhere.
| |
| | |
| Refer to [[NixOS modules]] page and {{NixOS Manual|name=NixOS Manual: Chapter - Package Management|anchor=#sec-writing-modules}} for more information on modules.
| |
|
| |
|
| == See also == <!--T:23--> | | == See also == <!--T:23--> |