NixOS: Difference between revisions
imported>HLandau |
imported>HLandau |
||
| Line 182: | Line 182: | ||
=== Modules === | === Modules === | ||
''See also: [https://nixos.org/nixos/manual/index.html#sec-writing-modules Modules (NixOS Manual)]'' | |||
NixOS | The NixOS module system as defined in [[Nixpkgs]] provides the means necessary to customize the configuration of the OS. It is used to enable and customize services such as nginx, enable firmware and customize the kernel. | ||
All module configuration is generally performed by adding options to <code>/etc/nixos/configuration.nix</code>. Most of the examples in the wiki show how this file can be used to configure the OS. | |||
The NixOS module system implements a typing system which allows typechecking of option settings. It also enables options defined in multiple places to be merged automatically. This allows you to spread your configuration over multiple files, and the options you set across all of those files will be merged together: | |||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
# /etc/nixos/configuration.nix | |||
{ | { | ||
imports = [ | imports = [ | ||
| Line 197: | Line 200: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
# /etc/nixos/basic-webserver.nix | |||
{ | { | ||
services.nginx.enable = true; | services.nginx.enable = true; | ||
| Line 206: | Line 209: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
# /etc/nixos/blog.nix | |||
{ | { | ||
services.nginx.virtualHosts."blog.example.com" = { | services.nginx.virtualHosts."blog.example.com" = { | ||
| Line 214: | Line 217: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
=== Generations === | === Generations === | ||