NixOS: Difference between revisions
imported>Ixxie |
imported>Makefu add remark to Configs |
||
| Line 9: | Line 9: | ||
=== Declarative Configuration === | === Declarative Configuration === | ||
One of NixOS's most distinguishing features is the ability to ''declaratively configure'' the whole system. This is done by specifying a configuration file which defines which packages are installed on the system, which services to run and various other settings and options. This file is normally called <code>configuration.nix</code> and is found by default at <code>/etc/nixos</code>, although another location can be set using the environment variable <code>NIX_PATH</code>. The system configuration is then built with the command <code>nixos-rebuild</code>. | One of NixOS's most distinguishing features is the ability to ''declaratively configure'' the whole system. This is done by specifying a configuration file which defines which packages are installed on the system, which services to run and various other settings and options. This file is normally called <code>configuration.nix</code> and is found by default at <code>/etc/nixos</code>, although another location can be set using the environment variable <code>NIX_PATH</code>. The system configuration is then built with the command <code>nixos-rebuild</code>. The following is an example of a <code>configuration.nix</code> file: | ||
The following is an example of a <code>configuration.nix</code> file: | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
| Line 19: | Line 17: | ||
# Import other configuration modules | # Import other configuration modules | ||
# (hardware-configuration.nix is autogenerated upon installation) | # (hardware-configuration.nix is autogenerated upon installation) | ||
# paths in nix expressions are always relative the file which defines them | |||
imports = | imports = | ||
[ | [ | ||
| Line 29: | Line 28: | ||
# Name your host machine | # Name your host machine | ||
networking.hostName = "mymachine"; | networking.hostName = "mymachine"; | ||
# Set your time zone. | |||
time.timeZone = "Europe/Utrecht"; | |||
# Enter keyboard layout | |||
services.xserver.layout = "us"; | |||
services.xserver.xkbVariant = "altgr-intl"; | |||
# Define user accounts | # Define user accounts | ||
users. | users.users = | ||
{ | { | ||
myuser = | myuser = | ||
| Line 56: | Line 62: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
For inspiration a collection of <code>configuration.nix</code> by NixOS community members can be found in the [[[Configs]] article. | |||
=== Imperative Operations === | === Imperative Operations === | ||