···23 this unit automatically at certain points in time, for instance,24 every night at 03:15:25 </para>26- <programlisting language="bash">27nix.gc.automatic = true;28nix.gc.dates = "03:15";29</programlisting>
···23 this unit automatically at certain points in time, for instance,24 every night at 03:15:25 </para>26+ <programlisting language="nix">27nix.gc.automatic = true;28nix.gc.dates = "03:15";29</programlisting>
···31 address. This can be accomplished using the following configuration32 on the host:33 </para>34- <programlisting language="bash">35networking.nat.enable = true;36networking.nat.internalInterfaces = ["ve-+"];37networking.nat.externalInterface = "eth0";···45 If you are using Network Manager, you need to explicitly prevent it46 from managing container interfaces:47 </para>48- <programlisting language="bash">49networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];50</programlisting>51 <para>
···31 address. This can be accomplished using the following configuration32 on the host:33 </para>34+ <programlisting language="nix">35networking.nat.enable = true;36networking.nat.internalInterfaces = ["ve-+"];37networking.nat.externalInterface = "eth0";···45 If you are using Network Manager, you need to explicitly prevent it46 from managing container interfaces:47 </para>48+ <programlisting language="nix">49networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];50</programlisting>51 <para>
···42 process would get 1/1001 of the cgroup’s CPU time.) You can limit a43 service’s CPU share in <literal>configuration.nix</literal>:44 </para>45- <programlisting language="bash">46systemd.services.httpd.serviceConfig.CPUShares = 512;47</programlisting>48 <para>···57 <literal>configuration.nix</literal>; for instance, to limit58 <literal>httpd.service</literal> to 512 MiB of RAM (excluding swap):59 </para>60- <programlisting language="bash">61systemd.services.httpd.serviceConfig.MemoryLimit = "512M";62</programlisting>63 <para>
···42 process would get 1/1001 of the cgroup’s CPU time.) You can limit a43 service’s CPU share in <literal>configuration.nix</literal>:44 </para>45+ <programlisting language="nix">46systemd.services.httpd.serviceConfig.CPUShares = 512;47</programlisting>48 <para>···57 <literal>configuration.nix</literal>; for instance, to limit58 <literal>httpd.service</literal> to 512 MiB of RAM (excluding swap):59 </para>60+ <programlisting language="nix">61systemd.services.httpd.serviceConfig.MemoryLimit = "512M";62</programlisting>63 <para>
···6 following specifies that there shall be a container named7 <literal>database</literal> running PostgreSQL:8 </para>9- <programlisting language="bash">10containers.database =11 { config =12 { config, pkgs, ... }:···29 However, they cannot change the network configuration. You can give30 a container its own network as follows:31 </para>32- <programlisting language="bash">33containers.database = {34 privateNetwork = true;35 hostAddress = "192.168.100.10";
···6 following specifies that there shall be a container named7 <literal>database</literal> running PostgreSQL:8 </para>9+ <programlisting language="nix">10containers.database =11 { config =12 { config, pkgs, ... }:···29 However, they cannot change the network configuration. You can give30 a container its own network as follows:31 </para>32+ <programlisting language="nix">33containers.database = {34 privateNetwork = true;35 hostAddress = "192.168.100.10";
···91 In order to enable a systemd <emphasis>system</emphasis> service92 with provided upstream package, use (e.g):93 </para>94- <programlisting language="bash">95systemd.packages = [ pkgs.packagekit ];96</programlisting>97 <para>
···91 In order to enable a systemd <emphasis>system</emphasis> service92 with provided upstream package, use (e.g):93 </para>94+ <programlisting language="nix">95systemd.packages = [ pkgs.packagekit ];96</programlisting>97 <para>
···4 If you find yourself repeating yourself over and over, it’s time to5 abstract. Take, for instance, this Apache HTTP Server configuration:6 </para>7- <programlisting language="bash">8{9 services.httpd.virtualHosts =10 { "blog.example.org" = {···29 the only difference is the document root directories. To prevent30 this duplication, we can use a <literal>let</literal>:31 </para>32- <programlisting language="bash">33let34 commonConfig =35 { adminAddr = "alice@example.org";···55 You can write a <literal>let</literal> wherever an expression is56 allowed. Thus, you also could have written:57 </para>58- <programlisting language="bash">59{60 services.httpd.virtualHosts =61 let commonConfig = ...; in···74 of different virtual hosts, all with identical configuration except75 for the document root. This can be done as follows:76 </para>77- <programlisting language="bash">78{79 services.httpd.virtualHosts =80 let
···4 If you find yourself repeating yourself over and over, it’s time to5 abstract. Take, for instance, this Apache HTTP Server configuration:6 </para>7+ <programlisting language="nix">8{9 services.httpd.virtualHosts =10 { "blog.example.org" = {···29 the only difference is the document root directories. To prevent30 this duplication, we can use a <literal>let</literal>:31 </para>32+ <programlisting language="nix">33let34 commonConfig =35 { adminAddr = "alice@example.org";···55 You can write a <literal>let</literal> wherever an expression is56 allowed. Thus, you also could have written:57 </para>58+ <programlisting language="nix">59{60 services.httpd.virtualHosts =61 let commonConfig = ...; in···74 of different virtual hosts, all with identical configuration except75 for the document root. This can be done as follows:76 </para>77+ <programlisting language="nix">78{79 services.httpd.virtualHosts =80 let
···7 network configuration not covered by the existing NixOS modules. For8 instance, to statically configure an IPv6 address:9 </para>10- <programlisting language="bash">11networking.localCommands =12 ''13 ip -6 addr add 2001:610:685:1::1/64 dev eth0
···7 network configuration not covered by the existing NixOS modules. For8 instance, to statically configure an IPv6 address:9 </para>10+ <programlisting language="nix">11networking.localCommands =12 ''13 ip -6 addr add 2001:610:685:1::1/64 dev eth0
···3 <para>4 The NixOS configuration file generally looks like this:5 </para>6- <programlisting language="bash">7{ config, pkgs, ... }:89{ option definitions···21 the name of an option and <literal>value</literal> is its value. For22 example,23 </para>24- <programlisting language="bash">25{ config, pkgs, ... }:2627{ services.httpd.enable = true;···44 <literal>true</literal>. This means that the example above can also45 be written as:46 </para>47- <programlisting language="bash">48{ config, pkgs, ... }:4950{ services = {···96 <para>97 Strings are enclosed in double quotes, e.g.98 </para>99- <programlisting language="bash">100networking.hostName = "dexter";101</programlisting>102 <para>···107 Multi-line strings can be enclosed in <emphasis>double single108 quotes</emphasis>, e.g.109 </para>110- <programlisting language="bash">111networking.extraHosts =112 ''113 127.0.0.2 other-localhost···135 These can be <literal>true</literal> or136 <literal>false</literal>, e.g.137 </para>138- <programlisting language="bash">139networking.firewall.enable = true;140networking.firewall.allowPing = false;141</programlisting>···149 <para>150 For example,151 </para>152- <programlisting language="bash">153boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 60;154</programlisting>155 <para>···171 Sets were introduced above. They are name/value pairs enclosed172 in braces, as in the option definition173 </para>174- <programlisting language="bash">175fileSystems."/boot" =176 { device = "/dev/sda1";177 fsType = "ext4";···189 The important thing to note about lists is that list elements190 are separated by whitespace, like this:191 </para>192- <programlisting language="bash">193boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];194</programlisting>195 <para>196 List elements can be any other type, e.g. sets:197 </para>198- <programlisting language="bash">199swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];200</programlisting>201 </listitem>···211 through the function argument <literal>pkgs</literal>. Typical212 uses:213 </para>214- <programlisting language="bash">215environment.systemPackages =216 [ pkgs.thunderbird217 pkgs.emacs
···3 <para>4 The NixOS configuration file generally looks like this:5 </para>6+ <programlisting language="nix">7{ config, pkgs, ... }:89{ option definitions···21 the name of an option and <literal>value</literal> is its value. For22 example,23 </para>24+ <programlisting language="nix">25{ config, pkgs, ... }:2627{ services.httpd.enable = true;···44 <literal>true</literal>. This means that the example above can also45 be written as:46 </para>47+ <programlisting language="nix">48{ config, pkgs, ... }:4950{ services = {···96 <para>97 Strings are enclosed in double quotes, e.g.98 </para>99+ <programlisting language="nix">100networking.hostName = "dexter";101</programlisting>102 <para>···107 Multi-line strings can be enclosed in <emphasis>double single108 quotes</emphasis>, e.g.109 </para>110+ <programlisting language="nix">111networking.extraHosts =112 ''113 127.0.0.2 other-localhost···135 These can be <literal>true</literal> or136 <literal>false</literal>, e.g.137 </para>138+ <programlisting language="nix">139networking.firewall.enable = true;140networking.firewall.allowPing = false;141</programlisting>···149 <para>150 For example,151 </para>152+ <programlisting language="nix">153boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 60;154</programlisting>155 <para>···171 Sets were introduced above. They are name/value pairs enclosed172 in braces, as in the option definition173 </para>174+ <programlisting language="nix">175fileSystems."/boot" =176 { device = "/dev/sda1";177 fsType = "ext4";···189 The important thing to note about lists is that list elements190 are separated by whitespace, like this:191 </para>192+ <programlisting language="nix">193boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];194</programlisting>195 <para>196 List elements can be any other type, e.g. sets:197 </para>198+ <programlisting language="nix">199swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];200</programlisting>201 </listitem>···211 through the function argument <literal>pkgs</literal>. Typical212 uses:213 </para>214+ <programlisting language="nix">215environment.systemPackages =216 [ pkgs.thunderbird217 pkgs.emacs
···22 a dependency on GTK 2. If you want to build it against GTK 3, you23 can specify that as follows:24 </para>25- <programlisting language="bash">26environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ];27</programlisting>28 <para>···46 the package, such as the source code. For instance, if you want to47 override the source code of Emacs, you can say:48 </para>49- <programlisting language="bash">50environment.systemPackages = [51 (pkgs.emacs.overrideAttrs (oldAttrs: {52 name = "emacs-25.0-pre";···72 everything depend on your customised instance, you can apply a73 <emphasis>global</emphasis> override as follows:74 </para>75- <programlisting language="bash">76nixpkgs.config.packageOverrides = pkgs:77 { emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };78 };
···22 a dependency on GTK 2. If you want to build it against GTK 3, you23 can specify that as follows:24 </para>25+ <programlisting language="nix">26environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ];27</programlisting>28 <para>···46 the package, such as the source code. For instance, if you want to47 override the source code of Emacs, you can say:48 </para>49+ <programlisting language="nix">50environment.systemPackages = [51 (pkgs.emacs.overrideAttrs (oldAttrs: {52 name = "emacs-25.0-pre";···72 everything depend on your customised instance, you can apply a73 <emphasis>global</emphasis> override as follows:74 </para>75+ <programlisting language="nix">76nixpkgs.config.packageOverrides = pkgs:77 { emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };78 };
···7 adding the following line to <literal>configuration.nix</literal>8 enables the Mozilla Thunderbird email application:9 </para>10- <programlisting language="bash">11environment.systemPackages = [ pkgs.thunderbird ];12</programlisting>13 <para>
···7 adding the following line to <literal>configuration.nix</literal>8 enables the Mozilla Thunderbird email application:9 </para>10+ <programlisting language="nix">11environment.systemPackages = [ pkgs.thunderbird ];12</programlisting>13 <para>
···6 both IPv4 and IPv6 traffic. It is enabled by default. It can be7 disabled as follows:8 </para>9- <programlisting language="bash">10networking.firewall.enable = false;11</programlisting>12 <para>13 If the firewall is enabled, you can open specific TCP ports to the14 outside world:15 </para>16- <programlisting language="bash">17networking.firewall.allowedTCPPorts = [ 80 443 ];18</programlisting>19 <para>···26 <para>27 To open ranges of TCP ports:28 </para>29- <programlisting language="bash">30networking.firewall.allowedTCPPortRanges = [31 { from = 4000; to = 4007; }32 { from = 8000; to = 8010; }
···6 both IPv4 and IPv6 traffic. It is enabled by default. It can be7 disabled as follows:8 </para>9+ <programlisting language="nix">10networking.firewall.enable = false;11</programlisting>12 <para>13 If the firewall is enabled, you can open specific TCP ports to the14 outside world:15 </para>16+ <programlisting language="nix">17networking.firewall.allowedTCPPorts = [ 80 443 ];18</programlisting>19 <para>···26 <para>27 To open ranges of TCP ports:28 </para>29+ <programlisting language="nix">30networking.firewall.allowedTCPPortRanges = [31 { from = 4000; to = 4007; }32 { from = 8000; to = 8010; }
···62 <xref linkend="opt-hardware.opengl.extraPackages" /> enables63 OpenCL support:64 </para>65- <programlisting language="bash">66hardware.opengl.extraPackages = [67 rocm-opencl-icd68];···85 enable OpenCL support. For example, for Gen8 and later GPUs, the86 following configuration can be used:87 </para>88- <programlisting language="bash">89hardware.opengl.extraPackages = [90 intel-compute-runtime91];···162 makes amdvlk the default driver and hides radv and lavapipe from163 the device list. A specific driver can be forced as follows:164 </para>165- <programlisting language="bash">166hardware.opengl.extraPackages = [167 pkgs.amdvlk168];···206 Modern Intel GPUs use the iHD driver, which can be installed207 with:208 </para>209- <programlisting language="bash">210hardware.opengl.extraPackages = [211 intel-media-driver212];···215 Older Intel GPUs use the i965 driver, which can be installed216 with:217 </para>218- <programlisting language="bash">219hardware.opengl.extraPackages = [220 vaapiIntel221];
···62 <xref linkend="opt-hardware.opengl.extraPackages" /> enables63 OpenCL support:64 </para>65+ <programlisting language="nix">66hardware.opengl.extraPackages = [67 rocm-opencl-icd68];···85 enable OpenCL support. For example, for Gen8 and later GPUs, the86 following configuration can be used:87 </para>88+ <programlisting language="nix">89hardware.opengl.extraPackages = [90 intel-compute-runtime91];···162 makes amdvlk the default driver and hides radv and lavapipe from163 the device list. A specific driver can be forced as follows:164 </para>165+ <programlisting language="nix">166hardware.opengl.extraPackages = [167 pkgs.amdvlk168];···206 Modern Intel GPUs use the iHD driver, which can be installed207 with:208 </para>209+ <programlisting language="nix">210hardware.opengl.extraPackages = [211 intel-media-driver212];···215 Older Intel GPUs use the i965 driver, which can be installed216 with:217 </para>218+ <programlisting language="nix">219hardware.opengl.extraPackages = [220 vaapiIntel221];
···6 interfaces. However, you can configure an interface manually as7 follows:8 </para>9- <programlisting language="bash">10networking.interfaces.eth0.ipv4.addresses = [ {11 address = "192.168.1.2";12 prefixLength = 24;···16 Typically you’ll also want to set a default gateway and set of name17 servers:18 </para>19- <programlisting language="bash">20networking.defaultGateway = "192.168.1.1";21networking.nameservers = [ "8.8.8.8" ];22</programlisting>···32 The host name is set using33 <xref linkend="opt-networking.hostName" />:34 </para>35- <programlisting language="bash">36networking.hostName = "cartman";37</programlisting>38 <para>
···6 interfaces. However, you can configure an interface manually as7 follows:8 </para>9+ <programlisting language="nix">10networking.interfaces.eth0.ipv4.addresses = [ {11 address = "192.168.1.2";12 prefixLength = 24;···16 Typically you’ll also want to set a default gateway and set of name17 servers:18 </para>19+ <programlisting language="nix">20networking.defaultGateway = "192.168.1.1";21networking.nameservers = [ "8.8.8.8" ];22</programlisting>···32 The host name is set using33 <xref linkend="opt-networking.hostName" />:34 </para>35+ <programlisting language="nix">36networking.hostName = "cartman";37</programlisting>38 <para>
···10 <xref linkend="opt-networking.interfaces._name_.tempAddress" />. You11 can disable IPv6 support globally by setting:12 </para>13- <programlisting language="bash">14networking.enableIPv6 = false;15</programlisting>16 <para>17 You can disable IPv6 on a single interface using a normal sysctl (in18 this example, we use interface <literal>eth0</literal>):19 </para>20- <programlisting language="bash">21boot.kernel.sysctl."net.ipv6.conf.eth0.disable_ipv6" = true;22</programlisting>23 <para>24 As with IPv4 networking interfaces are automatically configured via25 DHCPv6. You can configure an interface manually:26 </para>27- <programlisting language="bash">28networking.interfaces.eth0.ipv6.addresses = [ {29 address = "fe00:aa:bb:cc::2";30 prefixLength = 64;···34 For configuring a gateway, optionally with explicitly specified35 interface:36 </para>37- <programlisting language="bash">38networking.defaultGateway6 = {39 address = "fe00::1";40 interface = "enp0s3";
···10 <xref linkend="opt-networking.interfaces._name_.tempAddress" />. You11 can disable IPv6 support globally by setting:12 </para>13+ <programlisting language="nix">14networking.enableIPv6 = false;15</programlisting>16 <para>17 You can disable IPv6 on a single interface using a normal sysctl (in18 this example, we use interface <literal>eth0</literal>):19 </para>20+ <programlisting language="nix">21boot.kernel.sysctl."net.ipv6.conf.eth0.disable_ipv6" = true;22</programlisting>23 <para>24 As with IPv4 networking interfaces are automatically configured via25 DHCPv6. You can configure an interface manually:26 </para>27+ <programlisting language="nix">28networking.interfaces.eth0.ipv6.addresses = [ {29 address = "fe00:aa:bb:cc::2";30 prefixLength = 64;···34 For configuring a gateway, optionally with explicitly specified35 interface:36 </para>37+ <programlisting language="nix">38networking.defaultGateway6 = {39 address = "fe00::1";40 interface = "enp0s3";
···10 way is to enable and configure cluster components appropriately by11 hand:12 </para>13- <programlisting language="bash">14services.kubernetes = {15 apiserver.enable = true;16 controllerManager.enable = true;···25 <quote>node</quote>) to the host. This enables apiserver,26 controllerManager, scheduler, addonManager, kube-proxy and etcd:27 </para>28- <programlisting language="bash">29services.kubernetes.roles = [ "master" ];30</programlisting>31 <para>32 While this will enable the kubelet and kube-proxy only:33 </para>34- <programlisting language="bash">35services.kubernetes.roles = [ "node" ];36</programlisting>37 <para>38 Assigning both the master and node roles is usable if you want a39 single node Kubernetes cluster for dev or testing purposes:40 </para>41- <programlisting language="bash">42services.kubernetes.roles = [ "master" "node" ];43</programlisting>44 <para>
···10 way is to enable and configure cluster components appropriately by11 hand:12 </para>13+ <programlisting language="nix">14services.kubernetes = {15 apiserver.enable = true;16 controllerManager.enable = true;···25 <quote>node</quote>) to the host. This enables apiserver,26 controllerManager, scheduler, addonManager, kube-proxy and etcd:27 </para>28+ <programlisting language="nix">29services.kubernetes.roles = [ "master" ];30</programlisting>31 <para>32 While this will enable the kubelet and kube-proxy only:33 </para>34+ <programlisting language="nix">35services.kubernetes.roles = [ "node" ];36</programlisting>37 <para>38 Assigning both the master and node roles is usable if you want a39 single node Kubernetes cluster for dev or testing purposes:40 </para>41+ <programlisting language="nix">42services.kubernetes.roles = [ "master" "node" ];43</programlisting>44 <para>
···5 option <literal>boot.kernelPackages</literal>. For instance, this6 selects the Linux 3.10 kernel:7 </para>8- <programlisting language="bash">9boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_10;10</programlisting>11 <para>···48 <xref linkend="sec-customising-packages" />). For instance, to49 enable support for the kernel debugger KGDB:50 </para>51- <programlisting language="bash">52nixpkgs.config.packageOverrides = pkgs: pkgs.lib.recursiveUpdate pkgs {53 linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override {54 extraConfig = ''···69 automatically by <literal>udev</literal>. You can force a module to70 be loaded via <xref linkend="opt-boot.kernelModules" />, e.g.71 </para>72- <programlisting language="bash">73boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];74</programlisting>75 <para>···77 root file system), you can use78 <xref linkend="opt-boot.initrd.kernelModules" />:79 </para>80- <programlisting language="bash">81boot.initrd.kernelModules = [ "cifs" ];82</programlisting>83 <para>···88 Kernel runtime parameters can be set through89 <xref linkend="opt-boot.kernel.sysctl" />, e.g.90 </para>91- <programlisting language="bash">92boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120;93</programlisting>94 <para>···101 You can customize the default kernel configuration by overriding102 the arguments for your kernel package:103 </para>104- <programlisting language="bash">105pkgs.linux_latest.override {106 ignoreConfigErrors = true;107 autoModules = false;···126 <para>127 To use your custom kernel package in your NixOS configuration, set128 </para>129- <programlisting language="bash">130boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel;131</programlisting>132 <para>···139 a kernel that uses it with140 <literal>pkgs.linuxManualConfig</literal>:141 </para>142- <programlisting language="bash">143let144 baseKernel = pkgs.linux_latest;145in pkgs.linuxManualConfig {···198 available kernel version <emphasis>that is supported by199 ZFS</emphasis> like this:200 </para>201- <programlisting language="bash">202{203 boot.kernelPackages = pkgs.zfs.latestCompatibleLinuxPackages;204}
···5 option <literal>boot.kernelPackages</literal>. For instance, this6 selects the Linux 3.10 kernel:7 </para>8+ <programlisting language="nix">9boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_10;10</programlisting>11 <para>···48 <xref linkend="sec-customising-packages" />). For instance, to49 enable support for the kernel debugger KGDB:50 </para>51+ <programlisting language="nix">52nixpkgs.config.packageOverrides = pkgs: pkgs.lib.recursiveUpdate pkgs {53 linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override {54 extraConfig = ''···69 automatically by <literal>udev</literal>. You can force a module to70 be loaded via <xref linkend="opt-boot.kernelModules" />, e.g.71 </para>72+ <programlisting language="nix">73boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];74</programlisting>75 <para>···77 root file system), you can use78 <xref linkend="opt-boot.initrd.kernelModules" />:79 </para>80+ <programlisting language="nix">81boot.initrd.kernelModules = [ "cifs" ];82</programlisting>83 <para>···88 Kernel runtime parameters can be set through89 <xref linkend="opt-boot.kernel.sysctl" />, e.g.90 </para>91+ <programlisting language="nix">92boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120;93</programlisting>94 <para>···101 You can customize the default kernel configuration by overriding102 the arguments for your kernel package:103 </para>104+ <programlisting language="nix">105pkgs.linux_latest.override {106 ignoreConfigErrors = true;107 autoModules = false;···126 <para>127 To use your custom kernel package in your NixOS configuration, set128 </para>129+ <programlisting language="nix">130boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel;131</programlisting>132 <para>···139 a kernel that uses it with140 <literal>pkgs.linuxManualConfig</literal>:141 </para>142+ <programlisting language="nix">143let144 baseKernel = pkgs.linux_latest;145in pkgs.linuxManualConfig {···198 available kernel version <emphasis>that is supported by199 ZFS</emphasis> like this:200 </para>201+ <programlisting language="nix">202{203 boot.kernelPackages = pkgs.zfs.latestCompatibleLinuxPackages;204}
···30 at boot time as <literal>/</literal>, add the following to31 <literal>configuration.nix</literal>:32 </para>33- <programlisting language="bash">34boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d";35fileSystems."/".device = "/dev/mapper/crypted";36</programlisting>···39 located on an encrypted partition, it is necessary to add the40 following grub option:41 </para>42- <programlisting language="bash">43boot.loader.grub.enableCryptodisk = true;44</programlisting>45 <section xml:id="sec-luks-file-systems-fido2">···67 compatible key, add the following to68 <literal>configuration.nix</literal>:69 </para>70- <programlisting language="bash">71boot.initrd.luks.fido2Support = true;72boot.initrd.luks.devices."/dev/sda2".fido2.credential = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";73</programlisting>···77 protected, such as78 <link xlink:href="https://trezor.io/">Trezor</link>.79 </para>80- <programlisting language="bash">81boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess = true;82</programlisting>83 </section>
···30 at boot time as <literal>/</literal>, add the following to31 <literal>configuration.nix</literal>:32 </para>33+ <programlisting language="nix">34boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d";35fileSystems."/".device = "/dev/mapper/crypted";36</programlisting>···39 located on an encrypted partition, it is necessary to add the40 following grub option:41 </para>42+ <programlisting language="nix">43boot.loader.grub.enableCryptodisk = true;44</programlisting>45 <section xml:id="sec-luks-file-systems-fido2">···67 compatible key, add the following to68 <literal>configuration.nix</literal>:69 </para>70+ <programlisting language="nix">71boot.initrd.luks.fido2Support = true;72boot.initrd.luks.devices."/dev/sda2".fido2.credential = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";73</programlisting>···77 protected, such as78 <link xlink:href="https://trezor.io/">Trezor</link>.79 </para>80+ <programlisting language="nix">81boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess = true;82</programlisting>83 </section>
···14 other modules by including them from15 <literal>configuration.nix</literal>, e.g.:16 </para>17- <programlisting language="bash">18{ config, pkgs, ... }:1920{ imports = [ ./vpn.nix ./kde.nix ];···28 <literal>vpn.nix</literal> and <literal>kde.nix</literal>. The29 latter might look like this:30 </para>31- <programlisting language="bash">32{ config, pkgs, ... }:3334{ services.xserver.enable = true;···50 you want it to appear first, you can use51 <literal>mkBefore</literal>:52 </para>53- <programlisting language="bash">54boot.kernelModules = mkBefore [ "kvm-intel" ];55</programlisting>56 <para>···70 When that happens, it’s possible to force one definition take71 precedence over the others:72 </para>73- <programlisting language="bash">74services.httpd.adminAddr = pkgs.lib.mkForce "bob@example.org";75</programlisting>76 <para>···93 <xref linkend="opt-services.xserver.enable" /> is set to94 <literal>true</literal> somewhere else:95 </para>96- <programlisting language="bash">97{ config, pkgs, ... }:9899{ environment.systemPackages =···137 below would have the same effect as importing a file which sets138 those options.139 </para>140- <programlisting language="bash">141{ config, pkgs, ... }:142143let netConfig = hostName: {
···14 other modules by including them from15 <literal>configuration.nix</literal>, e.g.:16 </para>17+ <programlisting language="nix">18{ config, pkgs, ... }:1920{ imports = [ ./vpn.nix ./kde.nix ];···28 <literal>vpn.nix</literal> and <literal>kde.nix</literal>. The29 latter might look like this:30 </para>31+ <programlisting language="nix">32{ config, pkgs, ... }:3334{ services.xserver.enable = true;···50 you want it to appear first, you can use51 <literal>mkBefore</literal>:52 </para>53+ <programlisting language="nix">54boot.kernelModules = mkBefore [ "kvm-intel" ];55</programlisting>56 <para>···70 When that happens, it’s possible to force one definition take71 precedence over the others:72 </para>73+ <programlisting language="nix">74services.httpd.adminAddr = pkgs.lib.mkForce "bob@example.org";75</programlisting>76 <para>···93 <xref linkend="opt-services.xserver.enable" /> is set to94 <literal>true</literal> somewhere else:95 </para>96+ <programlisting language="nix">97{ config, pkgs, ... }:9899{ environment.systemPackages =···137 below would have the same effect as importing a file which sets138 those options.139 </para>140+ <programlisting language="nix">141{ config, pkgs, ... }:142143let netConfig = hostName: {
···4 To facilitate network configuration, some desktop environments use5 NetworkManager. You can enable NetworkManager by setting:6 </para>7- <programlisting language="bash">8networking.networkmanager.enable = true;9</programlisting>10 <para>···15 All users that should have permission to change network settings16 must belong to the <literal>networkmanager</literal> group:17 </para>18- <programlisting language="bash">19users.users.alice.extraGroups = [ "networkmanager" ];20</programlisting>21 <para>···36 used together if desired. To do this you need to instruct37 NetworkManager to ignore those interfaces like:38 </para>39- <programlisting language="bash">40networking.networkmanager.unmanaged = [41 "*" "except:type:wwan" "except:type:gsm"42];
···4 To facilitate network configuration, some desktop environments use5 NetworkManager. You can enable NetworkManager by setting:6 </para>7+ <programlisting language="nix">8networking.networkmanager.enable = true;9</programlisting>10 <para>···15 All users that should have permission to change network settings16 must belong to the <literal>networkmanager</literal> group:17 </para>18+ <programlisting language="nix">19users.users.alice.extraGroups = [ "networkmanager" ];20</programlisting>21 <para>···36 used together if desired. To do this you need to instruct37 NetworkManager to ignore those interfaces like:38 </para>39+ <programlisting language="nix">40networking.networkmanager.unmanaged = [41 "*" "except:type:wwan" "except:type:gsm"42];
···9 to say, expected usage is to add them to the imports list of your10 <literal>/etc/configuration.nix</literal> as such:11 </para>12- <programlisting language="bash">13imports = [14 <nixpkgs/nixos/modules/profiles/profile-name.nix>15];
···9 to say, expected usage is to add them to the imports list of your10 <literal>/etc/configuration.nix</literal> as such:11 </para>12+ <programlisting language="nix">13imports = [14 <nixpkgs/nixos/modules/profiles/profile-name.nix>15];
···30 the interface with MAC address31 <literal>52:54:00:12:01:01</literal> using a netword link unit:32 </para>33- <programlisting language="bash">34systemd.network.links."10-wan" = {35 matchConfig.PermanentMACAddress = "52:54:00:12:01:01";36 linkConfig.Name = "wan";···43 <para>44 Alternatively, we can use a plain old udev rule:45 </para>46- <programlisting language="bash">47services.udev.initrdRules = ''48 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \49 ATTR{address}=="52:54:00:12:01:01", KERNEL=="eth*", NAME="wan"
···30 the interface with MAC address31 <literal>52:54:00:12:01:01</literal> using a netword link unit:32 </para>33+ <programlisting language="nix">34systemd.network.links."10-wan" = {35 matchConfig.PermanentMACAddress = "52:54:00:12:01:01";36 linkConfig.Name = "wan";···43 <para>44 Alternatively, we can use a plain old udev rule:45 </para>46+ <programlisting language="nix">47services.udev.initrdRules = ''48 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \49 ATTR{address}=="52:54:00:12:01:01", KERNEL=="eth*", NAME="wan"
···3 <para>4 Secure shell (SSH) access to your machine can be enabled by setting:5 </para>6- <programlisting language="bash">7services.openssh.enable = true;8</programlisting>9 <para>···16 You can declaratively specify authorised RSA/DSA public keys for a17 user as follows:18 </para>19- <programlisting language="bash">20users.users.alice.openssh.authorizedKeys.keys =21 [ "ssh-dss AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];22</programlisting>
···3 <para>4 Secure shell (SSH) access to your machine can be enabled by setting:5 </para>6+ <programlisting language="nix">7services.openssh.enable = true;8</programlisting>9 <para>···16 You can declaratively specify authorised RSA/DSA public keys for a17 user as follows:18 </para>19+ <programlisting language="nix">20users.users.alice.openssh.authorizedKeys.keys =21 [ "ssh-dss AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];22</programlisting>
···54 <link linkend="opt-fileSystems">fileSystems</link> option. Here’s55 a typical setup:56 </para>57- <programlisting language="bash">58{59 system.fsPackages = [ pkgs.sshfs ];60···80 well, for example you can change the default SSH port or specify a81 jump proxy:82 </para>83- <programlisting language="bash">84{85 options =86 [ "ProxyJump=bastion@example.com"···92 It’s also possible to change the <literal>ssh</literal> command93 used by SSHFS to connect to the server. For example:94 </para>95- <programlisting language="bash">96{97 options =98 [ (builtins.replaceStrings [" "] ["\\040"]
···54 <link linkend="opt-fileSystems">fileSystems</link> option. Here’s55 a typical setup:56 </para>57+ <programlisting language="nix">58{59 system.fsPackages = [ pkgs.sshfs ];60···80 well, for example you can change the default SSH port or specify a81 jump proxy:82 </para>83+ <programlisting language="nix">84{85 options =86 [ "ProxyJump=bastion@example.com"···92 It’s also possible to change the <literal>ssh</literal> command93 used by SSHFS to connect to the server. For example:94 </para>95+ <programlisting language="nix">96{97 options =98 [ (builtins.replaceStrings [" "] ["\\040"]
···7 states that a user account named <literal>alice</literal> shall8 exist:9 </para>10- <programlisting language="bash">11users.users.alice = {12 isNormalUser = true;13 home = "/home/alice";···45 A user ID (uid) is assigned automatically. You can also specify a46 uid manually by adding47 </para>48- <programlisting language="bash">49uid = 1000;50</programlisting>51 <para>···55 Groups can be specified similarly. The following states that a group56 named <literal>students</literal> shall exist:57 </para>58- <programlisting language="bash">59users.groups.students.gid = 1000;60</programlisting>61 <para>
···7 states that a user account named <literal>alice</literal> shall8 exist:9 </para>10+ <programlisting language="nix">11users.users.alice = {12 isNormalUser = true;13 home = "/home/alice";···45 A user ID (uid) is assigned automatically. You can also specify a46 uid manually by adding47 </para>48+ <programlisting language="nix">49uid = 1000;50</programlisting>51 <para>···55 Groups can be specified similarly. The following states that a group56 named <literal>students</literal> shall exist:57 </para>58+ <programlisting language="nix">59users.groups.students.gid = 1000;60</programlisting>61 <para>
···10 Compositor such as sway without separately enabling a Wayland11 server:12 </para>13- <programlisting language="bash">14programs.sway.enable = true;15</programlisting>16 <para>···22 be able to share your screen, you might want to activate this23 option:24 </para>25- <programlisting language="bash">26xdg.portal.wlr.enable = true;27</programlisting>28 <para>
···10 Compositor such as sway without separately enabling a Wayland11 server:12 </para>13+ <programlisting language="nix">14programs.sway.enable = true;15</programlisting>16 <para>···22 be able to share your screen, you might want to activate this23 option:24 </para>25+ <programlisting language="nix">26xdg.portal.wlr.enable = true;27</programlisting>28 <para>
···9 <para>10 NixOS will start wpa_supplicant for you if you enable this setting:11 </para>12- <programlisting language="bash">13networking.wireless.enable = true;14</programlisting>15 <para>16 NixOS lets you specify networks for wpa_supplicant declaratively:17 </para>18- <programlisting language="bash">19networking.wireless.networks = {20 echelon = { # SSID with no spaces or special characters21 psk = "abcdefgh";···49 psk=dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c543550}51</programlisting>52- <programlisting language="bash">53networking.wireless.networks = {54 echelon = {55 pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435";
···9 <para>10 NixOS will start wpa_supplicant for you if you enable this setting:11 </para>12+ <programlisting language="nix">13networking.wireless.enable = true;14</programlisting>15 <para>16 NixOS lets you specify networks for wpa_supplicant declaratively:17 </para>18+ <programlisting language="nix">19networking.wireless.networks = {20 echelon = { # SSID with no spaces or special characters21 psk = "abcdefgh";···49 psk=dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c543550}51</programlisting>52+ <programlisting language="nix">53networking.wireless.networks = {54 echelon = {55 pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435";
···4 The X Window System (X11) provides the basis of NixOS’ graphical5 user interface. It can be enabled as follows:6 </para>7- <programlisting language="bash">8services.xserver.enable = true;9</programlisting>10 <para>···13 and <literal>intel</literal>). You can also specify a driver14 manually, e.g.15 </para>16- <programlisting language="bash">17services.xserver.videoDrivers = [ "r128" ];18</programlisting>19 <para>···25 <literal>xterm</literal> window. Thus you should pick one or more of26 the following lines:27 </para>28- <programlisting language="bash">29services.xserver.desktopManager.plasma5.enable = true;30services.xserver.desktopManager.xfce.enable = true;31services.xserver.desktopManager.gnome.enable = true;···42 LightDM. You can select an alternative one by picking one of the43 following lines:44 </para>45- <programlisting language="bash">46services.xserver.displayManager.sddm.enable = true;47services.xserver.displayManager.gdm.enable = true;48</programlisting>49 <para>50 You can set the keyboard layout (and optionally the layout variant):51 </para>52- <programlisting language="bash">53services.xserver.layout = "de";54services.xserver.xkbVariant = "neo";55</programlisting>···57 The X server is started automatically at boot time. If you don’t58 want this to happen, you can set:59 </para>60- <programlisting language="bash">61services.xserver.autorun = false;62</programlisting>63 <para>···70 On 64-bit systems, if you want OpenGL for 32-bit programs such as in71 Wine, you should also set the following:72 </para>73- <programlisting language="bash">74hardware.opengl.driSupport32Bit = true;75</programlisting>76 <section xml:id="sec-x11-auto-login">···90 manager and desktop environment. If you wanted no desktop91 environment and i3 as your your window manager, you’d define:92 </para>93- <programlisting language="bash">94services.xserver.displayManager.defaultSession = "none+i3";95</programlisting>96 <para>97 Every display manager in NixOS supports auto-login, here is an98 example using lightdm for a user <literal>alice</literal>:99 </para>100- <programlisting language="bash">101services.xserver.displayManager.lightdm.enable = true;102services.xserver.displayManager.autoLogin.enable = true;103services.xserver.displayManager.autoLogin.user = "alice";···131 <xref linkend="opt-services.xserver.videoDrivers" /> to set one.132 The recommended configuration for modern systems is:133 </para>134- <programlisting language="bash">135services.xserver.videoDrivers = [ "modesetting" ];136</programlisting>137 <para>138 If you experience screen tearing no matter what, this139 configuration was reported to resolve the issue:140 </para>141- <programlisting language="bash">142services.xserver.videoDrivers = [ "intel" ];143services.xserver.deviceSection = ''144 Option "DRI" "2"···159 enabled by default because it’s not free software. You can enable160 it as follows:161 </para>162- <programlisting language="bash">163services.xserver.videoDrivers = [ "nvidia" ];164</programlisting>165 <para>166 Or if you have an older card, you may have to use one of the167 legacy drivers:168 </para>169- <programlisting language="bash">170services.xserver.videoDrivers = [ "nvidiaLegacy390" ];171services.xserver.videoDrivers = [ "nvidiaLegacy340" ];172services.xserver.videoDrivers = [ "nvidiaLegacy304" ];···185 features or performance. If you still want to use it anyway, you186 need to explicitly set:187 </para>188- <programlisting language="bash">189services.xserver.videoDrivers = [ "amdgpu-pro" ];190</programlisting>191 <para>···199 Support for Synaptics touchpads (found in many laptops such as the200 Dell Latitude series) can be enabled as follows:201 </para>202- <programlisting language="bash">203services.xserver.libinput.enable = true;204</programlisting>205 <para>206 The driver has many options (see <xref linkend="ch-options" />).207 For instance, the following disables tap-to-click behavior:208 </para>209- <programlisting language="bash">210services.xserver.libinput.touchpad.tapping = false;211</programlisting>212 <para>···222 applications look similar to GTK ones, you can use the following223 configuration:224 </para>225- <programlisting language="bash">226qt5.enable = true;227qt5.platformTheme = "gtk2";228qt5.style = "gtk2";···247 <literal>symbols</literal>; it’s an XKB peculiarity that will help248 with testing):249 </para>250- <programlisting language="bash">251xkb_symbols "us-greek"252{253 include "us(basic)" // includes the base US keys···263 <para>264 A minimal layout specification must include the following:265 </para>266- <programlisting language="bash">267services.xserver.extraLayouts.us-greek = {268 description = "US layout with alt-gr greek";269 languages = [ "eng" ];···312 interest, then create a <literal>media-key</literal> file to hold313 the keycodes definitions314 </para>315- <programlisting language="bash">316xkb_keycodes "media"317{318 <volUp> = 123;···322 <para>323 Now use the newly define keycodes in <literal>media-sym</literal>:324 </para>325- <programlisting language="bash">326xkb_symbols "media"327{328 key.type = "ONE_LEVEL";···333 <para>334 As before, to install the layout do335 </para>336- <programlisting language="bash">337services.xserver.extraLayouts.media = {338 description = "Multimedia keys remapping";339 languages = [ "eng" ];···357 default. As a workaround, you can set the keymap using358 <literal>setxkbmap</literal> at the start of the session with:359 </para>360- <programlisting language="bash">361services.xserver.displayManager.sessionCommands = "setxkbmap -keycodes media";362</programlisting>363 <para>
···4 The X Window System (X11) provides the basis of NixOS’ graphical5 user interface. It can be enabled as follows:6 </para>7+ <programlisting language="nix">8services.xserver.enable = true;9</programlisting>10 <para>···13 and <literal>intel</literal>). You can also specify a driver14 manually, e.g.15 </para>16+ <programlisting language="nix">17services.xserver.videoDrivers = [ "r128" ];18</programlisting>19 <para>···25 <literal>xterm</literal> window. Thus you should pick one or more of26 the following lines:27 </para>28+ <programlisting language="nix">29services.xserver.desktopManager.plasma5.enable = true;30services.xserver.desktopManager.xfce.enable = true;31services.xserver.desktopManager.gnome.enable = true;···42 LightDM. You can select an alternative one by picking one of the43 following lines:44 </para>45+ <programlisting language="nix">46services.xserver.displayManager.sddm.enable = true;47services.xserver.displayManager.gdm.enable = true;48</programlisting>49 <para>50 You can set the keyboard layout (and optionally the layout variant):51 </para>52+ <programlisting language="nix">53services.xserver.layout = "de";54services.xserver.xkbVariant = "neo";55</programlisting>···57 The X server is started automatically at boot time. If you don’t58 want this to happen, you can set:59 </para>60+ <programlisting language="nix">61services.xserver.autorun = false;62</programlisting>63 <para>···70 On 64-bit systems, if you want OpenGL for 32-bit programs such as in71 Wine, you should also set the following:72 </para>73+ <programlisting language="nix">74hardware.opengl.driSupport32Bit = true;75</programlisting>76 <section xml:id="sec-x11-auto-login">···90 manager and desktop environment. If you wanted no desktop91 environment and i3 as your your window manager, you’d define:92 </para>93+ <programlisting language="nix">94services.xserver.displayManager.defaultSession = "none+i3";95</programlisting>96 <para>97 Every display manager in NixOS supports auto-login, here is an98 example using lightdm for a user <literal>alice</literal>:99 </para>100+ <programlisting language="nix">101services.xserver.displayManager.lightdm.enable = true;102services.xserver.displayManager.autoLogin.enable = true;103services.xserver.displayManager.autoLogin.user = "alice";···131 <xref linkend="opt-services.xserver.videoDrivers" /> to set one.132 The recommended configuration for modern systems is:133 </para>134+ <programlisting language="nix">135services.xserver.videoDrivers = [ "modesetting" ];136</programlisting>137 <para>138 If you experience screen tearing no matter what, this139 configuration was reported to resolve the issue:140 </para>141+ <programlisting language="nix">142services.xserver.videoDrivers = [ "intel" ];143services.xserver.deviceSection = ''144 Option "DRI" "2"···159 enabled by default because it’s not free software. You can enable160 it as follows:161 </para>162+ <programlisting language="nix">163services.xserver.videoDrivers = [ "nvidia" ];164</programlisting>165 <para>166 Or if you have an older card, you may have to use one of the167 legacy drivers:168 </para>169+ <programlisting language="nix">170services.xserver.videoDrivers = [ "nvidiaLegacy390" ];171services.xserver.videoDrivers = [ "nvidiaLegacy340" ];172services.xserver.videoDrivers = [ "nvidiaLegacy304" ];···185 features or performance. If you still want to use it anyway, you186 need to explicitly set:187 </para>188+ <programlisting language="nix">189services.xserver.videoDrivers = [ "amdgpu-pro" ];190</programlisting>191 <para>···199 Support for Synaptics touchpads (found in many laptops such as the200 Dell Latitude series) can be enabled as follows:201 </para>202+ <programlisting language="nix">203services.xserver.libinput.enable = true;204</programlisting>205 <para>206 The driver has many options (see <xref linkend="ch-options" />).207 For instance, the following disables tap-to-click behavior:208 </para>209+ <programlisting language="nix">210services.xserver.libinput.touchpad.tapping = false;211</programlisting>212 <para>···222 applications look similar to GTK ones, you can use the following223 configuration:224 </para>225+ <programlisting language="nix">226qt5.enable = true;227qt5.platformTheme = "gtk2";228qt5.style = "gtk2";···247 <literal>symbols</literal>; it’s an XKB peculiarity that will help248 with testing):249 </para>250+ <programlisting language="nix">251xkb_symbols "us-greek"252{253 include "us(basic)" // includes the base US keys···263 <para>264 A minimal layout specification must include the following:265 </para>266+ <programlisting language="nix">267services.xserver.extraLayouts.us-greek = {268 description = "US layout with alt-gr greek";269 languages = [ "eng" ];···312 interest, then create a <literal>media-key</literal> file to hold313 the keycodes definitions314 </para>315+ <programlisting language="nix">316xkb_keycodes "media"317{318 <volUp> = 123;···322 <para>323 Now use the newly define keycodes in <literal>media-sym</literal>:324 </para>325+ <programlisting language="nix">326xkb_symbols "media"327{328 key.type = "ONE_LEVEL";···333 <para>334 As before, to install the layout do335 </para>336+ <programlisting language="nix">337services.xserver.extraLayouts.media = {338 description = "Multimedia keys remapping";339 languages = [ "eng" ];···357 default. As a workaround, you can set the keymap using358 <literal>setxkbmap</literal> at the start of the session with:359 </para>360+ <programlisting language="nix">361services.xserver.displayManager.sessionCommands = "setxkbmap -keycodes media";362</programlisting>363 <para>
···22 these dependencies into account and order the snippets accordingly.23 As a simple example:24 </para>25- <programlisting language="bash">26system.activationScripts.my-activation-script = {27 deps = [ "etc" ];28 # supportsDryActivation = true;
···22 these dependencies into account and order the snippets accordingly.23 As a simple example:24 </para>25+ <programlisting language="nix">26system.activationScripts.my-activation-script = {27 deps = [ "etc" ];28 # supportsDryActivation = true;
···18 <para>19 This is an example of using <literal>warnings</literal>.20 </para>21- <programlisting language="bash">22{ config, lib, ... }:23{24 config = lib.mkIf config.services.foo.enable {···42 assertion is useful to prevent such a broken system from being43 built.44 </para>45- <programlisting language="bash">46{ config, lib, ... }:47{48 config = lib.mkIf config.services.syslogd.enable {
···18 <para>19 This is an example of using <literal>warnings</literal>.20 </para>21+ <programlisting language="nix">22{ config, lib, ... }:23{24 config = lib.mkIf config.services.foo.enable {···42 assertion is useful to prevent such a broken system from being43 built.44 </para>45+ <programlisting language="nix">46{ config, lib, ... }:47{48 config = lib.mkIf config.services.syslogd.enable {
···30 type-checked <literal>settings</literal> attribute</link> for a more31 complete example.32 </para>33- <programlisting language="bash">34{ lib, config, ... }: {3536 options.settings = lib.mkOption {···52 <para>53 And the following shows what such a module then allows54 </para>55- <programlisting language="bash">56{57 # Not a declared option, but the freeform type allows this58 settings.logLevel = "debug";···72 Freeform attributes cannot depend on other attributes of the same73 set without infinite recursion:74 </para>75- <programlisting language="bash">76{77 # This throws infinite recursion encountered78 settings.logLevel = lib.mkIf (config.settings.port == 80) "debug";
···30 type-checked <literal>settings</literal> attribute</link> for a more31 complete example.32 </para>33+ <programlisting language="nix">34{ lib, config, ... }: {3536 options.settings = lib.mkOption {···52 <para>53 And the following shows what such a module then allows54 </para>55+ <programlisting language="nix">56{57 # Not a declared option, but the freeform type allows this58 settings.logLevel = "debug";···72 Freeform attributes cannot depend on other attributes of the same73 set without infinite recursion:74 </para>75+ <programlisting language="nix">76{77 # This throws infinite recursion encountered78 settings.logLevel = lib.mkIf (config.settings.port == 80) "debug";
···4 Sometimes NixOS modules need to be used in configuration but exist5 outside of Nixpkgs. These modules can be imported:6 </para>7- <programlisting language="bash">8{ config, lib, pkgs, ... }:910{···23 Nixpkgs NixOS modules. Like any NixOS module, this module can import24 additional modules:25 </para>26- <programlisting language="bash">27# ./module-list/default.nix28[29 ./example-module130 ./example-module231]32</programlisting>33- <programlisting language="bash">34# ./extra-module/default.nix35{ imports = import ./module-list.nix; }36</programlisting>37- <programlisting language="bash">38# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module39{ config, lib, pkgs, ... }:40
···4 Sometimes NixOS modules need to be used in configuration but exist5 outside of Nixpkgs. These modules can be imported:6 </para>7+ <programlisting language="nix">8{ config, lib, pkgs, ... }:910{···23 Nixpkgs NixOS modules. Like any NixOS module, this module can import24 additional modules:25 </para>26+ <programlisting language="nix">27# ./module-list/default.nix28[29 ./example-module130 ./example-module231]32</programlisting>33+ <programlisting language="nix">34# ./extra-module/default.nix35{ imports = import ./module-list.nix; }36</programlisting>37+ <programlisting language="nix">38# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module39{ config, lib, pkgs, ... }:40
···15 Each of the meta-attributes must be defined at most once per module16 file.17 </para>18- <programlisting language="bash">19{ config, lib, pkgs, ... }:20{21 options = {
···15 Each of the meta-attributes must be defined at most once per module16 file.17 </para>18+ <programlisting language="nix">19{ config, lib, pkgs, ... }:20{21 options = {
···4 Option definitions are generally straight-forward bindings of values5 to option names, like6 </para>7- <programlisting language="bash">8config = {9 services.httpd.enable = true;10};···21 another option, you may need to use <literal>mkIf</literal>.22 Consider, for instance:23 </para>24- <programlisting language="bash">25config = if config.services.httpd.enable then {26 environment.systemPackages = [ ... ];27 ...···34 value being constructed here. After all, you could also write the35 clearly circular and contradictory:36 </para>37- <programlisting language="bash">38config = if config.services.httpd.enable then {39 services.httpd.enable = false;40} else {···44 <para>45 The solution is to write:46 </para>47- <programlisting language="bash">48config = mkIf config.services.httpd.enable {49 environment.systemPackages = [ ... ];50 ...···55 of the conditional to be <quote>pushed down</quote> into the56 individual definitions, as if you had written:57 </para>58- <programlisting language="bash">59config = {60 environment.systemPackages = if config.services.httpd.enable then [ ... ] else [];61 ...···72 option defaults have priority 1500. You can specify an explicit73 priority by using <literal>mkOverride</literal>, e.g.74 </para>75- <programlisting language="bash">76services.openssh.enable = mkOverride 10 false;77</programlisting>78 <para>···94 <literal>mkOrder 500</literal> and95 <literal>mkOrder 1500</literal>, respectively. As an example,96 </para>97- <programlisting language="bash">98hardware.firmware = mkBefore [ myFirmware ];99</programlisting>100 <para>···117 to be merged together as if they were declared in separate118 modules. This can be done using <literal>mkMerge</literal>:119 </para>120- <programlisting language="bash">121config = mkMerge122 [ # Unconditional stuff.123 { environment.systemPackages = [ ... ];
···4 Option definitions are generally straight-forward bindings of values5 to option names, like6 </para>7+ <programlisting language="nix">8config = {9 services.httpd.enable = true;10};···21 another option, you may need to use <literal>mkIf</literal>.22 Consider, for instance:23 </para>24+ <programlisting language="nix">25config = if config.services.httpd.enable then {26 environment.systemPackages = [ ... ];27 ...···34 value being constructed here. After all, you could also write the35 clearly circular and contradictory:36 </para>37+ <programlisting language="nix">38config = if config.services.httpd.enable then {39 services.httpd.enable = false;40} else {···44 <para>45 The solution is to write:46 </para>47+ <programlisting language="nix">48config = mkIf config.services.httpd.enable {49 environment.systemPackages = [ ... ];50 ...···55 of the conditional to be <quote>pushed down</quote> into the56 individual definitions, as if you had written:57 </para>58+ <programlisting language="nix">59config = {60 environment.systemPackages = if config.services.httpd.enable then [ ... ] else [];61 ...···72 option defaults have priority 1500. You can specify an explicit73 priority by using <literal>mkOverride</literal>, e.g.74 </para>75+ <programlisting language="nix">76services.openssh.enable = mkOverride 10 false;77</programlisting>78 <para>···94 <literal>mkOrder 500</literal> and95 <literal>mkOrder 1500</literal>, respectively. As an example,96 </para>97+ <programlisting language="nix">98hardware.firmware = mkBefore [ myFirmware ];99</programlisting>100 <para>···117 to be merged together as if they were declared in separate118 modules. This can be done using <literal>mkMerge</literal>:119 </para>120+ <programlisting language="nix">121config = mkMerge122 [ # Unconditional stuff.123 { environment.systemPackages = [ ... ];
···22 only overrides the module definition, this won’t use postgresql from23 nixos-unstable unless explicitly configured to do so.24 </para>25- <programlisting language="bash">26{ config, lib, pkgs, ... }:2728{···42 for an existing module. Importing this module will disable the43 original module without having to know its implementation details.44 </para>45- <programlisting language="bash">46{ config, lib, pkgs, ... }:4748with lib;
···22 only overrides the module definition, this won’t use postgresql from23 nixos-unstable unless explicitly configured to do so.24 </para>25+ <programlisting language="nix">26{ config, lib, pkgs, ... }:2728{···42 for an existing module. Importing this module will disable the43 original module without having to know its implementation details.44 </para>45+ <programlisting language="nix">46{ config, lib, pkgs, ... }:4748with lib;
···317 used, along with some other related best practices. See the318 comments for explanations.319 </para>320- <programlisting language="bash">321{ options, config, lib, pkgs, ... }:322let323 cfg = config.services.foo;···390 <emphasis role="strong">Example: Declaring a type-checked391 <literal>settings</literal> attribute</emphasis>392 </para>393- <programlisting language="bash">394settings = lib.mkOption {395 type = lib.types.submodule {396
···317 used, along with some other related best practices. See the318 comments for explanations.319 </para>320+ <programlisting language="nix">321{ options, config, lib, pkgs, ... }:322let323 cfg = config.services.foo;···390 <emphasis role="strong">Example: Declaring a type-checked391 <literal>settings</literal> attribute</emphasis>392 </para>393+ <programlisting language="nix">394settings = lib.mkOption {395 type = lib.types.submodule {396
···3 <para>4 A NixOS test is a module that has the following structure:5 </para>6- <programlisting language="bash">7{89 # One or more machines:···58 Tests that are part of NixOS are added to59 <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/all-tests.nix"><literal>nixos/tests/all-tests.nix</literal></link>.60 </para>61- <programlisting language="bash">62 hostname = runTest ./hostname.nix;63</programlisting>64 <para>65 Overrides can be added by defining an anonymous module in66 <literal>all-tests.nix</literal>.67 </para>68- <programlisting language="bash">69 hostname = runTest {70 imports = [ ./hostname.nix ];71 defaults.networking.firewall.enable = false;···87 Outside the <literal>nixpkgs</literal> repository, you can88 instantiate the test by first importing the NixOS library,89 </para>90- <programlisting language="bash">91let nixos-lib = import (nixpkgs + "/nixos/lib") { };92in93···633 For faster dev cycles it’s also possible to disable the634 code-linters (this shouldn’t be committed though):635 </para>636- <programlisting language="bash">637{638 skipLint = true;639 nodes.machine =···653 disable the Black linter directly (again, don’t commit this within654 the Nixpkgs repository):655 </para>656- <programlisting language="bash">657 testScript =658 ''659 # fmt: off···665 Similarly, the type checking of test scripts can be disabled in666 the following way:667 </para>668- <programlisting language="bash">669{670 skipTypeCheck = true;671 nodes.machine =···700 <literal>polling_condition</literal> takes the following701 (optional) arguments:702 </para>703- <para>704- <literal>seconds_interval</literal>705- </para>706- <para>707- : specifies how often the condition should be polled:708- </para>000000709 <programlisting language="python">710@polling_condition(seconds_interval=10)711def foo_running():712 machine.succeed("pgrep -x foo")713</programlisting>714- <para>715- <literal>description</literal>716- </para>717- <para>718- : is used in the log when the condition is checked. If this is not719- provided, the description is pulled from the docstring of the720- function. These two are therefore equivalent:721- </para>000000722 <programlisting language="python">723@polling_condition724def foo_running():···751 <literal>extraPythonPackages</literal>. For example, you could add752 <literal>numpy</literal> like this:753 </para>754- <programlisting language="bash">755{756 extraPythonPackages = p: [ p.numpy ];757
···3 <para>4 A NixOS test is a module that has the following structure:5 </para>6+ <programlisting language="nix">7{89 # One or more machines:···58 Tests that are part of NixOS are added to59 <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/all-tests.nix"><literal>nixos/tests/all-tests.nix</literal></link>.60 </para>61+ <programlisting language="nix">62 hostname = runTest ./hostname.nix;63</programlisting>64 <para>65 Overrides can be added by defining an anonymous module in66 <literal>all-tests.nix</literal>.67 </para>68+ <programlisting language="nix">69 hostname = runTest {70 imports = [ ./hostname.nix ];71 defaults.networking.firewall.enable = false;···87 Outside the <literal>nixpkgs</literal> repository, you can88 instantiate the test by first importing the NixOS library,89 </para>90+ <programlisting language="nix">91let nixos-lib = import (nixpkgs + "/nixos/lib") { };92in93···633 For faster dev cycles it’s also possible to disable the634 code-linters (this shouldn’t be committed though):635 </para>636+ <programlisting language="nix">637{638 skipLint = true;639 nodes.machine =···653 disable the Black linter directly (again, don’t commit this within654 the Nixpkgs repository):655 </para>656+ <programlisting language="nix">657 testScript =658 ''659 # fmt: off···665 Similarly, the type checking of test scripts can be disabled in666 the following way:667 </para>668+ <programlisting language="nix">669{670 skipTypeCheck = true;671 nodes.machine =···700 <literal>polling_condition</literal> takes the following701 (optional) arguments:702 </para>703+ <variablelist>704+ <varlistentry>705+ <term>706+ <literal>seconds_interval</literal>707+ </term>708+ <listitem>709+ <para>710+ specifies how often the condition should be polled:711+ </para>712+ </listitem>713+ </varlistentry>714+ </variablelist>715 <programlisting language="python">716@polling_condition(seconds_interval=10)717def foo_running():718 machine.succeed("pgrep -x foo")719</programlisting>720+ <variablelist>721+ <varlistentry>722+ <term>723+ <literal>description</literal>724+ </term>725+ <listitem>726+ <para>727+ is used in the log when the condition is checked. If this is728+ not provided, the description is pulled from the docstring729+ of the function. These two are therefore equivalent:730+ </para>731+ </listitem>732+ </varlistentry>733+ </variablelist>734 <programlisting language="python">735@polling_condition736def foo_running():···739 <literal>extraPythonPackages</literal>. For example, you could add740 <literal>numpy</literal> like this:741 </para>742+ <programlisting language="nix">743{744 extraPythonPackages = p: [ p.numpy ];745
···62 can create the following file at63 <literal>modules/installer/cd-dvd/installation-cd-graphical-gnome-macbook.nix</literal>:64 </para>65- <programlisting language="bash">66{ config, ... }:6768{
···62 can create the following file at63 <literal>modules/installer/cd-dvd/installation-cd-graphical-gnome-macbook.nix</literal>:64 </para>65+ <programlisting language="nix">66{ config, ... }:6768{
···94 unless you have set <literal>mutableUsers = false</literal>. Another95 way is to temporarily add the following to your configuration:96 </para>97- <programlisting language="bash">98users.users.your-user.initialHashedPassword = "test";99</programlisting>100 <para>
···94 unless you have set <literal>mutableUsers = false</literal>. Another95 way is to temporarily add the following to your configuration:96 </para>97+ <programlisting language="nix">98users.users.your-user.initialHashedPassword = "test";99</programlisting>100 <para>
···129 Ubuntu, you may want to add something like this to your130 <literal>configuration.nix</literal>:131 </para>132- <programlisting language="bash">133boot.loader.grub.extraEntries = ''134 menuentry "Ubuntu" {135 search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e···229 account with <literal>sudo passwd -l root</literal> if you use230 <literal>sudo</literal>)231 </para>232- <programlisting language="bash">233users.users.root.initialHashedPassword = "";234</programlisting>235 </listitem>
···129 Ubuntu, you may want to add something like this to your130 <literal>configuration.nix</literal>:131 </para>132+ <programlisting language="nix">133boot.loader.grub.extraEntries = ''134 menuentry "Ubuntu" {135 search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e···229 account with <literal>sudo passwd -l root</literal> if you use230 <literal>sudo</literal>)231 </para>232+ <programlisting language="nix">233users.users.root.initialHashedPassword = "";234</programlisting>235 </listitem>
···58 There are a few modifications you should make in configuration.nix.59 Enable booting:60 </para>61- <programlisting language="bash">62boot.loader.grub.device = "/dev/sda";63</programlisting>64 <para>65 Also remove the fsck that runs at startup. It will always fail to66 run, stopping your boot until you press <literal>*</literal>.67 </para>68- <programlisting language="bash">69boot.initrd.checkJournalingFS = false;70</programlisting>71 <para>···76 If you do not add <literal>"nofail"</literal>, the system77 will not boot properly.78 </para>79- <programlisting language="bash">80{ config, pkgs, ...} :81{82 fileSystems."/virtualboxshare" = {
···58 There are a few modifications you should make in configuration.nix.59 Enable booting:60 </para>61+ <programlisting language="nix">62boot.loader.grub.device = "/dev/sda";63</programlisting>64 <para>65 Also remove the fsck that runs at startup. It will always fail to66 run, stopping your boot until you press <literal>*</literal>.67 </para>68+ <programlisting language="nix">69boot.initrd.checkJournalingFS = false;70</programlisting>71 <para>···76 If you do not add <literal>"nofail"</literal>, the system77 will not boot properly.78 </para>79+ <programlisting language="nix">80{ config, pkgs, ...} :81{82 fileSystems."/virtualboxshare" = {
···128 You can keep a NixOS system up-to-date automatically by adding the129 following to <literal>configuration.nix</literal>:130 </para>131- <programlisting language="bash">132system.autoUpgrade.enable = true;133system.autoUpgrade.allowReboot = true;134</programlisting>···145 contains a different kernel, initrd or kernel modules. You can146 also specify a channel explicitly, e.g.147 </para>148- <programlisting language="bash">149system.autoUpgrade.channel = https://nixos.org/channels/nixos-22.11;150</programlisting>151 </section>
···128 You can keep a NixOS system up-to-date automatically by adding the129 following to <literal>configuration.nix</literal>:130 </para>131+ <programlisting language="nix">132system.autoUpgrade.enable = true;133system.autoUpgrade.allowReboot = true;134</programlisting>···145 contains a different kernel, initrd or kernel modules. You can146 also specify a channel explicitly, e.g.147 </para>148+ <programlisting language="nix">149system.autoUpgrade.channel = https://nixos.org/channels/nixos-22.11;150</programlisting>151 </section>
···79 the NixOS configuration. For instance, if a package80 <literal>foo</literal> provides systemd units, you can say:81 </para>82- <programlisting language="bash">83{84 systemd.packages = [ pkgs.foo ];85}···88 to enable those units. You can then set or override unit options89 in the usual way, e.g.90 </para>91- <programlisting language="bash">92{93 systemd.services.foo.wantedBy = [ "multi-user.target" ];94 systemd.services.foo.serviceConfig.MemoryLimit = "512M";···105 NixOS configuration requires unfree packages from Nixpkgs, you106 need to enable support for them explicitly by setting:107 </para>108- <programlisting language="bash">109{110 nixpkgs.config.allowUnfree = true;111}···123 The Adobe Flash player is no longer enabled by default in the124 Firefox and Chromium wrappers. To enable it, you must set:125 </para>126- <programlisting language="bash">127{128 nixpkgs.config.allowUnfree = true;129 nixpkgs.config.firefox.enableAdobeFlash = true; # for Firefox···136 The firewall is now enabled by default. If you don’t want this,137 you need to disable it explicitly:138 </para>139- <programlisting language="bash">140{141 networking.firewall.enable = false;142}
···79 the NixOS configuration. For instance, if a package80 <literal>foo</literal> provides systemd units, you can say:81 </para>82+ <programlisting language="nix">83{84 systemd.packages = [ pkgs.foo ];85}···88 to enable those units. You can then set or override unit options89 in the usual way, e.g.90 </para>91+ <programlisting language="nix">92{93 systemd.services.foo.wantedBy = [ "multi-user.target" ];94 systemd.services.foo.serviceConfig.MemoryLimit = "512M";···105 NixOS configuration requires unfree packages from Nixpkgs, you106 need to enable support for them explicitly by setting:107 </para>108+ <programlisting language="nix">109{110 nixpkgs.config.allowUnfree = true;111}···123 The Adobe Flash player is no longer enabled by default in the124 Firefox and Chromium wrappers. To enable it, you must set:125 </para>126+ <programlisting language="nix">127{128 nixpkgs.config.allowUnfree = true;129 nixpkgs.config.firefox.enableAdobeFlash = true; # for Firefox···136 The firewall is now enabled by default. If you don’t want this,137 you need to disable it explicitly:138 </para>139+ <programlisting language="nix">140{141 networking.firewall.enable = false;142}
···370 documentation</link> for details. If you wish to continue to use371 httpd 2.2, add the following line to your NixOS configuration:372 </para>373- <programlisting language="bash">374{375 services.httpd.package = pkgs.apacheHttpd_2_2;376}
···370 documentation</link> for details. If you wish to continue to use371 httpd 2.2, add the following line to your NixOS configuration:372 </para>373+ <programlisting language="nix">374{375 services.httpd.package = pkgs.apacheHttpd_2_2;376}
···378 You will need to add an import statement to your NixOS379 configuration in order to use it, e.g.380 </para>381- <programlisting language="bash">382{383 imports = [ <nixpkgs/nixos/modules/services/misc/gitit.nix> ];384}···395 to be built in. All modules now reside in396 <literal>nginxModules</literal> set. Example configuration:397 </para>398- <programlisting language="bash">399nginx.override {400 modules = [ nginxModules.rtmp nginxModules.dav nginxModules.moreheaders ];401}···468 continue to work, but print a warning, until the 16.09 release.469 An example of the new style:470 </para>471- <programlisting language="bash">472{473 fileSystems."/example" = {474 device = "/dev/sdc";···524 used input method name, <literal>"ibus"</literal> for525 ibus. An example of the new style:526 </para>527- <programlisting language="bash">528{529 i18n.inputMethod.enabled = "ibus";530 i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [ anthy mozc ];···533 <para>534 That is equivalent to the old version:535 </para>536- <programlisting language="bash">537{538 programs.ibus.enable = true;539 programs.ibus.plugins = with pkgs; [ ibus-anthy mozc ];···587 point to exact folder where syncthing is writing to. Example588 configuration should look something like:589 </para>590- <programlisting language="bash">591{592 services.syncthing = {593 enable = true;
···378 You will need to add an import statement to your NixOS379 configuration in order to use it, e.g.380 </para>381+ <programlisting language="nix">382{383 imports = [ <nixpkgs/nixos/modules/services/misc/gitit.nix> ];384}···395 to be built in. All modules now reside in396 <literal>nginxModules</literal> set. Example configuration:397 </para>398+ <programlisting language="nix">399nginx.override {400 modules = [ nginxModules.rtmp nginxModules.dav nginxModules.moreheaders ];401}···468 continue to work, but print a warning, until the 16.09 release.469 An example of the new style:470 </para>471+ <programlisting language="nix">472{473 fileSystems."/example" = {474 device = "/dev/sdc";···524 used input method name, <literal>"ibus"</literal> for525 ibus. An example of the new style:526 </para>527+ <programlisting language="nix">528{529 i18n.inputMethod.enabled = "ibus";530 i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [ anthy mozc ];···533 <para>534 That is equivalent to the old version:535 </para>536+ <programlisting language="nix">537{538 programs.ibus.enable = true;539 programs.ibus.plugins = with pkgs; [ ibus-anthy mozc ];···587 point to exact folder where syncthing is writing to. Example588 configuration should look something like:589 </para>590+ <programlisting language="nix">591{592 services.syncthing = {593 enable = true;
···192 interface has been streamlined. Desktop users should be able to193 simply set194 </para>195- <programlisting language="bash">196{197 security.grsecurity.enable = true;198}
···192 interface has been streamlined. Desktop users should be able to193 simply set194 </para>195+ <programlisting language="nix">196{197 security.grsecurity.enable = true;198}
···581 <literal>service.nylon</literal> is now declared using named582 instances. As an example:583 </para>584- <programlisting language="bash">585{586 services.nylon = {587 enable = true;···594 <para>595 should be replaced with:596 </para>597- <programlisting language="bash">598{599 services.nylon.myvpn = {600 enable = true;···615 <link xlink:href="https://nixos.org/nixpkgs/manual/#sec-overlays-install">616 overlays</link>. For example, the following code:617 </para>618- <programlisting language="bash">619let620 pkgs = import <nixpkgs> {};621in···624 <para>625 should be replaced by:626 </para>627- <programlisting language="bash">628let629 pkgs = import <nixpkgs> {};630in
···581 <literal>service.nylon</literal> is now declared using named582 instances. As an example:583 </para>584+ <programlisting language="nix">585{586 services.nylon = {587 enable = true;···594 <para>595 should be replaced with:596 </para>597+ <programlisting language="nix">598{599 services.nylon.myvpn = {600 enable = true;···615 <link xlink:href="https://nixos.org/nixpkgs/manual/#sec-overlays-install">616 overlays</link>. For example, the following code:617 </para>618+ <programlisting language="nix">619let620 pkgs = import <nixpkgs> {};621in···624 <para>625 should be replaced by:626 </para>627+ <programlisting language="nix">628let629 pkgs = import <nixpkgs> {};630in
···29 head. Apart from that, it’s now possible to also set30 additional options by using an attribute set, for example:31 </para>32- <programlisting language="bash">33{ services.xserver.xrandrHeads = [34 "HDMI-0"35 {
···29 head. Apart from that, it’s now possible to also set30 additional options by using an attribute set, for example:31 </para>32+ <programlisting language="nix">33{ services.xserver.xrandrHeads = [34 "HDMI-0"35 {
···830 <para>831 In order to have the previous default configuration add832 </para>833- <programlisting language="bash">834{835 services.xserver.displayManager.lightdm.greeters.gtk.indicators = [836 "~host" "~spacer"
···830 <para>831 In order to have the previous default configuration add832 </para>833+ <programlisting language="nix">834{835 services.xserver.displayManager.lightdm.greeters.gtk.indicators = [836 "~host" "~spacer"
···54 <para>55 For example56 </para>57- <programlisting language="bash">58{59 programs.firejail = {60 enable = true;···695 A NixOS system can now be constructed more easily based on a696 preexisting invocation of Nixpkgs. For example:697 </para>698- <programlisting language="bash">699{700 inherit (pkgs.nixos {701 boot.loader.grub.enable = false;···791 <para>792 An example usage of this would be:793 </para>794- <programlisting language="bash">795{ config, ... }:796797{
···54 <para>55 For example56 </para>57+ <programlisting language="nix">58{59 programs.firejail = {60 enable = true;···695 A NixOS system can now be constructed more easily based on a696 preexisting invocation of Nixpkgs. For example:697 </para>698+ <programlisting language="nix">699{700 inherit (pkgs.nixos {701 boot.loader.grub.enable = false;···791 <para>792 An example usage of this would be:793 </para>794+ <programlisting language="nix">795{ config, ... }:796797{
···133 option to improve support for upstream session files. If you134 used something like:135 </para>136- <programlisting language="bash">137{138 services.xserver.desktopManager.default = "xfce";139 services.xserver.windowManager.default = "icewm";···142 <para>143 you should change it to:144 </para>145- <programlisting language="bash">146{147 services.xserver.displayManager.defaultSession = "xfce+icewm";148}···821 is a <literal>loaOf</literal> option that is commonly used as822 follows:823 </para>824- <programlisting language="bash">825{826 users.users =827 [ { name = "me";···836 value of <literal>name</literal> as the name of the attribute837 set:838 </para>839- <programlisting language="bash">840{841 users.users.me =842 { description = "My personal user.";···940 because it permitted root auto-login you can override the941 lightdm-autologin pam module like:942 </para>943- <programlisting language="bash">944{945 security.pam.services.lightdm-autologin.text = lib.mkForce ''946 auth requisite pam_nologin.so···1004 Additionally, some Postfix configuration must now be set1005 manually instead of automatically by the Mailman module:1006 </para>1007- <programlisting language="bash">1008{1009 services.postfix.relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];1010 services.postfix.config.transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];···1066 or by passing a TOML configuration file via1067 <link xlink:href="options.html#opt-services.dnscrypt-proxy2.configFile">services.dnscrypt-proxy2.configFile</link>.1068 </para>1069- <programlisting language="bash">1070{1071 # Example configuration:1072 services.dnscrypt-proxy2.enable = true;···1229 when upgrading. Otherwise, the package can be deployed1230 using the following config:1231 </para>1232- <programlisting language="bash">1233{ pkgs, ... }: {1234 services.hydra.package = pkgs.hydra-migration;1235}···1319 <para>1320 To continue to use the old approach, you can configure:1321 </para>1322- <programlisting language="bash">1323{1324 services.nginx.appendConfig = let cfg = config.services.nginx; in ''user ${cfg.user} ${cfg.group};'';1325 systemd.services.nginx.serviceConfig.User = lib.mkForce "root";···1432 older, you simply need to enable postgresql-support1433 explicitly:1434 </para>1435- <programlisting language="bash">1436{ ... }: {1437 services.matrix-synapse = {1438 enable = true;
···133 option to improve support for upstream session files. If you134 used something like:135 </para>136+ <programlisting language="nix">137{138 services.xserver.desktopManager.default = "xfce";139 services.xserver.windowManager.default = "icewm";···142 <para>143 you should change it to:144 </para>145+ <programlisting language="nix">146{147 services.xserver.displayManager.defaultSession = "xfce+icewm";148}···821 is a <literal>loaOf</literal> option that is commonly used as822 follows:823 </para>824+ <programlisting language="nix">825{826 users.users =827 [ { name = "me";···836 value of <literal>name</literal> as the name of the attribute837 set:838 </para>839+ <programlisting language="nix">840{841 users.users.me =842 { description = "My personal user.";···940 because it permitted root auto-login you can override the941 lightdm-autologin pam module like:942 </para>943+ <programlisting language="nix">944{945 security.pam.services.lightdm-autologin.text = lib.mkForce ''946 auth requisite pam_nologin.so···1004 Additionally, some Postfix configuration must now be set1005 manually instead of automatically by the Mailman module:1006 </para>1007+ <programlisting language="nix">1008{1009 services.postfix.relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];1010 services.postfix.config.transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];···1066 or by passing a TOML configuration file via1067 <link xlink:href="options.html#opt-services.dnscrypt-proxy2.configFile">services.dnscrypt-proxy2.configFile</link>.1068 </para>1069+ <programlisting language="nix">1070{1071 # Example configuration:1072 services.dnscrypt-proxy2.enable = true;···1229 when upgrading. Otherwise, the package can be deployed1230 using the following config:1231 </para>1232+ <programlisting language="nix">1233{ pkgs, ... }: {1234 services.hydra.package = pkgs.hydra-migration;1235}···1319 <para>1320 To continue to use the old approach, you can configure:1321 </para>1322+ <programlisting language="nix">1323{1324 services.nginx.appendConfig = let cfg = config.services.nginx; in ''user ${cfg.user} ${cfg.group};'';1325 systemd.services.nginx.serviceConfig.User = lib.mkForce "root";···1432 older, you simply need to enable postgresql-support1433 explicitly:1434 </para>1435+ <programlisting language="nix">1436{ ... }: {1437 services.matrix-synapse = {1438 enable = true;
···730 traditional mysql_native_password plugin method, one must run731 the following:732 </para>733- <programlisting language="bash">734{735services.mysql.initialScript = pkgs.writeText "mariadb-init.sql" ''736 ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("verysecret");···755 allow MySQL to read from /home and /tmp directories when using756 <literal>LOAD DATA INFILE</literal>757 </para>758- <programlisting language="bash">759{760 systemd.services.mysql.serviceConfig.ProtectHome = lib.mkForce "read-only";761}···766 <literal>SELECT * INTO OUTFILE</literal>, assuming the mysql767 user has write access to <literal>/var/data</literal>768 </para>769- <programlisting language="bash">770{771 systemd.services.mysql.serviceConfig.ReadWritePaths = [ "/var/data" ];772}···885 <literal>phantomJsSupport = true</literal> to the package886 instantiation:887 </para>888- <programlisting language="bash">889{890 services.grafana.package = pkgs.grafana.overrideAttrs (oldAttrs: rec {891 phantomJsSupport = true;···958 <literal>opcache</literal>, <literal>pdo</literal> and959 <literal>pdo_mysql</literal> loaded:960 </para>961- <programlisting language="bash">962{963 environment.systemPackages = [964 (pkgs.php.withExtensions···997 The remaining configuration flags can now be set directly on998 the <literal>php</literal> attribute. For example, instead of999 </para>1000- <programlisting language="bash">1001{1002 php.override {1003 config.php.embed = true;···1008 <para>1009 you should now write1010 </para>1011- <programlisting language="bash">1012{1013 php.override {1014 embedSupport = true;···1062 writing to other folders, use1063 <literal>systemd.services.nginx.serviceConfig.ReadWritePaths</literal>1064 </para>1065- <programlisting language="bash">1066{1067 systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ];1068}···1076 docs</link> for details). If you require serving files from1077 home directories, you may choose to set e.g.1078 </para>1079- <programlisting language="bash">1080{1081 systemd.services.nginx.serviceConfig.ProtectHome = "read-only";1082}···1093 <para>1094 Replace a <literal>nesting.clone</literal> entry with:1095 </para>1096- <programlisting language="bash">1097{1098 specialisation.example-sub-configuration = {1099 configuration = {···1104 <para>1105 Replace a <literal>nesting.children</literal> entry with:1106 </para>1107- <programlisting language="bash">1108{1109 specialisation.example-sub-configuration = {1110 inheritParentConfig = false;···1385 multi-instance config with an existing bitcoind data directory1386 and user, you have to adjust the original config, e.g.:1387 </para>1388- <programlisting language="bash">1389{1390 services.bitcoind = {1391 enable = true;···1397 <para>1398 To something similar:1399 </para>1400- <programlisting language="bash">1401{1402 services.bitcoind.mainnet = {1403 enable = true;···1447 the original SSL settings, you have to adjust the original1448 config, e.g.:1449 </para>1450- <programlisting language="bash">1451{1452 services.dokuwiki = {1453 enable = true;···1458 <para>1459 To something similar:1460 </para>1461- <programlisting language="bash">1462{1463 services.dokuwiki."mywiki" = {1464 enable = true;···1492 option is (<literal>/var/db/postgresql</literal>) and then1493 explicitly set this value to maintain compatibility:1494 </para>1495- <programlisting language="bash">1496{1497 services.postgresql.dataDir = "/var/db/postgresql";1498}···1825 you must include those directories into the1826 <literal>BindPaths</literal> of the service:1827 </para>1828- <programlisting language="bash">1829{1830 systemd.services.transmission.serviceConfig.BindPaths = [ "/path/to/alternative/download-dir" ];1831}···1835 <literal>transmission-daemon</literal> is now only available1836 on the local network interface by default. Use:1837 </para>1838- <programlisting language="bash">1839{1840 services.transmission.settings.rpc-bind-address = "0.0.0.0";1841}···1900 <para>1901 This means that a configuration like this1902 </para>1903- <programlisting language="bash">1904{1905 services.dovecot2.mailboxes = [1906 { name = "Junk";···1912 <para>1913 should now look like this:1914 </para>1915- <programlisting language="bash">1916{1917 services.dovecot2.mailboxes = {1918 Junk.auto = "create";
···730 traditional mysql_native_password plugin method, one must run731 the following:732 </para>733+ <programlisting language="nix">734{735services.mysql.initialScript = pkgs.writeText "mariadb-init.sql" ''736 ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("verysecret");···755 allow MySQL to read from /home and /tmp directories when using756 <literal>LOAD DATA INFILE</literal>757 </para>758+ <programlisting language="nix">759{760 systemd.services.mysql.serviceConfig.ProtectHome = lib.mkForce "read-only";761}···766 <literal>SELECT * INTO OUTFILE</literal>, assuming the mysql767 user has write access to <literal>/var/data</literal>768 </para>769+ <programlisting language="nix">770{771 systemd.services.mysql.serviceConfig.ReadWritePaths = [ "/var/data" ];772}···885 <literal>phantomJsSupport = true</literal> to the package886 instantiation:887 </para>888+ <programlisting language="nix">889{890 services.grafana.package = pkgs.grafana.overrideAttrs (oldAttrs: rec {891 phantomJsSupport = true;···958 <literal>opcache</literal>, <literal>pdo</literal> and959 <literal>pdo_mysql</literal> loaded:960 </para>961+ <programlisting language="nix">962{963 environment.systemPackages = [964 (pkgs.php.withExtensions···997 The remaining configuration flags can now be set directly on998 the <literal>php</literal> attribute. For example, instead of999 </para>1000+ <programlisting language="nix">1001{1002 php.override {1003 config.php.embed = true;···1008 <para>1009 you should now write1010 </para>1011+ <programlisting language="nix">1012{1013 php.override {1014 embedSupport = true;···1062 writing to other folders, use1063 <literal>systemd.services.nginx.serviceConfig.ReadWritePaths</literal>1064 </para>1065+ <programlisting language="nix">1066{1067 systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ];1068}···1076 docs</link> for details). If you require serving files from1077 home directories, you may choose to set e.g.1078 </para>1079+ <programlisting language="nix">1080{1081 systemd.services.nginx.serviceConfig.ProtectHome = "read-only";1082}···1093 <para>1094 Replace a <literal>nesting.clone</literal> entry with:1095 </para>1096+ <programlisting language="nix">1097{1098 specialisation.example-sub-configuration = {1099 configuration = {···1104 <para>1105 Replace a <literal>nesting.children</literal> entry with:1106 </para>1107+ <programlisting language="nix">1108{1109 specialisation.example-sub-configuration = {1110 inheritParentConfig = false;···1385 multi-instance config with an existing bitcoind data directory1386 and user, you have to adjust the original config, e.g.:1387 </para>1388+ <programlisting language="nix">1389{1390 services.bitcoind = {1391 enable = true;···1397 <para>1398 To something similar:1399 </para>1400+ <programlisting language="nix">1401{1402 services.bitcoind.mainnet = {1403 enable = true;···1447 the original SSL settings, you have to adjust the original1448 config, e.g.:1449 </para>1450+ <programlisting language="nix">1451{1452 services.dokuwiki = {1453 enable = true;···1458 <para>1459 To something similar:1460 </para>1461+ <programlisting language="nix">1462{1463 services.dokuwiki."mywiki" = {1464 enable = true;···1492 option is (<literal>/var/db/postgresql</literal>) and then1493 explicitly set this value to maintain compatibility:1494 </para>1495+ <programlisting language="nix">1496{1497 services.postgresql.dataDir = "/var/db/postgresql";1498}···1825 you must include those directories into the1826 <literal>BindPaths</literal> of the service:1827 </para>1828+ <programlisting language="nix">1829{1830 systemd.services.transmission.serviceConfig.BindPaths = [ "/path/to/alternative/download-dir" ];1831}···1835 <literal>transmission-daemon</literal> is now only available1836 on the local network interface by default. Use:1837 </para>1838+ <programlisting language="nix">1839{1840 services.transmission.settings.rpc-bind-address = "0.0.0.0";1841}···1900 <para>1901 This means that a configuration like this1902 </para>1903+ <programlisting language="nix">1904{1905 services.dovecot2.mailboxes = [1906 { name = "Junk";···1912 <para>1913 should now look like this:1914 </para>1915+ <programlisting language="nix">1916{1917 services.dovecot2.mailboxes = {1918 Junk.auto = "create";
···330 <literal>mediatomb</literal> package. If you want to keep the331 old behavior, you must declare it with:332 </para>333- <programlisting language="bash">334{335 services.mediatomb.package = pkgs.mediatomb;336}···341 service declaration to add the firewall rules itself before,342 you should now declare it with:343 </para>344- <programlisting language="bash">345{346 services.mediatomb.openFirewall = true;347}···368 <link xlink:href="options.html#opt-services.uwsgi.capabilities">services.uwsgi.capabilities</link>.369 The previous behaviour can be restored by setting:370 </para>371- <programlisting language="bash">372{373 services.uwsgi.user = "root";374 services.uwsgi.group = "root";···552 has been removed. To enable Privoxy, and to configure it to553 use Tor’s faster port, use the following configuration:554 </para>555- <programlisting language="bash">556{557 opt-services.privoxy.enable = true;558 opt-services.privoxy.enableTor = true;···689 <literal>mpich</literal> instead of the default690 <literal>openmpi</literal> can now be achived like this:691 </para>692- <programlisting language="bash">693self: super:694{695 mpi = super.mpich;···850 kodiPackages.inputstream-adaptive and kodiPackages.vfs-sftp851 addons:852 </para>853- <programlisting language="bash">854{855 environment.systemPackages = [856 pkgs.kodi···867 and as a result the above configuration should now be written868 as:869 </para>870- <programlisting language="bash">871{872 environment.systemPackages = [873 (pkgs.kodi.withPackages (p: with p; [···1158 users to declare autoscan media directories from their nixos1159 configuration:1160 </para>1161- <programlisting language="bash">1162{1163 services.mediatomb.mediaDirectories = [1164 { path = "/var/lib/mediatomb/pictures"; recursive = false; hidden-files = false; }···1519 been dropped. Users that still want it should add the1520 following to their system configuration:1521 </para>1522- <programlisting language="bash">1523{1524 services.gvfs.package = pkgs.gvfs.override { samba = null; };1525}
···330 <literal>mediatomb</literal> package. If you want to keep the331 old behavior, you must declare it with:332 </para>333+ <programlisting language="nix">334{335 services.mediatomb.package = pkgs.mediatomb;336}···341 service declaration to add the firewall rules itself before,342 you should now declare it with:343 </para>344+ <programlisting language="nix">345{346 services.mediatomb.openFirewall = true;347}···368 <link xlink:href="options.html#opt-services.uwsgi.capabilities">services.uwsgi.capabilities</link>.369 The previous behaviour can be restored by setting:370 </para>371+ <programlisting language="nix">372{373 services.uwsgi.user = "root";374 services.uwsgi.group = "root";···552 has been removed. To enable Privoxy, and to configure it to553 use Tor’s faster port, use the following configuration:554 </para>555+ <programlisting language="nix">556{557 opt-services.privoxy.enable = true;558 opt-services.privoxy.enableTor = true;···689 <literal>mpich</literal> instead of the default690 <literal>openmpi</literal> can now be achived like this:691 </para>692+ <programlisting language="nix">693self: super:694{695 mpi = super.mpich;···850 kodiPackages.inputstream-adaptive and kodiPackages.vfs-sftp851 addons:852 </para>853+ <programlisting language="nix">854{855 environment.systemPackages = [856 pkgs.kodi···867 and as a result the above configuration should now be written868 as:869 </para>870+ <programlisting language="nix">871{872 environment.systemPackages = [873 (pkgs.kodi.withPackages (p: with p; [···1158 users to declare autoscan media directories from their nixos1159 configuration:1160 </para>1161+ <programlisting language="nix">1162{1163 services.mediatomb.mediaDirectories = [1164 { path = "/var/lib/mediatomb/pictures"; recursive = false; hidden-files = false; }···1519 been dropped. Users that still want it should add the1520 following to their system configuration:1521 </para>1522+ <programlisting language="nix">1523{1524 services.gvfs.package = pkgs.gvfs.override { samba = null; };1525}
···642 </para>643 </listitem>644 </itemizedlist>645- <programlisting language="bash">646{647 services.paperless-ng.extraConfig = {648 # Provide languages as ISO 639-2 codes···737 insecure. Out-of-tree modules are likely to require738 adaptation: instead of739 </para>740- <programlisting language="bash">741{742 users.users.foo = {743 isSystemUser = true;···747 <para>748 also create a group for your user:749 </para>750- <programlisting language="bash">751{752 users.users.foo = {753 isSystemUser = true;
···642 </para>643 </listitem>644 </itemizedlist>645+ <programlisting language="nix">646{647 services.paperless-ng.extraConfig = {648 # Provide languages as ISO 639-2 codes···737 insecure. Out-of-tree modules are likely to require738 adaptation: instead of739 </para>740+ <programlisting language="nix">741{742 users.users.foo = {743 isSystemUser = true;···747 <para>748 also create a group for your user:749 </para>750+ <programlisting language="nix">751{752 users.users.foo = {753 isSystemUser = true;
···1082 removed. This option was an association of environment1083 variables for Grafana. If you had an expression like1084 </para>1085- <programlisting language="bash">1086{1087 services.grafana.extraOptions.SECURITY_ADMIN_USER = "foobar";1088}···1096 For the migration, it is recommended to turn it into the1097 INI format, i.e. to declare1098 </para>1099- <programlisting language="bash">1100{1101 services.grafana.settings.security.admin_user = "foobar";1102}
···1082 removed. This option was an association of environment1083 variables for Grafana. If you had an expression like1084 </para>1085+ <programlisting language="nix">1086{1087 services.grafana.extraOptions.SECURITY_ADMIN_USER = "foobar";1088}···1096 For the migration, it is recommended to turn it into the1097 INI format, i.e. to declare1098 </para>1099+ <programlisting language="nix">1100{1101 services.grafana.settings.security.admin_user = "foobar";1102}
+1-1
nixos/doc/manual/md-to-db.sh
···1#! /usr/bin/env nix-shell2-#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/tarball/21.11 -i bash -p pandoc34# This script is temporarily needed while we transition the manual to5# CommonMark. It converts the .md files in the regular manual folder
···1#! /usr/bin/env nix-shell2+#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/tarball/22.11 -i bash -p pandoc34# This script is temporarily needed while we transition the manual to5# CommonMark. It converts the .md files in the regular manual folder