NixOS: Difference between revisions
imported>Ixxie No edit summary |
imported>Ixxie |
||
| 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>. | 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 following is an example of a <code>configuration.nix</code> file: | ||
<syntaxhighlight lang="nix"> | |||
{ config, pkgs, ... }: | |||
{ | |||
# Import other configuration modules | |||
# (hardware-configuration.nix is autogenerated upon installation) | |||
imports = | |||
[ | |||
./hardware-configuration.nix | |||
./my-dev-tools.nix | |||
./my-desktop-env.nix | |||
./etc.nix | |||
]; | |||
# Name your host machine | |||
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 | |||
users.extraUsers = | |||
{ | |||
myuser = | |||
{ | |||
home = "/home/myuser"; | |||
extraGroups = [ "wheel" "networkmanager" ]; | |||
isNormalUser = true; | |||
uid = 1000; | |||
}; | |||
}; | |||
# Install some packages | |||
environment.systemPackages = | |||
with pkgs; | |||
[ | |||
ddate | |||
testdisk | |||
zsh | |||
]; | |||
# Enable the OpenSSH daemon | |||
services.openssh.enable = true; | |||
} | |||
</syntaxhighlight> | |||
=== Imperative Operations === | === Imperative Operations === | ||