about summary refs log tree commit diff
path: root/nixpkgs/nixos
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-09-13 11:53:06 +0000
committerAlyssa Ross <hi@alyssa.is>2021-09-13 17:18:49 +0000
commitc3e005913d59b8ad64004e60888a71816688af1f (patch)
treef65b32f0d16acaa40f2ee82ac736d150de4b6cf5 /nixpkgs/nixos
parent1c8034da05499ca3d999f57ba1f6b235e7711ee1 (diff)
parentdb88608d8c811a93b74c99cfa1224952afc78200 (diff)
downloadnixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.gz
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.bz2
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.lz
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.xz
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.zst
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.zip
Merge commit 'db88608d8c811a93b74c99cfa1224952afc78200'
Conflicts:
	nixpkgs/nixos/modules/config/update-users-groups.pl
Diffstat (limited to 'nixpkgs/nixos')
-rw-r--r--nixpkgs/nixos/doc/manual/administration/boot-problems.section.md2
-rw-r--r--nixpkgs/nixos/doc/manual/administration/cleaning-store.chapter.md62
-rw-r--r--nixpkgs/nixos/doc/manual/administration/cleaning-store.xml63
-rw-r--r--nixpkgs/nixos/doc/manual/administration/container-networking.section.md44
-rw-r--r--nixpkgs/nixos/doc/manual/administration/container-networking.xml59
-rw-r--r--nixpkgs/nixos/doc/manual/administration/containers.chapter.md28
-rw-r--r--nixpkgs/nixos/doc/manual/administration/containers.xml34
-rw-r--r--nixpkgs/nixos/doc/manual/administration/control-groups.chapter.md59
-rw-r--r--nixpkgs/nixos/doc/manual/administration/control-groups.xml65
-rw-r--r--nixpkgs/nixos/doc/manual/administration/declarative-containers.section.md48
-rw-r--r--nixpkgs/nixos/doc/manual/administration/declarative-containers.xml60
-rw-r--r--nixpkgs/nixos/doc/manual/administration/imperative-containers.section.md115
-rw-r--r--nixpkgs/nixos/doc/manual/administration/imperative-containers.xml123
-rw-r--r--nixpkgs/nixos/doc/manual/administration/logging.chapter.md38
-rw-r--r--nixpkgs/nixos/doc/manual/administration/logging.xml43
-rw-r--r--nixpkgs/nixos/doc/manual/administration/maintenance-mode.section.md11
-rw-r--r--nixpkgs/nixos/doc/manual/administration/maintenance-mode.xml16
-rw-r--r--nixpkgs/nixos/doc/manual/administration/network-problems.section.md21
-rw-r--r--nixpkgs/nixos/doc/manual/administration/network-problems.xml27
-rw-r--r--nixpkgs/nixos/doc/manual/administration/rebooting.chapter.md30
-rw-r--r--nixpkgs/nixos/doc/manual/administration/rebooting.xml35
-rw-r--r--nixpkgs/nixos/doc/manual/administration/rollback.section.md38
-rw-r--r--nixpkgs/nixos/doc/manual/administration/rollback.xml41
-rw-r--r--nixpkgs/nixos/doc/manual/administration/running.xml16
-rw-r--r--nixpkgs/nixos/doc/manual/administration/service-mgmt.chapter.md120
-rw-r--r--nixpkgs/nixos/doc/manual/administration/service-mgmt.xml140
-rw-r--r--nixpkgs/nixos/doc/manual/administration/store-corruption.section.md28
-rw-r--r--nixpkgs/nixos/doc/manual/administration/store-corruption.xml36
-rw-r--r--nixpkgs/nixos/doc/manual/administration/troubleshooting.chapter.md12
-rw-r--r--nixpkgs/nixos/doc/manual/administration/troubleshooting.xml16
-rw-r--r--nixpkgs/nixos/doc/manual/administration/user-sessions.chapter.md43
-rw-r--r--nixpkgs/nixos/doc/manual/administration/user-sessions.xml45
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.section.md13
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.xml20
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.section.md51
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.xml61
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.section.md74
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.xml73
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/config-file.section.md175
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/config-file.xml216
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/config-syntax.chapter.md19
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/config-syntax.xml25
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/configuration.xml26
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/customizing-packages.section.md74
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/customizing-packages.xml86
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/declarative-packages.section.md46
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/declarative-packages.xml54
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/file-systems.chapter.md42
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/file-systems.xml58
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/firewall.section.md32
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/firewall.xml37
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/gpu-accel.chapter.md204
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/gpu-accel.xml262
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ipv4-config.section.md35
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ipv4-config.xml43
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ipv6-config.section.md42
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ipv6-config.xml54
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/kubernetes.chapter.md104
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/kubernetes.xml112
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/linux-kernel.chapter.md135
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/linux-kernel.xml138
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/luks-file-systems.section.md77
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/luks-file-systems.xml78
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/modularity.section.md133
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/modularity.xml146
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/network-manager.section.md42
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/network-manager.xml48
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/networking.chapter.md16
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/networking.xml20
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/package-mgmt.chapter.md18
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/package-mgmt.xml31
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles.chapter.md34
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles.xml39
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.section.md11
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.xml21
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/base.section.md7
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/base.xml15
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.section.md11
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.xml21
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/demo.section.md4
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/demo.xml14
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.section.md7
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.xml16
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/graphical.section.md10
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/graphical.xml20
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/hardened.section.md20
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/hardened.xml32
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/headless.section.md9
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/headless.xml19
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.section.md24
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.xml36
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/minimal.section.md9
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/minimal.xml17
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.section.md7
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.xml17
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.section.md51
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.xml67
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ssh.section.md19
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/ssh.xml27
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/sshfs-file-systems.section.md2
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/subversion.chapter.md102
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/subversion.xml140
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/summary.section.md46
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/summary.xml227
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/user-mgmt.chapter.md92
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/user-mgmt.xml88
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/wayland.chapter.md27
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/wayland.xml33
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/wireless.section.md67
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/wireless.xml70
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/x-windows.chapter.md337
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/x-windows.xml355
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/xfce.chapter.md52
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/xfce.xml59
-rw-r--r--nixpkgs/nixos/doc/manual/development/building-parts.chapter.md74
-rw-r--r--nixpkgs/nixos/doc/manual/development/building-parts.xml121
-rw-r--r--nixpkgs/nixos/doc/manual/development/development.xml12
-rw-r--r--nixpkgs/nixos/doc/manual/development/freeform-modules.section.md79
-rw-r--r--nixpkgs/nixos/doc/manual/development/freeform-modules.xml68
-rw-r--r--nixpkgs/nixos/doc/manual/development/importing-modules.section.md46
-rw-r--r--nixpkgs/nixos/doc/manual/development/importing-modules.xml56
-rw-r--r--nixpkgs/nixos/doc/manual/development/meta-attributes.section.md40
-rw-r--r--nixpkgs/nixos/doc/manual/development/meta-attributes.xml63
-rw-r--r--nixpkgs/nixos/doc/manual/development/nixos-tests.chapter.md13
-rw-r--r--nixpkgs/nixos/doc/manual/development/nixos-tests.xml20
-rw-r--r--nixpkgs/nixos/doc/manual/development/option-declarations.section.md136
-rw-r--r--nixpkgs/nixos/doc/manual/development/option-declarations.xml199
-rw-r--r--nixpkgs/nixos/doc/manual/development/option-def.section.md91
-rw-r--r--nixpkgs/nixos/doc/manual/development/option-def.xml99
-rw-r--r--nixpkgs/nixos/doc/manual/development/option-types.section.md558
-rw-r--r--nixpkgs/nixos/doc/manual/development/option-types.xml914
-rw-r--r--nixpkgs/nixos/doc/manual/development/replace-modules.section.md64
-rw-r--r--nixpkgs/nixos/doc/manual/development/replace-modules.xml79
-rw-r--r--nixpkgs/nixos/doc/manual/development/settings-options.section.md192
-rw-r--r--nixpkgs/nixos/doc/manual/development/settings-options.xml226
-rw-r--r--nixpkgs/nixos/doc/manual/development/sources.chapter.md77
-rw-r--r--nixpkgs/nixos/doc/manual/development/sources.xml85
-rw-r--r--nixpkgs/nixos/doc/manual/development/testing-installer.chapter.md18
-rw-r--r--nixpkgs/nixos/doc/manual/development/testing-installer.xml22
-rw-r--r--nixpkgs/nixos/doc/manual/development/writing-documentation.chapter.md93
-rw-r--r--nixpkgs/nixos/doc/manual/development/writing-documentation.xml150
-rw-r--r--nixpkgs/nixos/doc/manual/development/writing-modules.chapter.md166
-rw-r--r--nixpkgs/nixos/doc/manual/development/writing-modules.xml191
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/boot-problems.section.xml2
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/cleaning-store.chapter.xml71
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/container-networking.section.xml54
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/containers.chapter.xml31
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/control-groups.chapter.xml67
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/declarative-containers.section.xml60
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/imperative-containers.section.xml131
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/logging.chapter.xml45
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/maintenance-mode.section.xml14
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/network-problems.section.xml25
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/rebooting.chapter.xml38
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/rollback.section.xml42
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/service-mgmt.chapter.xml141
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/store-corruption.section.xml34
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/troubleshooting.chapter.xml12
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/administration/user-sessions.chapter.xml46
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-network-config.section.xml16
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-packages.section.xml59
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/adding-custom-packages.section.xml80
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/config-file.section.xml231
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/config-syntax.chapter.xml21
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/customizing-packages.section.xml90
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/declarative-packages.section.xml53
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/file-systems.chapter.xml55
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/firewall.section.xml39
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/gpu-accel.chapter.xml239
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/ipv4-config.section.xml43
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/ipv6-config.section.xml47
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/kubernetes.chapter.xml126
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/linux-kernel.chapter.xml150
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/luks-file-systems.section.xml84
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/modularity.section.xml152
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/network-manager.section.xml49
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/networking.chapter.xml15
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/package-mgmt.chapter.xml28
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles.chapter.xml38
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/all-hardware.section.xml15
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/base.section.xml10
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/clone-config.section.xml16
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/demo.section.xml10
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/docker-container.section.xml12
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/graphical.section.xml14
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/hardened.section.xml25
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/headless.section.xml15
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/installation-device.section.xml32
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/minimal.section.xml13
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/profiles/qemu-guest.section.xml11
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/renaming-interfaces.section.xml62
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/ssh.section.xml23
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/sshfs-file-systems.section.xml4
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/subversion.chapter.xml121
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/summary.section.xml332
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/user-mgmt.chapter.xml105
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/wayland.chapter.xml31
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/wireless.section.xml73
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml381
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/configuration/xfce.chapter.xml62
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/building-parts.chapter.xml124
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/freeform-modules.section.xml87
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/importing-modules.section.xml47
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/meta-attributes.section.xml55
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/nixos-tests.chapter.xml14
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/option-declarations.section.xml203
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/option-def.section.xml104
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/option-types.section.xml987
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/replace-modules.section.xml70
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/settings-options.section.xml285
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/sources.chapter.xml90
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/testing-installer.chapter.xml22
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml144
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/development/writing-modules.chapter.xml196
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/changing-config.chapter.xml117
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/installing-behind-a-proxy.section.xml41
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/installing-from-other-distro.section.xml388
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/installing-pxe.section.xml42
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/installing-usb.section.xml35
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/installing-virtualbox-guest.section.xml92
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/installing.chapter.xml642
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/obtaining.chapter.xml48
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/installation/upgrading.chapter.xml152
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2009.section.xml10
-rw-r--r--nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml36
-rw-r--r--nixpkgs/nixos/doc/manual/installation/changing-config.chapter.md100
-rw-r--r--nixpkgs/nixos/doc/manual/installation/changing-config.xml97
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installation.xml8
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.section.md29
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.xml48
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.section.md279
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.xml364
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-pxe.section.md32
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-pxe.xml50
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-usb.section.md31
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-usb.xml40
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.section.md59
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.xml103
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing.chapter.md479
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing.xml616
-rw-r--r--nixpkgs/nixos/doc/manual/installation/obtaining.chapter.md26
-rw-r--r--nixpkgs/nixos/doc/manual/installation/obtaining.xml54
-rw-r--r--nixpkgs/nixos/doc/manual/installation/upgrading.chapter.md118
-rw-r--r--nixpkgs/nixos/doc/manual/installation/upgrading.xml139
-rw-r--r--nixpkgs/nixos/doc/manual/man-nixos-rebuild.xml16
-rwxr-xr-xnixpkgs/nixos/doc/manual/md-to-db.sh18
-rw-r--r--nixpkgs/nixos/doc/manual/release-notes/rl-2009.section.md4
-rw-r--r--nixpkgs/nixos/doc/manual/release-notes/rl-2111.section.md11
-rw-r--r--nixpkgs/nixos/modules/config/update-users-groups.pl47
-rw-r--r--nixpkgs/nixos/modules/config/users-groups.nix6
-rw-r--r--nixpkgs/nixos/modules/misc/documentation.nix30
-rw-r--r--nixpkgs/nixos/modules/module-list.nix4
-rw-r--r--nixpkgs/nixos/modules/programs/bash/bash-completion.nix2
-rw-r--r--nixpkgs/nixos/modules/programs/bash/bash.nix8
-rw-r--r--nixpkgs/nixos/modules/programs/command-not-found/command-not-found.nix12
-rw-r--r--nixpkgs/nixos/modules/programs/environment.nix3
-rw-r--r--nixpkgs/nixos/modules/programs/git.nix45
-rw-r--r--nixpkgs/nixos/modules/rename.nix1
-rw-r--r--nixpkgs/nixos/modules/services/amqp/rabbitmq.nix27
-rw-r--r--nixpkgs/nixos/modules/services/audio/spotifyd.nix27
-rw-r--r--nixpkgs/nixos/modules/services/backup/sanoid.nix9
-rw-r--r--nixpkgs/nixos/modules/services/backup/znapzend.nix2
-rw-r--r--nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix2
-rw-r--r--nixpkgs/nixos/modules/services/games/crossfire-server.nix177
-rw-r--r--nixpkgs/nixos/modules/services/games/deliantra-server.nix170
-rw-r--r--nixpkgs/nixos/modules/services/logging/promtail.nix4
-rw-r--r--nixpkgs/nixos/modules/services/misc/nix-ssh-serve.nix8
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/grafana.nix27
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/nagios.nix2
-rw-r--r--nixpkgs/nixos/modules/services/network-filesystems/ipfs.nix20
-rw-r--r--nixpkgs/nixos/modules/services/networking/firefox/sync-server.nix2
-rw-r--r--nixpkgs/nixos/modules/services/networking/gnunet.nix22
-rw-r--r--nixpkgs/nixos/modules/services/networking/wicd.nix40
-rw-r--r--nixpkgs/nixos/modules/services/search/elasticsearch.nix12
-rw-r--r--nixpkgs/nixos/modules/services/security/privacyidea.nix6
-rw-r--r--nixpkgs/nixos/modules/services/video/mirakurun.nix2
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/sx.nix2
-rw-r--r--nixpkgs/nixos/modules/services/x11/extra-layouts.nix3
-rw-r--r--nixpkgs/nixos/modules/system/activation/activation-script.nix100
-rw-r--r--nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl6
-rw-r--r--nixpkgs/nixos/modules/system/activation/top-level.nix9
-rw-r--r--nixpkgs/nixos/modules/tasks/lvm.nix26
-rw-r--r--nixpkgs/nixos/tests/handbrake.nix2
-rw-r--r--nixpkgs/nixos/tests/kernel-generic.nix1
-rw-r--r--nixpkgs/nixos/tests/miniflux.nix2
-rw-r--r--nixpkgs/nixos/tests/mutable-users.nix28
286 files changed, 14385 insertions, 7729 deletions
diff --git a/nixpkgs/nixos/doc/manual/administration/boot-problems.section.md b/nixpkgs/nixos/doc/manual/administration/boot-problems.section.md
index dee83e7ec225..bca4fdc3fb38 100644
--- a/nixpkgs/nixos/doc/manual/administration/boot-problems.section.md
+++ b/nixpkgs/nixos/doc/manual/administration/boot-problems.section.md
@@ -16,7 +16,7 @@ If NixOS fails to boot, there are a number of kernel command line parameters tha
 
 `boot.debug1mounts`
 
-: Like `boot.debug1` or `boot.debug1devices`, but runs stage1 until all filesystems that are mounted during initrd are mounted (see [neededForBoot](#opt-fileSystems._name_.neededForBoot)). As a motivating example, this could be useful if you've forgotten to set [neededForBoot](options.html#opt-fileSystems._name_.neededForBoot) on a file system.
+: Like `boot.debug1` or `boot.debug1devices`, but runs stage1 until all filesystems that are mounted during initrd are mounted (see [neededForBoot](#opt-fileSystems._name_.neededForBoot)). As a motivating example, this could be useful if you've forgotten to set [neededForBoot](#opt-fileSystems._name_.neededForBoot) on a file system.
 
 `boot.trace`
 
diff --git a/nixpkgs/nixos/doc/manual/administration/cleaning-store.chapter.md b/nixpkgs/nixos/doc/manual/administration/cleaning-store.chapter.md
new file mode 100644
index 000000000000..fb2090b31d84
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/cleaning-store.chapter.md
@@ -0,0 +1,62 @@
+# Cleaning the Nix Store {#sec-nix-gc}
+
+Nix has a purely functional model, meaning that packages are never
+upgraded in place. Instead new versions of packages end up in a
+different location in the Nix store (`/nix/store`). You should
+periodically run Nix's *garbage collector* to remove old, unreferenced
+packages. This is easy:
+
+```ShellSession
+$ nix-collect-garbage
+```
+
+Alternatively, you can use a systemd unit that does the same in the
+background:
+
+```ShellSession
+# systemctl start nix-gc.service
+```
+
+You can tell NixOS in `configuration.nix` to run this unit automatically
+at certain points in time, for instance, every night at 03:15:
+
+```nix
+nix.gc.automatic = true;
+nix.gc.dates = "03:15";
+```
+
+The commands above do not remove garbage collector roots, such as old
+system configurations. Thus they do not remove the ability to roll back
+to previous configurations. The following command deletes old roots,
+removing the ability to roll back to them:
+
+```ShellSession
+$ nix-collect-garbage -d
+```
+
+You can also do this for specific profiles, e.g.
+
+```ShellSession
+$ nix-env -p /nix/var/nix/profiles/per-user/eelco/profile --delete-generations old
+```
+
+Note that NixOS system configurations are stored in the profile
+`/nix/var/nix/profiles/system`.
+
+Another way to reclaim disk space (often as much as 40% of the size of
+the Nix store) is to run Nix's store optimiser, which seeks out
+identical files in the store and replaces them with hard links to a
+single copy.
+
+```ShellSession
+$ nix-store --optimise
+```
+
+Since this command needs to read the entire Nix store, it can take quite
+a while to finish.
+
+## NixOS Boot Entries {#sect-nixos-gc-boot-entries}
+
+If your `/boot` partition runs out of space, after clearing old profiles
+you must rebuild your system with `nixos-rebuild` to update the `/boot`
+partition and clear space.
diff --git a/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml b/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml
deleted file mode 100644
index 526803e429ba..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-nix-gc">
- <title>Cleaning the Nix Store</title>
- <para>
-  Nix has a purely functional model, meaning that packages are never upgraded
-  in place. Instead new versions of packages end up in a different location in
-  the Nix store (<filename>/nix/store</filename>). You should periodically run
-  Nix’s <emphasis>garbage collector</emphasis> to remove old, unreferenced
-  packages. This is easy:
-<screen>
-<prompt>$ </prompt>nix-collect-garbage
-</screen>
-  Alternatively, you can use a systemd unit that does the same in the
-  background:
-<screen>
-<prompt># </prompt>systemctl start nix-gc.service
-</screen>
-  You can tell NixOS in <filename>configuration.nix</filename> to run this unit
-  automatically at certain points in time, for instance, every night at 03:15:
-<programlisting>
-<xref linkend="opt-nix.gc.automatic"/> = true;
-<xref linkend="opt-nix.gc.dates"/> = "03:15";
-</programlisting>
- </para>
- <para>
-  The commands above do not remove garbage collector roots, such as old system
-  configurations. Thus they do not remove the ability to roll back to previous
-  configurations. The following command deletes old roots, removing the ability
-  to roll back to them:
-<screen>
-<prompt>$ </prompt>nix-collect-garbage -d
-</screen>
-  You can also do this for specific profiles, e.g.
-<screen>
-<prompt>$ </prompt>nix-env -p /nix/var/nix/profiles/per-user/eelco/profile --delete-generations old
-</screen>
-  Note that NixOS system configurations are stored in the profile
-  <filename>/nix/var/nix/profiles/system</filename>.
- </para>
- <para>
-  Another way to reclaim disk space (often as much as 40% of the size of the
-  Nix store) is to run Nix’s store optimiser, which seeks out identical files
-  in the store and replaces them with hard links to a single copy.
-<screen>
-<prompt>$ </prompt>nix-store --optimise
-</screen>
-  Since this command needs to read the entire Nix store, it can take quite a
-  while to finish.
- </para>
- <section xml:id="sect-nixos-gc-boot-entries">
-  <title>NixOS Boot Entries</title>
-
-  <para>
-   If your <filename>/boot</filename> partition runs out of space, after
-   clearing old profiles you must rebuild your system with
-   <literal>nixos-rebuild</literal> to update the <filename>/boot</filename>
-   partition and clear space.
-  </para>
- </section>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/administration/container-networking.section.md b/nixpkgs/nixos/doc/manual/administration/container-networking.section.md
new file mode 100644
index 000000000000..0873768376cc
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/container-networking.section.md
@@ -0,0 +1,44 @@
+# Container Networking {#sec-container-networking}
+
+When you create a container using `nixos-container create`, it gets it
+own private IPv4 address in the range `10.233.0.0/16`. You can get the
+container's IPv4 address as follows:
+
+```ShellSession
+# nixos-container show-ip foo
+10.233.4.2
+
+$ ping -c1 10.233.4.2
+64 bytes from 10.233.4.2: icmp_seq=1 ttl=64 time=0.106 ms
+```
+
+Networking is implemented using a pair of virtual Ethernet devices. The
+network interface in the container is called `eth0`, while the matching
+interface in the host is called `ve-container-name` (e.g., `ve-foo`).
+The container has its own network namespace and the `CAP_NET_ADMIN`
+capability, so it can perform arbitrary network configuration such as
+setting up firewall rules, without affecting or having access to the
+host's network.
+
+By default, containers cannot talk to the outside network. If you want
+that, you should set up Network Address Translation (NAT) rules on the
+host to rewrite container traffic to use your external IP address. This
+can be accomplished using the following configuration on the host:
+
+```nix
+networking.nat.enable = true;
+networking.nat.internalInterfaces = ["ve-+"];
+networking.nat.externalInterface = "eth0";
+```
+
+where `eth0` should be replaced with the desired external interface.
+Note that `ve-+` is a wildcard that matches all container interfaces.
+
+If you are using Network Manager, you need to explicitly prevent it from
+managing container interfaces:
+
+```nix
+networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
+```
+
+You may need to restart your system for the changes to take effect.
diff --git a/nixpkgs/nixos/doc/manual/administration/container-networking.xml b/nixpkgs/nixos/doc/manual/administration/container-networking.xml
deleted file mode 100644
index 42486f01fe8c..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/container-networking.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<section  xmlns="http://docbook.org/ns/docbook"
-          xmlns:xlink="http://www.w3.org/1999/xlink"
-          xmlns:xi="http://www.w3.org/2001/XInclude"
-          version="5.0"
-          xml:id="sec-container-networking">
- <title>Container Networking</title>
-
- <para>
-  When you create a container using <literal>nixos-container create</literal>,
-  it gets it own private IPv4 address in the range
-  <literal>10.233.0.0/16</literal>. You can get the container’s IPv4 address
-  as follows:
-<screen>
-<prompt># </prompt>nixos-container show-ip foo
-10.233.4.2
-
-<prompt>$ </prompt>ping -c1 10.233.4.2
-64 bytes from 10.233.4.2: icmp_seq=1 ttl=64 time=0.106 ms
-</screen>
- </para>
-
- <para>
-  Networking is implemented using a pair of virtual Ethernet devices. The
-  network interface in the container is called <literal>eth0</literal>, while
-  the matching interface in the host is called
-  <literal>ve-<replaceable>container-name</replaceable></literal> (e.g.,
-  <literal>ve-foo</literal>). The container has its own network namespace and
-  the <literal>CAP_NET_ADMIN</literal> capability, so it can perform arbitrary
-  network configuration such as setting up firewall rules, without affecting or
-  having access to the host’s network.
- </para>
-
- <para>
-  By default, containers cannot talk to the outside network. If you want that,
-  you should set up Network Address Translation (NAT) rules on the host to
-  rewrite container traffic to use your external IP address. This can be
-  accomplished using the following configuration on the host:
-<programlisting>
-<xref linkend="opt-networking.nat.enable"/> = true;
-<xref linkend="opt-networking.nat.internalInterfaces"/> = ["ve-+"];
-<xref linkend="opt-networking.nat.externalInterface"/> = "eth0";
-</programlisting>
-  where <literal>eth0</literal> should be replaced with the desired external
-  interface. Note that <literal>ve-+</literal> is a wildcard that matches all
-  container interfaces.
- </para>
-
- <para>
-  If you are using Network Manager, you need to explicitly prevent it from
-  managing container interfaces:
-<programlisting>
-networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
-</programlisting>
- </para>
-
- <para>
-  You may need to restart your system for the changes to take effect.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/administration/containers.chapter.md b/nixpkgs/nixos/doc/manual/administration/containers.chapter.md
new file mode 100644
index 000000000000..ea51f91f698f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/containers.chapter.md
@@ -0,0 +1,28 @@
+# Container Management {#ch-containers}
+
+NixOS allows you to easily run other NixOS instances as *containers*.
+Containers are a light-weight approach to virtualisation that runs
+software in the container at the same speed as in the host system. NixOS
+containers share the Nix store of the host, making container creation
+very efficient.
+
+::: {.warning}
+Currently, NixOS containers are not perfectly isolated from the host
+system. This means that a user with root access to the container can do
+things that affect the host. So you should not give container root
+access to untrusted users.
+:::
+
+NixOS containers can be created in two ways: imperatively, using the
+command `nixos-container`, and declaratively, by specifying them in your
+`configuration.nix`. The declarative approach implies that containers
+get upgraded along with your host system when you run `nixos-rebuild`,
+which is often not what you want. By contrast, in the imperative
+approach, containers are configured and updated independently from the
+host system.
+
+```{=docbook}
+<xi:include href="imperative-containers.section.xml" />
+<xi:include href="declarative-containers.section.xml" />
+<xi:include href="container-networking.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/administration/containers.xml b/nixpkgs/nixos/doc/manual/administration/containers.xml
deleted file mode 100644
index 0d3355e56a58..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/containers.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="ch-containers">
- <title>Container Management</title>
- <para>
-  NixOS allows you to easily run other NixOS instances as
-  <emphasis>containers</emphasis>. Containers are a light-weight approach to
-  virtualisation that runs software in the container at the same speed as in
-  the host system. NixOS containers share the Nix store of the host, making
-  container creation very efficient.
- </para>
- <warning>
-  <para>
-   Currently, NixOS containers are not perfectly isolated from the host system.
-   This means that a user with root access to the container can do things that
-   affect the host. So you should not give container root access to untrusted
-   users.
-  </para>
- </warning>
- <para>
-  NixOS containers can be created in two ways: imperatively, using the command
-  <command>nixos-container</command>, and declaratively, by specifying them in
-  your <filename>configuration.nix</filename>. The declarative approach implies
-  that containers get upgraded along with your host system when you run
-  <command>nixos-rebuild</command>, which is often not what you want. By
-  contrast, in the imperative approach, containers are configured and updated
-  independently from the host system.
- </para>
- <xi:include href="imperative-containers.xml" />
- <xi:include href="declarative-containers.xml" />
- <xi:include href="container-networking.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/administration/control-groups.chapter.md b/nixpkgs/nixos/doc/manual/administration/control-groups.chapter.md
new file mode 100644
index 000000000000..abe8dd80b5ab
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/control-groups.chapter.md
@@ -0,0 +1,59 @@
+# Control Groups {#sec-cgroups}
+
+To keep track of the processes in a running system, systemd uses
+*control groups* (cgroups). A control group is a set of processes used
+to allocate resources such as CPU, memory or I/O bandwidth. There can be
+multiple control group hierarchies, allowing each kind of resource to be
+managed independently.
+
+The command `systemd-cgls` lists all control groups in the `systemd`
+hierarchy, which is what systemd uses to keep track of the processes
+belonging to each service or user session:
+
+```ShellSession
+$ systemd-cgls
+├─user
+│ └─eelco
+│   └─c1
+│     ├─ 2567 -:0
+│     ├─ 2682 kdeinit4: kdeinit4 Running...
+│     ├─ ...
+│     └─10851 sh -c less -R
+└─system
+  ├─httpd.service
+  │ ├─2444 httpd -f /nix/store/3pyacby5cpr55a03qwbnndizpciwq161-httpd.conf -DNO_DETACH
+  │ └─...
+  ├─dhcpcd.service
+  │ └─2376 dhcpcd --config /nix/store/f8dif8dsi2yaa70n03xir8r653776ka6-dhcpcd.conf
+  └─ ...
+```
+
+Similarly, `systemd-cgls cpu` shows the cgroups in the CPU hierarchy,
+which allows per-cgroup CPU scheduling priorities. By default, every
+systemd service gets its own CPU cgroup, while all user sessions are in
+the top-level CPU cgroup. This ensures, for instance, that a thousand
+run-away processes in the `httpd.service` cgroup cannot starve the CPU
+for one process in the `postgresql.service` cgroup. (By contrast, it
+they were in the same cgroup, then the PostgreSQL process would get
+1/1001 of the cgroup's CPU time.) You can limit a service's CPU share in
+`configuration.nix`:
+
+```nix
+systemd.services.httpd.serviceConfig.CPUShares = 512;
+```
+
+By default, every cgroup has 1024 CPU shares, so this will halve the CPU
+allocation of the `httpd.service` cgroup.
+
+There also is a `memory` hierarchy that controls memory allocation
+limits; by default, all processes are in the top-level cgroup, so any
+service or session can exhaust all available memory. Per-cgroup memory
+limits can be specified in `configuration.nix`; for instance, to limit
+`httpd.service` to 512 MiB of RAM (excluding swap):
+
+```nix
+systemd.services.httpd.serviceConfig.MemoryLimit = "512M";
+```
+
+The command `systemd-cgtop` shows a continuously updated list of all
+cgroups with their CPU and memory usage.
diff --git a/nixpkgs/nixos/doc/manual/administration/control-groups.xml b/nixpkgs/nixos/doc/manual/administration/control-groups.xml
deleted file mode 100644
index 16d03cc0d1ab..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/control-groups.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-cgroups">
- <title>Control Groups</title>
- <para>
-  To keep track of the processes in a running system, systemd uses
-  <emphasis>control groups</emphasis> (cgroups). A control group is a set of
-  processes used to allocate resources such as CPU, memory or I/O bandwidth.
-  There can be multiple control group hierarchies, allowing each kind of
-  resource to be managed independently.
- </para>
- <para>
-  The command <command>systemd-cgls</command> lists all control groups in the
-  <literal>systemd</literal> hierarchy, which is what systemd uses to keep
-  track of the processes belonging to each service or user session:
-<screen>
-<prompt>$ </prompt>systemd-cgls
-├─user
-│ └─eelco
-│   └─c1
-│     ├─ 2567 -:0
-│     ├─ 2682 kdeinit4: kdeinit4 Running...
-│     ├─ <replaceable>...</replaceable>
-│     └─10851 sh -c less -R
-└─system
-  ├─httpd.service
-  │ ├─2444 httpd -f /nix/store/3pyacby5cpr55a03qwbnndizpciwq161-httpd.conf -DNO_DETACH
-  │ └─<replaceable>...</replaceable>
-  ├─dhcpcd.service
-  │ └─2376 dhcpcd --config /nix/store/f8dif8dsi2yaa70n03xir8r653776ka6-dhcpcd.conf
-  └─ <replaceable>...</replaceable>
-</screen>
-  Similarly, <command>systemd-cgls cpu</command> shows the cgroups in the CPU
-  hierarchy, which allows per-cgroup CPU scheduling priorities. By default,
-  every systemd service gets its own CPU cgroup, while all user sessions are in
-  the top-level CPU cgroup. This ensures, for instance, that a thousand
-  run-away processes in the <literal>httpd.service</literal> cgroup cannot
-  starve the CPU for one process in the <literal>postgresql.service</literal>
-  cgroup. (By contrast, it they were in the same cgroup, then the PostgreSQL
-  process would get 1/1001 of the cgroup’s CPU time.) You can limit a
-  service’s CPU share in <filename>configuration.nix</filename>:
-<programlisting>
-<link linkend="opt-systemd.services._name_.serviceConfig">systemd.services.httpd.serviceConfig</link>.CPUShares = 512;
-</programlisting>
-  By default, every cgroup has 1024 CPU shares, so this will halve the CPU
-  allocation of the <literal>httpd.service</literal> cgroup.
- </para>
- <para>
-  There also is a <literal>memory</literal> hierarchy that controls memory
-  allocation limits; by default, all processes are in the top-level cgroup, so
-  any service or session can exhaust all available memory. Per-cgroup memory
-  limits can be specified in <filename>configuration.nix</filename>; for
-  instance, to limit <literal>httpd.service</literal> to 512 MiB of RAM
-  (excluding swap):
-<programlisting>
-<link linkend="opt-systemd.services._name_.serviceConfig">systemd.services.httpd.serviceConfig</link>.MemoryLimit = "512M";
-</programlisting>
- </para>
- <para>
-  The command <command>systemd-cgtop</command> shows a continuously updated
-  list of all cgroups with their CPU and memory usage.
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/administration/declarative-containers.section.md b/nixpkgs/nixos/doc/manual/administration/declarative-containers.section.md
new file mode 100644
index 000000000000..273672fc10ca
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/declarative-containers.section.md
@@ -0,0 +1,48 @@
+# Declarative Container Specification {#sec-declarative-containers}
+
+You can also specify containers and their configuration in the host's
+`configuration.nix`. For example, the following specifies that there
+shall be a container named `database` running PostgreSQL:
+
+```nix
+containers.database =
+  { config =
+      { config, pkgs, ... }:
+      { services.postgresql.enable = true;
+      services.postgresql.package = pkgs.postgresql_9_6;
+      };
+  };
+```
+
+If you run `nixos-rebuild switch`, the container will be built. If the
+container was already running, it will be updated in place, without
+rebooting. The container can be configured to start automatically by
+setting `containers.database.autoStart = true` in its configuration.
+
+By default, declarative containers share the network namespace of the
+host, meaning that they can listen on (privileged) ports. However, they
+cannot change the network configuration. You can give a container its
+own network as follows:
+
+```nix
+containers.database = {
+  privateNetwork = true;
+  hostAddress = "192.168.100.10";
+  localAddress = "192.168.100.11";
+};
+```
+
+This gives the container a private virtual Ethernet interface with IP
+address `192.168.100.11`, which is hooked up to a virtual Ethernet
+interface on the host with IP address `192.168.100.10`. (See the next
+section for details on container networking.)
+
+To disable the container, just remove it from `configuration.nix` and
+run `nixos-rebuild
+  switch`. Note that this will not delete the root directory of the
+container in `/var/lib/containers`. Containers can be destroyed using
+the imperative method: `nixos-container destroy foo`.
+
+Declarative containers can be started and stopped using the
+corresponding systemd service, e.g.
+`systemctl start container@database`.
diff --git a/nixpkgs/nixos/doc/manual/administration/declarative-containers.xml b/nixpkgs/nixos/doc/manual/administration/declarative-containers.xml
deleted file mode 100644
index d03dbc4d7055..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/declarative-containers.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<section  xmlns="http://docbook.org/ns/docbook"
-          xmlns:xlink="http://www.w3.org/1999/xlink"
-          xmlns:xi="http://www.w3.org/2001/XInclude"
-          version="5.0"
-          xml:id="sec-declarative-containers">
- <title>Declarative Container Specification</title>
-
- <para>
-  You can also specify containers and their configuration in the host’s
-  <filename>configuration.nix</filename>. For example, the following specifies
-  that there shall be a container named <literal>database</literal> running
-  PostgreSQL:
-<programlisting>
-containers.database =
-  { config =
-      { config, pkgs, ... }:
-      { <xref linkend="opt-services.postgresql.enable"/> = true;
-      <xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql_9_6;
-      };
-  };
-</programlisting>
-  If you run <literal>nixos-rebuild switch</literal>, the container will be
-  built. If the container was already running, it will be updated in place,
-  without rebooting. The container can be configured to start automatically by
-  setting <literal>containers.database.autoStart = true</literal> in its
-  configuration.
- </para>
-
- <para>
-  By default, declarative containers share the network namespace of the host,
-  meaning that they can listen on (privileged) ports. However, they cannot
-  change the network configuration. You can give a container its own network as
-  follows:
-<programlisting>
-containers.database = {
-  <link linkend="opt-containers._name_.privateNetwork">privateNetwork</link> = true;
-  <link linkend="opt-containers._name_.hostAddress">hostAddress</link> = "192.168.100.10";
-  <link linkend="opt-containers._name_.localAddress">localAddress</link> = "192.168.100.11";
-};
-</programlisting>
-  This gives the container a private virtual Ethernet interface with IP address
-  <literal>192.168.100.11</literal>, which is hooked up to a virtual Ethernet
-  interface on the host with IP address <literal>192.168.100.10</literal>. (See
-  the next section for details on container networking.)
- </para>
-
- <para>
-  To disable the container, just remove it from
-  <filename>configuration.nix</filename> and run <literal>nixos-rebuild
-  switch</literal>. Note that this will not delete the root directory of the
-  container in <literal>/var/lib/containers</literal>. Containers can be
-  destroyed using the imperative method: <literal>nixos-container destroy
-  foo</literal>.
- </para>
-
- <para>
-  Declarative containers can be started and stopped using the corresponding
-  systemd service, e.g. <literal>systemctl start container@database</literal>.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/administration/imperative-containers.section.md b/nixpkgs/nixos/doc/manual/administration/imperative-containers.section.md
new file mode 100644
index 000000000000..05196bf5d819
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/imperative-containers.section.md
@@ -0,0 +1,115 @@
+# Imperative Container Management {#sec-imperative-containers}
+
+We'll cover imperative container management using `nixos-container`
+first. Be aware that container management is currently only possible as
+`root`.
+
+You create a container with identifier `foo` as follows:
+
+```ShellSession
+# nixos-container create foo
+```
+
+This creates the container's root directory in `/var/lib/containers/foo`
+and a small configuration file in `/etc/containers/foo.conf`. It also
+builds the container's initial system configuration and stores it in
+`/nix/var/nix/profiles/per-container/foo/system`. You can modify the
+initial configuration of the container on the command line. For
+instance, to create a container that has `sshd` running, with the given
+public key for `root`:
+
+```ShellSession
+# nixos-container create foo --config '
+  services.openssh.enable = true;
+  users.users.root.openssh.authorizedKeys.keys = ["ssh-dss AAAAB3N…"];
+'
+```
+
+By default the next free address in the `10.233.0.0/16` subnet will be
+chosen as container IP. This behavior can be altered by setting
+`--host-address` and `--local-address`:
+
+```ShellSession
+# nixos-container create test --config-file test-container.nix \
+    --local-address 10.235.1.2 --host-address 10.235.1.1
+```
+
+Creating a container does not start it. To start the container, run:
+
+```ShellSession
+# nixos-container start foo
+```
+
+This command will return as soon as the container has booted and has
+reached `multi-user.target`. On the host, the container runs within a
+systemd unit called `container@container-name.service`. Thus, if
+something went wrong, you can get status info using `systemctl`:
+
+```ShellSession
+# systemctl status container@foo
+```
+
+If the container has started successfully, you can log in as root using
+the `root-login` operation:
+
+```ShellSession
+# nixos-container root-login foo
+[root@foo:~]#
+```
+
+Note that only root on the host can do this (since there is no
+authentication). You can also get a regular login prompt using the
+`login` operation, which is available to all users on the host:
+
+```ShellSession
+# nixos-container login foo
+foo login: alice
+Password: ***
+```
+
+With `nixos-container run`, you can execute arbitrary commands in the
+container:
+
+```ShellSession
+# nixos-container run foo -- uname -a
+Linux foo 3.4.82 #1-NixOS SMP Thu Mar 20 14:44:05 UTC 2014 x86_64 GNU/Linux
+```
+
+There are several ways to change the configuration of the container.
+First, on the host, you can edit
+`/var/lib/container/name/etc/nixos/configuration.nix`, and run
+
+```ShellSession
+# nixos-container update foo
+```
+
+This will build and activate the new configuration. You can also specify
+a new configuration on the command line:
+
+```ShellSession
+# nixos-container update foo --config '
+  services.httpd.enable = true;
+  services.httpd.adminAddr = "foo@example.org";
+  networking.firewall.allowedTCPPorts = [ 80 ];
+'
+
+# curl http://$(nixos-container show-ip foo)/
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">…
+```
+
+However, note that this will overwrite the container's
+`/etc/nixos/configuration.nix`.
+
+Alternatively, you can change the configuration from within the
+container itself by running `nixos-rebuild switch` inside the container.
+Note that the container by default does not have a copy of the NixOS
+channel, so you should run `nix-channel --update` first.
+
+Containers can be stopped and started using `nixos-container
+  stop` and `nixos-container start`, respectively, or by using
+`systemctl` on the container's service unit. To destroy a container,
+including its file system, do
+
+```ShellSession
+# nixos-container destroy foo
+```
diff --git a/nixpkgs/nixos/doc/manual/administration/imperative-containers.xml b/nixpkgs/nixos/doc/manual/administration/imperative-containers.xml
deleted file mode 100644
index bc19acf9f690..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/imperative-containers.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<section  xmlns="http://docbook.org/ns/docbook"
-          xmlns:xlink="http://www.w3.org/1999/xlink"
-          xmlns:xi="http://www.w3.org/2001/XInclude"
-          version="5.0"
-          xml:id="sec-imperative-containers">
- <title>Imperative Container Management</title>
-
- <para>
-  We’ll cover imperative container management using
-  <command>nixos-container</command> first. Be aware that container management
-  is currently only possible as <literal>root</literal>.
- </para>
-
- <para>
-  You create a container with identifier <literal>foo</literal> as follows:
-<screen>
-<prompt># </prompt>nixos-container create <replaceable>foo</replaceable>
-</screen>
-  This creates the container’s root directory in
-  <filename>/var/lib/containers/<replaceable>foo</replaceable></filename> and a small configuration file
-  in <filename>/etc/containers/<replaceable>foo</replaceable>.conf</filename>. It also builds the
-  container’s initial system configuration and stores it in
-  <filename>/nix/var/nix/profiles/per-container/<replaceable>foo</replaceable>/system</filename>. You can
-  modify the initial configuration of the container on the command line. For
-  instance, to create a container that has <command>sshd</command> running,
-  with the given public key for <literal>root</literal>:
-<screen>
-<prompt># </prompt>nixos-container create <replaceable>foo</replaceable> --config '
-  <xref linkend="opt-services.openssh.enable"/> = true;
-  <link linkend="opt-users.users._name_.openssh.authorizedKeys.keys">users.users.root.openssh.authorizedKeys.keys</link> = ["ssh-dss AAAAB3N…"];
-'
-</screen>
-  By default the next free address in the <literal>10.233.0.0/16</literal> subnet will be chosen
-  as container IP. This behavior can be altered by setting <literal>--host-address</literal> and
-  <literal>--local-address</literal>:
-<screen>
-<prompt># </prompt>nixos-container create test --config-file test-container.nix \
-    --local-address 10.235.1.2 --host-address 10.235.1.1
-</screen>
- </para>
-
- <para>
-  Creating a container does not start it. To start the container, run:
-<screen>
-<prompt># </prompt>nixos-container start <replaceable>foo</replaceable>
-</screen>
-  This command will return as soon as the container has booted and has reached
-  <literal>multi-user.target</literal>. On the host, the container runs within
-  a systemd unit called
-  <literal>container@<replaceable>container-name</replaceable>.service</literal>.
-  Thus, if something went wrong, you can get status info using
-  <command>systemctl</command>:
-<screen>
-<prompt># </prompt>systemctl status container@<replaceable>foo</replaceable>
-</screen>
- </para>
-
- <para>
-  If the container has started successfully, you can log in as root using the
-  <command>root-login</command> operation:
-<screen>
-<prompt># </prompt>nixos-container root-login <replaceable>foo</replaceable>
-<prompt>[root@foo:~]#</prompt>
-</screen>
-  Note that only root on the host can do this (since there is no
-  authentication). You can also get a regular login prompt using the
-  <command>login</command> operation, which is available to all users on the
-  host:
-<screen>
-<prompt># </prompt>nixos-container login <replaceable>foo</replaceable>
-foo login: alice
-Password: ***
-</screen>
-  With <command>nixos-container run</command>, you can execute arbitrary
-  commands in the container:
-<screen>
-<prompt># </prompt>nixos-container run <replaceable>foo</replaceable> -- uname -a
-Linux foo 3.4.82 #1-NixOS SMP Thu Mar 20 14:44:05 UTC 2014 x86_64 GNU/Linux
-</screen>
- </para>
-
- <para>
-  There are several ways to change the configuration of the container. First,
-  on the host, you can edit
-  <literal>/var/lib/container/<replaceable>name</replaceable>/etc/nixos/configuration.nix</literal>,
-  and run
-<screen>
-<prompt># </prompt>nixos-container update <replaceable>foo</replaceable>
-</screen>
-  This will build and activate the new configuration. You can also specify a
-  new configuration on the command line:
-<screen>
-<prompt># </prompt>nixos-container update <replaceable>foo</replaceable> --config '
-  <xref linkend="opt-services.httpd.enable"/> = true;
-  <xref linkend="opt-services.httpd.adminAddr"/> = "foo@example.org";
-  <xref linkend="opt-networking.firewall.allowedTCPPorts"/> = [ 80 ];
-'
-
-<prompt># </prompt>curl http://$(nixos-container show-ip <replaceable>foo</replaceable>)/
-&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">…
-</screen>
-  However, note that this will overwrite the container’s
-  <filename>/etc/nixos/configuration.nix</filename>.
- </para>
-
- <para>
-  Alternatively, you can change the configuration from within the container
-  itself by running <command>nixos-rebuild switch</command> inside the
-  container. Note that the container by default does not have a copy of the
-  NixOS channel, so you should run <command>nix-channel --update</command>
-  first.
- </para>
-
- <para>
-  Containers can be stopped and started using <literal>nixos-container
-  stop</literal> and <literal>nixos-container start</literal>, respectively, or
-  by using <command>systemctl</command> on the container’s service unit. To
-  destroy a container, including its file system, do
-<screen>
-<prompt># </prompt>nixos-container destroy <replaceable>foo</replaceable>
-</screen>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/administration/logging.chapter.md b/nixpkgs/nixos/doc/manual/administration/logging.chapter.md
new file mode 100644
index 000000000000..4ce6f5e9fa72
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/logging.chapter.md
@@ -0,0 +1,38 @@
+# Logging {#sec-logging}
+
+System-wide logging is provided by systemd's *journal*, which subsumes
+traditional logging daemons such as syslogd and klogd. Log entries are
+kept in binary files in `/var/log/journal/`. The command `journalctl`
+allows you to see the contents of the journal. For example,
+
+```ShellSession
+$ journalctl -b
+```
+
+shows all journal entries since the last reboot. (The output of
+`journalctl` is piped into `less` by default.) You can use various
+options and match operators to restrict output to messages of interest.
+For instance, to get all messages from PostgreSQL:
+
+```ShellSession
+$ journalctl -u postgresql.service
+-- Logs begin at Mon, 2013-01-07 13:28:01 CET, end at Tue, 2013-01-08 01:09:57 CET. --
+...
+Jan 07 15:44:14 hagbard postgres[2681]: [2-1] LOG:  database system is shut down
+-- Reboot --
+Jan 07 15:45:10 hagbard postgres[2532]: [1-1] LOG:  database system was shut down at 2013-01-07 15:44:14 CET
+Jan 07 15:45:13 hagbard postgres[2500]: [1-1] LOG:  database system is ready to accept connections
+```
+
+Or to get all messages since the last reboot that have at least a
+"critical" severity level:
+
+```ShellSession
+$ journalctl -b -p crit
+Dec 17 21:08:06 mandark sudo[3673]: pam_unix(sudo:auth): auth could not identify password for [alice]
+Dec 29 01:30:22 mandark kernel[6131]: [1053513.909444] CPU6: Core temperature above threshold, cpu clock throttled (total events = 1)
+```
+
+The system journal is readable by root and by users in the `wheel` and
+`systemd-journal` groups. All users have a private journal that can be
+read using `journalctl`.
diff --git a/nixpkgs/nixos/doc/manual/administration/logging.xml b/nixpkgs/nixos/doc/manual/administration/logging.xml
deleted file mode 100644
index da4877fcdf08..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/logging.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-logging">
- <title>Logging</title>
- <para>
-  System-wide logging is provided by systemd’s <emphasis>journal</emphasis>,
-  which subsumes traditional logging daemons such as syslogd and klogd. Log
-  entries are kept in binary files in <filename>/var/log/journal/</filename>.
-  The command <literal>journalctl</literal> allows you to see the contents of
-  the journal. For example,
-<screen>
-<prompt>$ </prompt>journalctl -b
-</screen>
-  shows all journal entries since the last reboot. (The output of
-  <command>journalctl</command> is piped into <command>less</command> by
-  default.) You can use various options and match operators to restrict output
-  to messages of interest. For instance, to get all messages from PostgreSQL:
-<screen>
-<prompt>$ </prompt>journalctl -u postgresql.service
--- Logs begin at Mon, 2013-01-07 13:28:01 CET, end at Tue, 2013-01-08 01:09:57 CET. --
-...
-Jan 07 15:44:14 hagbard postgres[2681]: [2-1] LOG:  database system is shut down
--- Reboot --
-Jan 07 15:45:10 hagbard postgres[2532]: [1-1] LOG:  database system was shut down at 2013-01-07 15:44:14 CET
-Jan 07 15:45:13 hagbard postgres[2500]: [1-1] LOG:  database system is ready to accept connections
-</screen>
-  Or to get all messages since the last reboot that have at least a
-  “critical” severity level:
-<screen>
-<prompt>$ </prompt>journalctl -b -p crit
-Dec 17 21:08:06 mandark sudo[3673]: pam_unix(sudo:auth): auth could not identify password for [alice]
-Dec 29 01:30:22 mandark kernel[6131]: [1053513.909444] CPU6: Core temperature above threshold, cpu clock throttled (total events = 1)
-</screen>
- </para>
- <para>
-  The system journal is readable by root and by users in the
-  <literal>wheel</literal> and <literal>systemd-journal</literal> groups. All
-  users have a private journal that can be read using
-  <command>journalctl</command>.
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/administration/maintenance-mode.section.md b/nixpkgs/nixos/doc/manual/administration/maintenance-mode.section.md
new file mode 100644
index 000000000000..0aec013c0a9b
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/maintenance-mode.section.md
@@ -0,0 +1,11 @@
+# Maintenance Mode {#sec-maintenance-mode}
+
+You can enter rescue mode by running:
+
+```ShellSession
+# systemctl rescue
+```
+
+This will eventually give you a single-user root shell. Systemd will
+stop (almost) all system services. To get out of maintenance mode, just
+exit from the rescue shell.
diff --git a/nixpkgs/nixos/doc/manual/administration/maintenance-mode.xml b/nixpkgs/nixos/doc/manual/administration/maintenance-mode.xml
deleted file mode 100644
index 74abfdd7c663..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/maintenance-mode.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-maintenance-mode">
- <title>Maintenance Mode</title>
-
- <para>
-  You can enter rescue mode by running:
-<screen>
-<prompt># </prompt>systemctl rescue</screen>
-  This will eventually give you a single-user root shell. Systemd will stop
-  (almost) all system services. To get out of maintenance mode, just exit from
-  the rescue shell.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/administration/network-problems.section.md b/nixpkgs/nixos/doc/manual/administration/network-problems.section.md
new file mode 100644
index 000000000000..d360120d72d0
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/network-problems.section.md
@@ -0,0 +1,21 @@
+# Network Problems {#sec-nix-network-issues}
+
+Nix uses a so-called *binary cache* to optimise building a package from
+source into downloading it as a pre-built binary. That is, whenever a
+command like `nixos-rebuild` needs a path in the Nix store, Nix will try
+to download that path from the Internet rather than build it from
+source. The default binary cache is `https://cache.nixos.org/`. If this
+cache is unreachable, Nix operations may take a long time due to HTTP
+connection timeouts. You can disable the use of the binary cache by
+adding `--option use-binary-caches false`, e.g.
+
+```ShellSession
+# nixos-rebuild switch --option use-binary-caches false
+```
+
+If you have an alternative binary cache at your disposal, you can use it
+instead:
+
+```ShellSession
+# nixos-rebuild switch --option binary-caches http://my-cache.example.org/
+```
diff --git a/nixpkgs/nixos/doc/manual/administration/network-problems.xml b/nixpkgs/nixos/doc/manual/administration/network-problems.xml
deleted file mode 100644
index 1035e4e056a9..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/network-problems.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-nix-network-issues">
- <title>Network Problems</title>
-
- <para>
-  Nix uses a so-called <emphasis>binary cache</emphasis> to optimise building a
-  package from source into downloading it as a pre-built binary. That is,
-  whenever a command like <command>nixos-rebuild</command> needs a path in the
-  Nix store, Nix will try to download that path from the Internet rather than
-  build it from source. The default binary cache is
-  <uri>https://cache.nixos.org/</uri>. If this cache is unreachable, Nix
-  operations may take a long time due to HTTP connection timeouts. You can
-  disable the use of the binary cache by adding <option>--option
-  use-binary-caches false</option>, e.g.
-<screen>
-<prompt># </prompt>nixos-rebuild switch --option use-binary-caches false
-</screen>
-  If you have an alternative binary cache at your disposal, you can use it
-  instead:
-<screen>
-<prompt># </prompt>nixos-rebuild switch --option binary-caches <replaceable>http://my-cache.example.org/</replaceable>
-</screen>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/administration/rebooting.chapter.md b/nixpkgs/nixos/doc/manual/administration/rebooting.chapter.md
new file mode 100644
index 000000000000..ec4b889b1648
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/rebooting.chapter.md
@@ -0,0 +1,30 @@
+# Rebooting and Shutting Down {#sec-rebooting}
+
+The system can be shut down (and automatically powered off) by doing:
+
+```ShellSession
+# shutdown
+```
+
+This is equivalent to running `systemctl poweroff`.
+
+To reboot the system, run
+
+```ShellSession
+# reboot
+```
+
+which is equivalent to `systemctl reboot`. Alternatively, you can
+quickly reboot the system using `kexec`, which bypasses the BIOS by
+directly loading the new kernel into memory:
+
+```ShellSession
+# systemctl kexec
+```
+
+The machine can be suspended to RAM (if supported) using `systemctl suspend`,
+and suspended to disk using `systemctl hibernate`.
+
+These commands can be run by any user who is logged in locally, i.e. on
+a virtual console or in X11; otherwise, the user is asked for
+authentication.
diff --git a/nixpkgs/nixos/doc/manual/administration/rebooting.xml b/nixpkgs/nixos/doc/manual/administration/rebooting.xml
deleted file mode 100644
index c57d885c5f3c..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/rebooting.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-rebooting">
- <title>Rebooting and Shutting Down</title>
- <para>
-  The system can be shut down (and automatically powered off) by doing:
-<screen>
-<prompt># </prompt>shutdown
-</screen>
-  This is equivalent to running <command>systemctl poweroff</command>.
- </para>
- <para>
-  To reboot the system, run
-<screen>
-<prompt># </prompt>reboot
-</screen>
-  which is equivalent to <command>systemctl reboot</command>. Alternatively,
-  you can quickly reboot the system using <literal>kexec</literal>, which
-  bypasses the BIOS by directly loading the new kernel into memory:
-<screen>
-<prompt># </prompt>systemctl kexec
-</screen>
- </para>
- <para>
-  The machine can be suspended to RAM (if supported) using <command>systemctl
-  suspend</command>, and suspended to disk using <command>systemctl
-  hibernate</command>.
- </para>
- <para>
-  These commands can be run by any user who is logged in locally, i.e. on a
-  virtual console or in X11; otherwise, the user is asked for authentication.
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/administration/rollback.section.md b/nixpkgs/nixos/doc/manual/administration/rollback.section.md
new file mode 100644
index 000000000000..290d685a2a18
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/rollback.section.md
@@ -0,0 +1,38 @@
+# Rolling Back Configuration Changes {#sec-rollback}
+
+After running `nixos-rebuild` to switch to a new configuration, you may
+find that the new configuration doesn't work very well. In that case,
+there are several ways to return to a previous configuration.
+
+First, the GRUB boot manager allows you to boot into any previous
+configuration that hasn't been garbage-collected. These configurations
+can be found under the GRUB submenu "NixOS - All configurations". This
+is especially useful if the new configuration fails to boot. After the
+system has booted, you can make the selected configuration the default
+for subsequent boots:
+
+```ShellSession
+# /run/current-system/bin/switch-to-configuration boot
+```
+
+Second, you can switch to the previous configuration in a running
+system:
+
+```ShellSession
+# nixos-rebuild switch --rollback
+```
+
+This is equivalent to running:
+
+```ShellSession
+# /nix/var/nix/profiles/system-N-link/bin/switch-to-configuration switch
+```
+
+where `N` is the number of the NixOS system configuration. To get a
+list of the available configurations, do:
+
+```ShellSession
+$ ls -l /nix/var/nix/profiles/system-*-link
+...
+lrwxrwxrwx 1 root root 78 Aug 12 13:54 /nix/var/nix/profiles/system-268-link -> /nix/store/202b...-nixos-13.07pre4932_5a676e4-4be1055
+```
diff --git a/nixpkgs/nixos/doc/manual/administration/rollback.xml b/nixpkgs/nixos/doc/manual/administration/rollback.xml
deleted file mode 100644
index 80d79e1a53f1..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/rollback.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-rollback">
- <title>Rolling Back Configuration Changes</title>
-
- <para>
-  After running <command>nixos-rebuild</command> to switch to a new
-  configuration, you may find that the new configuration doesn’t work very
-  well. In that case, there are several ways to return to a previous
-  configuration.
- </para>
-
- <para>
-  First, the GRUB boot manager allows you to boot into any previous
-  configuration that hasn’t been garbage-collected. These configurations can
-  be found under the GRUB submenu “NixOS - All configurations”. This is
-  especially useful if the new configuration fails to boot. After the system
-  has booted, you can make the selected configuration the default for
-  subsequent boots:
-<screen>
-<prompt># </prompt>/run/current-system/bin/switch-to-configuration boot</screen>
- </para>
-
- <para>
-  Second, you can switch to the previous configuration in a running system:
-<screen>
-<prompt># </prompt>nixos-rebuild switch --rollback</screen>
-  This is equivalent to running:
-<screen>
-<prompt># </prompt>/nix/var/nix/profiles/system-<replaceable>N</replaceable>-link/bin/switch-to-configuration switch</screen>
-  where <replaceable>N</replaceable> is the number of the NixOS system
-  configuration. To get a list of the available configurations, do:
-<screen>
-<prompt>$ </prompt>ls -l /nix/var/nix/profiles/system-*-link
-<replaceable>...</replaceable>
-lrwxrwxrwx 1 root root 78 Aug 12 13:54 /nix/var/nix/profiles/system-268-link -> /nix/store/202b...-nixos-13.07pre4932_5a676e4-4be1055
-</screen>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/administration/running.xml b/nixpkgs/nixos/doc/manual/administration/running.xml
index 19bec1f7794d..d9fcc1aee263 100644
--- a/nixpkgs/nixos/doc/manual/administration/running.xml
+++ b/nixpkgs/nixos/doc/manual/administration/running.xml
@@ -10,12 +10,12 @@
    such as how to use the <command>systemd</command> service manager.
   </para>
  </partintro>
- <xi:include href="service-mgmt.xml" />
- <xi:include href="rebooting.xml" />
- <xi:include href="user-sessions.xml" />
- <xi:include href="control-groups.xml" />
- <xi:include href="logging.xml" />
- <xi:include href="cleaning-store.xml" />
- <xi:include href="containers.xml" />
- <xi:include href="troubleshooting.xml" />
+ <xi:include href="../from_md/administration/service-mgmt.chapter.xml" />
+ <xi:include href="../from_md/administration/rebooting.chapter.xml" />
+ <xi:include href="../from_md/administration/user-sessions.chapter.xml" />
+ <xi:include href="../from_md/administration/control-groups.chapter.xml" />
+ <xi:include href="../from_md/administration/logging.chapter.xml" />
+ <xi:include href="../from_md/administration/cleaning-store.chapter.xml" />
+ <xi:include href="../from_md/administration/containers.chapter.xml" />
+ <xi:include href="../from_md/administration/troubleshooting.chapter.xml" />
 </part>
diff --git a/nixpkgs/nixos/doc/manual/administration/service-mgmt.chapter.md b/nixpkgs/nixos/doc/manual/administration/service-mgmt.chapter.md
new file mode 100644
index 000000000000..bb0f9b62e913
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/service-mgmt.chapter.md
@@ -0,0 +1,120 @@
+# Service Management {#sec-systemctl}
+
+In NixOS, all system services are started and monitored using the
+systemd program. systemd is the "init" process of the system (i.e. PID
+1), the parent of all other processes. It manages a set of so-called
+"units", which can be things like system services (programs), but also
+mount points, swap files, devices, targets (groups of units) and more.
+Units can have complex dependencies; for instance, one unit can require
+that another unit must be successfully started before the first unit can
+be started. When the system boots, it starts a unit named
+`default.target`; the dependencies of this unit cause all system
+services to be started, file systems to be mounted, swap files to be
+activated, and so on.
+
+## Interacting with a running systemd {#sect-nixos-systemd-general}
+
+The command `systemctl` is the main way to interact with `systemd`. The
+following paragraphs demonstrate ways to interact with any OS running
+systemd as init system. NixOS is of no exception. The [next section
+](#sect-nixos-systemd-nixos) explains NixOS specific things worth
+knowing.
+
+Without any arguments, `systemctl` the status of active units:
+
+```ShellSession
+$ systemctl
+-.mount          loaded active mounted   /
+swapfile.swap    loaded active active    /swapfile
+sshd.service     loaded active running   SSH Daemon
+graphical.target loaded active active    Graphical Interface
+...
+```
+
+You can ask for detailed status information about a unit, for instance,
+the PostgreSQL database service:
+
+```ShellSession
+$ systemctl status postgresql.service
+postgresql.service - PostgreSQL Server
+          Loaded: loaded (/nix/store/pn3q73mvh75gsrl8w7fdlfk3fq5qm5mw-unit/postgresql.service)
+          Active: active (running) since Mon, 2013-01-07 15:55:57 CET; 9h ago
+        Main PID: 2390 (postgres)
+          CGroup: name=systemd:/system/postgresql.service
+                  ├─2390 postgres
+                  ├─2418 postgres: writer process
+                  ├─2419 postgres: wal writer process
+                  ├─2420 postgres: autovacuum launcher process
+                  ├─2421 postgres: stats collector process
+                  └─2498 postgres: zabbix zabbix [local] idle
+
+Jan 07 15:55:55 hagbard postgres[2394]: [1-1] LOG:  database system was shut down at 2013-01-07 15:55:05 CET
+Jan 07 15:55:57 hagbard postgres[2390]: [1-1] LOG:  database system is ready to accept connections
+Jan 07 15:55:57 hagbard postgres[2420]: [1-1] LOG:  autovacuum launcher started
+Jan 07 15:55:57 hagbard systemd[1]: Started PostgreSQL Server.
+```
+
+Note that this shows the status of the unit (active and running), all
+the processes belonging to the service, as well as the most recent log
+messages from the service.
+
+Units can be stopped, started or restarted:
+
+```ShellSession
+# systemctl stop postgresql.service
+# systemctl start postgresql.service
+# systemctl restart postgresql.service
+```
+
+These operations are synchronous: they wait until the service has
+finished starting or stopping (or has failed). Starting a unit will
+cause the dependencies of that unit to be started as well (if
+necessary).
+
+## systemd in NixOS {#sect-nixos-systemd-nixos}
+
+Packages in Nixpkgs sometimes provide systemd units with them, usually
+in e.g `#pkg-out#/lib/systemd/`. Putting such a package in
+`environment.systemPackages` doesn\'t make the service available to
+users or the system.
+
+In order to enable a systemd *system* service with provided upstream
+package, use (e.g):
+
+```nix
+systemd.packages = [ pkgs.packagekit ];
+```
+
+Usually NixOS modules written by the community do the above, plus take
+care of other details. If a module was written for a service you are
+interested in, you\'d probably need only to use
+`services.#name#.enable = true;`. These services are defined in
+Nixpkgs\' [ `nixos/modules/` directory
+](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules). In case
+the service is simple enough, the above method should work, and start
+the service on boot.
+
+*User* systemd services on the other hand, should be treated
+differently. Given a package that has a systemd unit file at
+`#pkg-out#/lib/systemd/user/`, using [](#opt-systemd.packages) will
+make you able to start the service via `systemctl --user start`, but it
+won\'t start automatically on login. However, You can imperatively
+enable it by adding the package\'s attribute to
+[](#opt-systemd.packages) and then do this (e.g):
+
+```ShellSession
+$ mkdir -p ~/.config/systemd/user/default.target.wants
+$ ln -s /run/current-system/sw/lib/systemd/user/syncthing.service ~/.config/systemd/user/default.target.wants/
+$ systemctl --user daemon-reload
+$ systemctl --user enable syncthing.service
+```
+
+If you are interested in a timer file, use `timers.target.wants` instead
+of `default.target.wants` in the 1st and 2nd command.
+
+Using `systemctl --user enable syncthing.service` instead of the above,
+will work, but it\'ll use the absolute path of `syncthing.service` for
+the symlink, and this path is in `/nix/store/.../lib/systemd/user/`.
+Hence [garbage collection](#sec-nix-gc) will remove that file and you
+will wind up with a broken symlink in your systemd configuration, which
+in turn will not make the service / timer start on login.
diff --git a/nixpkgs/nixos/doc/manual/administration/service-mgmt.xml b/nixpkgs/nixos/doc/manual/administration/service-mgmt.xml
deleted file mode 100644
index 863b0d47f6c7..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/service-mgmt.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-systemctl">
- <title>Service Management</title>
- <para>
-  In NixOS, all system services are started and monitored using the systemd
-  program. systemd is the “init” process of the system (i.e. PID 1), the
-  parent of all other processes. It manages a set of so-called “units”,
-  which can be things like system services (programs), but also mount points,
-  swap files, devices, targets (groups of units) and more. Units can have
-  complex dependencies; for instance, one unit can require that another unit
-  must be successfully started before the first unit can be started. When the
-  system boots, it starts a unit named <literal>default.target</literal>; the
-  dependencies of this unit cause all system services to be started, file
-  systems to be mounted, swap files to be activated, and so on.
- </para>
- <section xml:id="sect-nixos-systemd-general">
-  <title>Interacting with a running systemd</title>
-   <para>
-    The command <command>systemctl</command> is the main way to interact with
-    <command>systemd</command>. The following paragraphs demonstrate ways to
-    interact with any OS running systemd as init system. NixOS is of no
-    exception. The <link xlink:href="#sect-nixos-systemd-nixos">next section
-    </link> explains NixOS specific things worth knowing.
-   </para>
-   <para>
-    Without any arguments, <literal>systmctl</literal> the status of active units:
-<screen>
-<prompt>$ </prompt>systemctl
--.mount          loaded active mounted   /
-swapfile.swap    loaded active active    /swapfile
-sshd.service     loaded active running   SSH Daemon
-graphical.target loaded active active    Graphical Interface
-<replaceable>...</replaceable>
-</screen>
-  </para>
-  <para>
-   You can ask for detailed status information about a unit, for instance, the
-   PostgreSQL database service:
-<screen>
-<prompt>$ </prompt>systemctl status postgresql.service
-postgresql.service - PostgreSQL Server
-          Loaded: loaded (/nix/store/pn3q73mvh75gsrl8w7fdlfk3fq5qm5mw-unit/postgresql.service)
-          Active: active (running) since Mon, 2013-01-07 15:55:57 CET; 9h ago
-        Main PID: 2390 (postgres)
-          CGroup: name=systemd:/system/postgresql.service
-                  ├─2390 postgres
-                  ├─2418 postgres: writer process
-                  ├─2419 postgres: wal writer process
-                  ├─2420 postgres: autovacuum launcher process
-                  ├─2421 postgres: stats collector process
-                  └─2498 postgres: zabbix zabbix [local] idle
-
-Jan 07 15:55:55 hagbard postgres[2394]: [1-1] LOG:  database system was shut down at 2013-01-07 15:55:05 CET
-Jan 07 15:55:57 hagbard postgres[2390]: [1-1] LOG:  database system is ready to accept connections
-Jan 07 15:55:57 hagbard postgres[2420]: [1-1] LOG:  autovacuum launcher started
-Jan 07 15:55:57 hagbard systemd[1]: Started PostgreSQL Server.
-</screen>
-  Note that this shows the status of the unit (active and running), all the
-  processes belonging to the service, as well as the most recent log messages
-  from the service.
- </para>
- <para>
-  Units can be stopped, started or restarted:
-<screen>
-<prompt># </prompt>systemctl stop postgresql.service
-<prompt># </prompt>systemctl start postgresql.service
-<prompt># </prompt>systemctl restart postgresql.service
-</screen>
-   These operations are synchronous: they wait until the service has finished
-   starting or stopping (or has failed). Starting a unit will cause the
-   dependencies of that unit to be started as well (if necessary).
-  </para>
-  <!-- TODO: document cgroups, draft:
-   each service and user session is a cgroup
-
-   - cgroup resource management -->
- </section>
- <section xml:id="sect-nixos-systemd-nixos">
-  <title>systemd in NixOS</title>
-  <para>
-   Packages in Nixpkgs sometimes provide systemd units with them, usually in
-   e.g <literal>#pkg-out#/lib/systemd/</literal>. Putting such a package in
-   <literal>environment.systemPackages</literal> doesn't make the service
-   available to users or the system.
-  </para>
-  <para>
-   In order to enable a systemd <emphasis>system</emphasis> service with
-   provided upstream package, use (e.g):
-<programlisting>
-<xref linkend="opt-systemd.packages"/> = [ pkgs.packagekit ];
-</programlisting>
-  </para>
-  <para>
-   Usually NixOS modules written by the community do the above, plus take care of
-   other details. If a module was written for a service you are interested in,
-   you'd probably need only to use
-   <literal>services.#name#.enable = true;</literal>. These services are defined
-   in Nixpkgs'
-   <link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/modules">
-   <literal>nixos/modules/</literal> directory </link>. In case the service is
-   simple enough, the above method should work, and start the service on boot.
-  </para>
-  <para>
-   <emphasis>User</emphasis> systemd services on the other hand, should be
-   treated differently. Given a package that has a systemd unit file at
-   <literal>#pkg-out#/lib/systemd/user/</literal>, using
-   <xref linkend="opt-systemd.packages"/> will make you able to start the service via
-   <literal>systemctl --user start</literal>, but it won't start automatically on login.
-   <!-- TODO: Document why systemd.packages doesn't work for user services or fix this.
-   https://github.com/NixOS/nixpkgs/blob/2cd6594a8710a801038af2b72348658f732ce84a/nixos/modules/system/boot/systemd-lib.nix#L177-L198
-
-   This has been talked over at https://discourse.nixos.org/t/how-to-enable-upstream-systemd-user-services-declaratively/7649/5
-   -->
-   However, You can imperatively enable it by adding the package's attribute to
-   <link linkend="opt-environment.systemPackages">
-   <literal>systemd.packages</literal></link> and then do this (e.g):
-<screen>
-<prompt>$ </prompt>mkdir -p ~/.config/systemd/user/default.target.wants
-<prompt>$ </prompt>ln -s /run/current-system/sw/lib/systemd/user/syncthing.service ~/.config/systemd/user/default.target.wants/
-<prompt>$ </prompt>systemctl --user daemon-reload
-<prompt>$ </prompt>systemctl --user enable syncthing.service
-</screen>
-   If you are interested in a timer file, use <literal>timers.target.wants</literal>
-   instead of <literal>default.target.wants</literal> in the 1st and 2nd command.
-  </para>
-  <para>
-   Using <literal>systemctl --user enable syncthing.service</literal> instead of
-   the above, will work, but it'll use the absolute path of
-   <literal>syncthing.service</literal> for the symlink, and this path is in
-   <literal>/nix/store/.../lib/systemd/user/</literal>. Hence
-   <link xlink:href="#sec-nix-gc">garbage collection</link> will remove that file
-   and you will wind up with a broken symlink in your systemd configuration, which
-   in turn will not make the service / timer start on login.
-  </para>
- </section>
-</chapter>
-
diff --git a/nixpkgs/nixos/doc/manual/administration/store-corruption.section.md b/nixpkgs/nixos/doc/manual/administration/store-corruption.section.md
new file mode 100644
index 000000000000..bd8a5772b37c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/store-corruption.section.md
@@ -0,0 +1,28 @@
+# Nix Store Corruption {#sec-nix-store-corruption}
+
+After a system crash, it's possible for files in the Nix store to become
+corrupted. (For instance, the Ext4 file system has the tendency to
+replace un-synced files with zero bytes.) NixOS tries hard to prevent
+this from happening: it performs a `sync` before switching to a new
+configuration, and Nix's database is fully transactional. If corruption
+still occurs, you may be able to fix it automatically.
+
+If the corruption is in a path in the closure of the NixOS system
+configuration, you can fix it by doing
+
+```ShellSession
+# nixos-rebuild switch --repair
+```
+
+This will cause Nix to check every path in the closure, and if its
+cryptographic hash differs from the hash recorded in Nix's database, the
+path is rebuilt or redownloaded.
+
+You can also scan the entire Nix store for corrupt paths:
+
+```ShellSession
+# nix-store --verify --check-contents --repair
+```
+
+Any corrupt paths will be redownloaded if they're available in a binary
+cache; otherwise, they cannot be repaired.
diff --git a/nixpkgs/nixos/doc/manual/administration/store-corruption.xml b/nixpkgs/nixos/doc/manual/administration/store-corruption.xml
deleted file mode 100644
index b9d11152d5e1..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/store-corruption.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-nix-store-corruption">
- <title>Nix Store Corruption</title>
-
- <para>
-  After a system crash, it’s possible for files in the Nix store to become
-  corrupted. (For instance, the Ext4 file system has the tendency to replace
-  un-synced files with zero bytes.) NixOS tries hard to prevent this from
-  happening: it performs a <command>sync</command> before switching to a new
-  configuration, and Nix’s database is fully transactional. If corruption
-  still occurs, you may be able to fix it automatically.
- </para>
-
- <para>
-  If the corruption is in a path in the closure of the NixOS system
-  configuration, you can fix it by doing
-<screen>
-<prompt># </prompt>nixos-rebuild switch --repair
-</screen>
-  This will cause Nix to check every path in the closure, and if its
-  cryptographic hash differs from the hash recorded in Nix’s database, the
-  path is rebuilt or redownloaded.
- </para>
-
- <para>
-  You can also scan the entire Nix store for corrupt paths:
-<screen>
-<prompt># </prompt>nix-store --verify --check-contents --repair
-</screen>
-  Any corrupt paths will be redownloaded if they’re available in a binary
-  cache; otherwise, they cannot be repaired.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/administration/troubleshooting.chapter.md b/nixpkgs/nixos/doc/manual/administration/troubleshooting.chapter.md
new file mode 100644
index 000000000000..548456eaf6d6
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/troubleshooting.chapter.md
@@ -0,0 +1,12 @@
+# Troubleshooting {#ch-troubleshooting}
+
+This chapter describes solutions to common problems you might encounter
+when you manage your NixOS system.
+
+```{=docbook}
+<xi:include href="boot-problems.section.xml" />
+<xi:include href="maintenance-mode.section.xml" />
+<xi:include href="rollback.section.xml" />
+<xi:include href="store-corruption.section.xml" />
+<xi:include href="network-problems.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/administration/troubleshooting.xml b/nixpkgs/nixos/doc/manual/administration/troubleshooting.xml
deleted file mode 100644
index b055acadacf3..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/troubleshooting.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="ch-troubleshooting">
- <title>Troubleshooting</title>
- <para>
-  This chapter describes solutions to common problems you might encounter when
-  you manage your NixOS system.
- </para>
- <xi:include href="../from_md/administration/boot-problems.section.xml" />
- <xi:include href="maintenance-mode.xml" />
- <xi:include href="rollback.xml" />
- <xi:include href="store-corruption.xml" />
- <xi:include href="network-problems.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/administration/user-sessions.chapter.md b/nixpkgs/nixos/doc/manual/administration/user-sessions.chapter.md
new file mode 100644
index 000000000000..5ff468b30122
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/administration/user-sessions.chapter.md
@@ -0,0 +1,43 @@
+# User Sessions {#sec-user-sessions}
+
+Systemd keeps track of all users who are logged into the system (e.g. on
+a virtual console or remotely via SSH). The command `loginctl` allows
+querying and manipulating user sessions. For instance, to list all user
+sessions:
+
+```ShellSession
+$ loginctl
+   SESSION        UID USER             SEAT
+        c1        500 eelco            seat0
+        c3          0 root             seat0
+        c4        500 alice
+```
+
+This shows that two users are logged in locally, while another is logged
+in remotely. ("Seats" are essentially the combinations of displays and
+input devices attached to the system; usually, there is only one seat.)
+To get information about a session:
+
+```ShellSession
+$ loginctl session-status c3
+c3 - root (0)
+           Since: Tue, 2013-01-08 01:17:56 CET; 4min 42s ago
+          Leader: 2536 (login)
+            Seat: seat0; vc3
+             TTY: /dev/tty3
+         Service: login; type tty; class user
+           State: online
+          CGroup: name=systemd:/user/root/c3
+                  ├─ 2536 /nix/store/10mn4xip9n7y9bxqwnsx7xwx2v2g34xn-shadow-4.1.5.1/bin/login --
+                  ├─10339 -bash
+                  └─10355 w3m nixos.org
+```
+
+This shows that the user is logged in on virtual console 3. It also
+lists the processes belonging to this session. Since systemd keeps track
+of this, you can terminate a session in a way that ensures that all the
+session's processes are gone:
+
+```ShellSession
+# loginctl terminate-session c3
+```
diff --git a/nixpkgs/nixos/doc/manual/administration/user-sessions.xml b/nixpkgs/nixos/doc/manual/administration/user-sessions.xml
deleted file mode 100644
index 9acb147ac1a6..000000000000
--- a/nixpkgs/nixos/doc/manual/administration/user-sessions.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-user-sessions">
- <title>User Sessions</title>
- <para>
-  Systemd keeps track of all users who are logged into the system (e.g. on a
-  virtual console or remotely via SSH). The command <command>loginctl</command>
-  allows querying and manipulating user sessions. For instance, to list all
-  user sessions:
-<screen>
-<prompt>$ </prompt>loginctl
-   SESSION        UID USER             SEAT
-        c1        500 eelco            seat0
-        c3          0 root             seat0
-        c4        500 alice
-</screen>
-  This shows that two users are logged in locally, while another is logged in
-  remotely. (“Seats” are essentially the combinations of displays and input
-  devices attached to the system; usually, there is only one seat.) To get
-  information about a session:
-<screen>
-<prompt>$ </prompt>loginctl session-status c3
-c3 - root (0)
-           Since: Tue, 2013-01-08 01:17:56 CET; 4min 42s ago
-          Leader: 2536 (login)
-            Seat: seat0; vc3
-             TTY: /dev/tty3
-         Service: login; type tty; class user
-           State: online
-          CGroup: name=systemd:/user/root/c3
-                  ├─ 2536 /nix/store/10mn4xip9n7y9bxqwnsx7xwx2v2g34xn-shadow-4.1.5.1/bin/login --
-                  ├─10339 -bash
-                  └─10355 w3m nixos.org
-</screen>
-  This shows that the user is logged in on virtual console 3. It also lists the
-  processes belonging to this session. Since systemd keeps track of this, you
-  can terminate a session in a way that ensures that all the session’s
-  processes are gone:
-<screen>
-<prompt># </prompt>loginctl terminate-session c3
-</screen>
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.section.md b/nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.section.md
new file mode 100644
index 000000000000..4478d77f361d
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.section.md
@@ -0,0 +1,13 @@
+# Ad-Hoc Configuration {#ad-hoc-network-config}
+
+You can use [](#opt-networking.localCommands) to
+specify shell commands to be run at the end of `network-setup.service`. This
+is useful for doing network configuration not covered by the existing NixOS
+modules. For instance, to statically configure an IPv6 address:
+
+```nix
+networking.localCommands =
+  ''
+    ip -6 addr add 2001:610:685:1::1/64 dev eth0
+  '';
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.xml b/nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.xml
deleted file mode 100644
index 00e595c7cb7f..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/ad-hoc-network-config.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="ad-hoc-network-config">
- <title>Ad-Hoc Configuration</title>
-
- <para>
-  You can use <xref linkend="opt-networking.localCommands"/> to specify shell
-  commands to be run at the end of <literal>network-setup.service</literal>.
-  This is useful for doing network configuration not covered by the existing
-  NixOS modules. For instance, to statically configure an IPv6 address:
-<programlisting>
-<xref linkend="opt-networking.localCommands"/> =
-  ''
-    ip -6 addr add 2001:610:685:1::1/64 dev eth0
-  '';
-</programlisting>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.section.md b/nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.section.md
new file mode 100644
index 000000000000..e9d574903a10
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.section.md
@@ -0,0 +1,51 @@
+# Ad-Hoc Package Management {#sec-ad-hoc-packages}
+
+With the command `nix-env`, you can install and uninstall packages from
+the command line. For instance, to install Mozilla Thunderbird:
+
+```ShellSession
+$ nix-env -iA nixos.thunderbird
+```
+
+If you invoke this as root, the package is installed in the Nix profile
+`/nix/var/nix/profiles/default` and visible to all users of the system;
+otherwise, the package ends up in
+`/nix/var/nix/profiles/per-user/username/profile` and is not visible to
+other users. The `-A` flag specifies the package by its attribute name;
+without it, the package is installed by matching against its package
+name (e.g. `thunderbird`). The latter is slower because it requires
+matching against all available Nix packages, and is ambiguous if there
+are multiple matching packages.
+
+Packages come from the NixOS channel. You typically upgrade a package by
+updating to the latest version of the NixOS channel:
+
+```ShellSession
+$ nix-channel --update nixos
+```
+
+and then running `nix-env -i` again. Other packages in the profile are
+*not* affected; this is the crucial difference with the declarative
+style of package management, where running `nixos-rebuild switch` causes
+all packages to be updated to their current versions in the NixOS
+channel. You can however upgrade all packages for which there is a newer
+version by doing:
+
+```ShellSession
+$ nix-env -u '*'
+```
+
+A package can be uninstalled using the `-e` flag:
+
+```ShellSession
+$ nix-env -e thunderbird
+```
+
+Finally, you can roll back an undesirable `nix-env` action:
+
+```ShellSession
+$ nix-env --rollback
+```
+
+`nix-env` has many more flags. For details, see the nix-env(1) manpage or
+the Nix manual.
diff --git a/nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.xml b/nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.xml
deleted file mode 100644
index c7e882d846fa..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/ad-hoc-packages.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-ad-hoc-packages">
- <title>Ad-Hoc Package Management</title>
-
- <para>
-  With the command <command>nix-env</command>, you can install and uninstall
-  packages from the command line. For instance, to install Mozilla Thunderbird:
-<screen>
-<prompt>$ </prompt>nix-env -iA nixos.thunderbird</screen>
-  If you invoke this as root, the package is installed in the Nix profile
-  <filename>/nix/var/nix/profiles/default</filename> and visible to all users
-  of the system; otherwise, the package ends up in
-  <filename>/nix/var/nix/profiles/per-user/<replaceable>username</replaceable>/profile</filename>
-  and is not visible to other users. The <option>-A</option> flag specifies the
-  package by its attribute name; without it, the package is installed by
-  matching against its package name (e.g. <literal>thunderbird</literal>). The
-  latter is slower because it requires matching against all available Nix
-  packages, and is ambiguous if there are multiple matching packages.
- </para>
-
- <para>
-  Packages come from the NixOS channel. You typically upgrade a package by
-  updating to the latest version of the NixOS channel:
-<screen>
-<prompt>$ </prompt>nix-channel --update nixos
-</screen>
-  and then running <literal>nix-env -i</literal> again. Other packages in the
-  profile are <emphasis>not</emphasis> affected; this is the crucial difference
-  with the declarative style of package management, where running
-  <command>nixos-rebuild switch</command> causes all packages to be updated to
-  their current versions in the NixOS channel. You can however upgrade all
-  packages for which there is a newer version by doing:
-<screen>
-<prompt>$ </prompt>nix-env -u '*'
-</screen>
- </para>
-
- <para>
-  A package can be uninstalled using the <option>-e</option> flag:
-<screen>
-<prompt>$ </prompt>nix-env -e thunderbird
-</screen>
- </para>
-
- <para>
-  Finally, you can roll back an undesirable <command>nix-env</command> action:
-<screen>
-<prompt>$ </prompt>nix-env --rollback
-</screen>
- </para>
-
- <para>
-  <command>nix-env</command> has many more flags. For details, see the
-  <citerefentry>
-  <refentrytitle>nix-env</refentrytitle>
-  <manvolnum>1</manvolnum></citerefentry> manpage or the Nix manual.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.section.md b/nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.section.md
new file mode 100644
index 000000000000..5d1198fb0f41
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.section.md
@@ -0,0 +1,74 @@
+# Adding Custom Packages {#sec-custom-packages}
+
+It's possible that a package you need is not available in NixOS. In that
+case, you can do two things. First, you can clone the Nixpkgs
+repository, add the package to your clone, and (optionally) submit a
+patch or pull request to have it accepted into the main Nixpkgs repository.
+This is described in detail in the [Nixpkgs manual](https://nixos.org/nixpkgs/manual).
+In short, you clone Nixpkgs:
+
+```ShellSession
+$ git clone https://github.com/NixOS/nixpkgs
+$ cd nixpkgs
+```
+
+Then you write and test the package as described in the Nixpkgs manual.
+Finally, you add it to [](#opt-environment.systemPackages), e.g.
+
+```nix
+environment.systemPackages = [ pkgs.my-package ];
+```
+
+and you run `nixos-rebuild`, specifying your own Nixpkgs tree:
+
+```ShellSession
+# nixos-rebuild switch -I nixpkgs=/path/to/my/nixpkgs
+```
+
+The second possibility is to add the package outside of the Nixpkgs
+tree. For instance, here is how you specify a build of the
+[GNU Hello](https://www.gnu.org/software/hello/) package directly in
+`configuration.nix`:
+
+```nix
+environment.systemPackages =
+  let
+    my-hello = with pkgs; stdenv.mkDerivation rec {
+      name = "hello-2.8";
+      src = fetchurl {
+        url = "mirror://gnu/hello/${name}.tar.gz";
+        sha256 = "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6";
+      };
+    };
+  in
+  [ my-hello ];
+```
+
+Of course, you can also move the definition of `my-hello` into a
+separate Nix expression, e.g.
+
+```nix
+environment.systemPackages = [ (import ./my-hello.nix) ];
+```
+
+where `my-hello.nix` contains:
+
+```nix
+with import <nixpkgs> {}; # bring all of Nixpkgs into scope
+
+stdenv.mkDerivation rec {
+  name = "hello-2.8";
+  src = fetchurl {
+    url = "mirror://gnu/hello/${name}.tar.gz";
+    sha256 = "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6";
+  };
+}
+```
+
+This allows testing the package easily:
+
+```ShellSession
+$ nix-build my-hello.nix
+$ ./result/bin/hello
+Hello, world!
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.xml b/nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.xml
deleted file mode 100644
index 19eb2429d0a0..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/adding-custom-packages.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-custom-packages">
- <title>Adding Custom Packages</title>
-
- <para>
-  It’s possible that a package you need is not available in NixOS. In that
-  case, you can do two things. First, you can clone the Nixpkgs repository, add
-  the package to your clone, and (optionally) submit a patch or pull request to
-  have it accepted into the main Nixpkgs repository. This is described in
-  detail in the <link
-xlink:href="https://nixos.org/nixpkgs/manual">Nixpkgs
-  manual</link>. In short, you clone Nixpkgs:
-<screen>
-<prompt>$ </prompt>git clone https://github.com/NixOS/nixpkgs
-<prompt>$ </prompt>cd nixpkgs
-</screen>
-  Then you write and test the package as described in the Nixpkgs manual.
-  Finally, you add it to <literal>environment.systemPackages</literal>, e.g.
-<programlisting>
-<xref linkend="opt-environment.systemPackages"/> = [ pkgs.my-package ];
-</programlisting>
-  and you run <command>nixos-rebuild</command>, specifying your own Nixpkgs
-  tree:
-<screen>
-<prompt># </prompt>nixos-rebuild switch -I nixpkgs=/path/to/my/nixpkgs</screen>
- </para>
-
- <para>
-  The second possibility is to add the package outside of the Nixpkgs tree. For
-  instance, here is how you specify a build of the
-  <link xlink:href="https://www.gnu.org/software/hello/">GNU Hello</link>
-  package directly in <filename>configuration.nix</filename>:
-<programlisting>
-<xref linkend="opt-environment.systemPackages"/> =
-  let
-    my-hello = with pkgs; stdenv.mkDerivation rec {
-      name = "hello-2.8";
-      src = fetchurl {
-        url = "mirror://gnu/hello/${name}.tar.gz";
-        sha256 = "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6";
-      };
-    };
-  in
-  [ my-hello ];
-</programlisting>
-  Of course, you can also move the definition of <literal>my-hello</literal>
-  into a separate Nix expression, e.g.
-<programlisting>
-<xref linkend="opt-environment.systemPackages"/> = [ (import ./my-hello.nix) ];
-</programlisting>
-  where <filename>my-hello.nix</filename> contains:
-<programlisting>
-with import &lt;nixpkgs> {}; # bring all of Nixpkgs into scope
-
-stdenv.mkDerivation rec {
-  name = "hello-2.8";
-  src = fetchurl {
-    url = "mirror://gnu/hello/${name}.tar.gz";
-    sha256 = "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6";
-  };
-}
-</programlisting>
-  This allows testing the package easily:
-<screen>
-<prompt>$ </prompt>nix-build my-hello.nix
-<prompt>$ </prompt>./result/bin/hello
-Hello, world!
-</screen>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/config-file.section.md b/nixpkgs/nixos/doc/manual/configuration/config-file.section.md
new file mode 100644
index 000000000000..f21ba113bf8c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/config-file.section.md
@@ -0,0 +1,175 @@
+# NixOS Configuration File {#sec-configuration-file}
+
+The NixOS configuration file generally looks like this:
+
+```nix
+{ config, pkgs, ... }:
+
+{ option definitions
+}
+```
+
+The first line (`{ config, pkgs, ... }:`) denotes that this is actually
+a function that takes at least the two arguments `config` and `pkgs`.
+(These are explained later, in chapter [](#sec-writing-modules)) The
+function returns a *set* of option definitions (`{ ... }`).
+These definitions have the form `name = value`, where `name` is the
+name of an option and `value` is its value. For example,
+
+```nix
+{ config, pkgs, ... }:
+
+{ services.httpd.enable = true;
+  services.httpd.adminAddr = "alice@example.org";
+  services.httpd.virtualHosts.localhost.documentRoot = "/webroot";
+}
+```
+
+defines a configuration with three option definitions that together
+enable the Apache HTTP Server with `/webroot` as the document root.
+
+Sets can be nested, and in fact dots in option names are shorthand for
+defining a set containing another set. For instance,
+[](#opt-services.httpd.enable) defines a set named
+`services` that contains a set named `httpd`, which in turn contains an
+option definition named `enable` with value `true`. This means that the
+example above can also be written as:
+
+```nix
+{ config, pkgs, ... }:
+
+{ services = {
+    httpd = {
+      enable = true;
+      adminAddr = "alice@example.org";
+      virtualHosts = {
+        localhost = {
+          documentRoot = "/webroot";
+        };
+      };
+    };
+  };
+}
+```
+
+which may be more convenient if you have lots of option definitions that
+share the same prefix (such as `services.httpd`).
+
+NixOS checks your option definitions for correctness. For instance, if
+you try to define an option that doesn't exist (that is, doesn't have a
+corresponding *option declaration*), `nixos-rebuild` will give an error
+like:
+
+```plain
+The option `services.httpd.enable' defined in `/etc/nixos/configuration.nix' does not exist.
+```
+
+Likewise, values in option definitions must have a correct type. For
+instance, `services.httpd.enable` must be a Boolean (`true` or `false`).
+Trying to give it a value of another type, such as a string, will cause
+an error:
+
+```plain
+The option value `services.httpd.enable' in `/etc/nixos/configuration.nix' is not a boolean.
+```
+
+Options have various types of values. The most important are:
+
+Strings
+
+:   Strings are enclosed in double quotes, e.g.
+
+    ```nix
+    networking.hostName = "dexter";
+    ```
+
+    Special characters can be escaped by prefixing them with a backslash
+    (e.g. `\"`).
+
+    Multi-line strings can be enclosed in *double single quotes*, e.g.
+
+    ```nix
+    networking.extraHosts =
+      ''
+        127.0.0.2 other-localhost
+        10.0.0.1 server
+      '';
+    ```
+
+    The main difference is that it strips from each line a number of
+    spaces equal to the minimal indentation of the string as a whole
+    (disregarding the indentation of empty lines), and that characters
+    like `"` and `\` are not special (making it more convenient for
+    including things like shell code). See more info about this in the
+    Nix manual [here](https://nixos.org/nix/manual/#ssec-values).
+
+Booleans
+
+:   These can be `true` or `false`, e.g.
+
+    ```nix
+    networking.firewall.enable = true;
+    networking.firewall.allowPing = false;
+    ```
+
+Integers
+
+:   For example,
+
+    ```nix
+    boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 60;
+    ```
+
+    (Note that here the attribute name `net.ipv4.tcp_keepalive_time` is
+    enclosed in quotes to prevent it from being interpreted as a set
+    named `net` containing a set named `ipv4`, and so on. This is
+    because it's not a NixOS option but the literal name of a Linux
+    kernel setting.)
+
+Sets
+
+:   Sets were introduced above. They are name/value pairs enclosed in
+    braces, as in the option definition
+
+    ```nix
+    fileSystems."/boot" =
+      { device = "/dev/sda1";
+        fsType = "ext4";
+        options = [ "rw" "data=ordered" "relatime" ];
+      };
+    ```
+
+Lists
+
+:   The important thing to note about lists is that list elements are
+    separated by whitespace, like this:
+
+    ```nix
+    boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];
+    ```
+
+    List elements can be any other type, e.g. sets:
+
+    ```nix
+    swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];
+    ```
+
+Packages
+
+:   Usually, the packages you need are already part of the Nix Packages
+    collection, which is a set that can be accessed through the function
+    argument `pkgs`. Typical uses:
+
+    ```nix
+    environment.systemPackages =
+      [ pkgs.thunderbird
+        pkgs.emacs
+      ];
+
+    services.postgresql.package = pkgs.postgresql_10;
+    ```
+
+    The latter option definition changes the default PostgreSQL package
+    used by NixOS's PostgreSQL service to 10.x. For more information on
+    packages, including how to add new ones, see
+    [](#sec-custom-packages).
diff --git a/nixpkgs/nixos/doc/manual/configuration/config-file.xml b/nixpkgs/nixos/doc/manual/configuration/config-file.xml
deleted file mode 100644
index 19cfb57920df..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/config-file.xml
+++ /dev/null
@@ -1,216 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-    xmlns:xlink="http://www.w3.org/1999/xlink"
-    xmlns:xi="http://www.w3.org/2001/XInclude"
-    version="5.0"
-    xml:id="sec-configuration-file">
- <title>NixOS Configuration File</title>
-
- <para>
-  The NixOS configuration file generally looks like this:
-<programlisting>
-{ config, pkgs, ... }:
-
-{ <replaceable>option definitions</replaceable>
-}
-</programlisting>
-  The first line (<literal>{ config, pkgs, ... }:</literal>) denotes that this
-  is actually a function that takes at least the two arguments
-  <varname>config</varname> and <varname>pkgs</varname>. (These are explained
-  later, in chapter <xref linkend="sec-writing-modules" />) The function returns
-  a <emphasis>set</emphasis> of option definitions (<literal>{
-  <replaceable>...</replaceable> }</literal>). These definitions have the form
-  <literal><replaceable>name</replaceable> =
-  <replaceable>value</replaceable></literal>, where
-  <replaceable>name</replaceable> is the name of an option and
-  <replaceable>value</replaceable> is its value. For example,
-<programlisting>
-{ config, pkgs, ... }:
-
-{ <xref linkend="opt-services.httpd.enable"/> = true;
-  <xref linkend="opt-services.httpd.adminAddr"/> = "alice@example.org";
-  <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.localhost.documentRoot</link> = "/webroot";
-}
-</programlisting>
-  defines a configuration with three option definitions that together enable
-  the Apache HTTP Server with <filename>/webroot</filename> as the document
-  root.
- </para>
-
- <para>
-  Sets can be nested, and in fact dots in option names are shorthand for
-  defining a set containing another set. For instance,
-  <xref linkend="opt-services.httpd.enable"/> defines a set named
-  <varname>services</varname> that contains a set named
-  <varname>httpd</varname>, which in turn contains an option definition named
-  <varname>enable</varname> with value <literal>true</literal>. This means that
-  the example above can also be written as:
-<programlisting>
-{ config, pkgs, ... }:
-
-{ services = {
-    httpd = {
-      enable = true;
-      adminAddr = "alice@example.org";
-      virtualHosts = {
-        localhost = {
-          documentRoot = "/webroot";
-        };
-      };
-    };
-  };
-}
-</programlisting>
-  which may be more convenient if you have lots of option definitions that
-  share the same prefix (such as <literal>services.httpd</literal>).
- </para>
-
- <para>
-  NixOS checks your option definitions for correctness. For instance, if you
-  try to define an option that doesn’t exist (that is, doesn’t have a
-  corresponding <emphasis>option declaration</emphasis>),
-  <command>nixos-rebuild</command> will give an error like:
-<screen>
-The option `services.httpd.enable' defined in `/etc/nixos/configuration.nix' does not exist.
-</screen>
-  Likewise, values in option definitions must have a correct type. For
-  instance, <option>services.httpd.enable</option> must be a Boolean
-  (<literal>true</literal> or <literal>false</literal>). Trying to give it a
-  value of another type, such as a string, will cause an error:
-<screen>
-The option value `services.httpd.enable' in `/etc/nixos/configuration.nix' is not a boolean.
-</screen>
- </para>
-
- <para>
-  Options have various types of values. The most important are:
-  <variablelist>
-   <varlistentry>
-    <term>
-     Strings
-    </term>
-    <listitem>
-     <para>
-      Strings are enclosed in double quotes, e.g.
-<programlisting>
-<xref linkend="opt-networking.hostName"/> = "dexter";
-</programlisting>
-      Special characters can be escaped by prefixing them with a backslash
-      (e.g. <literal>\"</literal>).
-     </para>
-     <para>
-      Multi-line strings can be enclosed in <emphasis>double single
-      quotes</emphasis>, e.g.
-<programlisting>
-<xref linkend="opt-networking.extraHosts"/> =
-  ''
-    127.0.0.2 other-localhost
-    10.0.0.1 server
-  '';
-</programlisting>
-      The main difference is that it strips from each line a number of spaces
-      equal to the minimal indentation of the string as a whole (disregarding
-      the indentation of empty lines), and that characters like
-      <literal>"</literal> and <literal>\</literal> are not special (making it
-      more convenient for including things like shell code). See more info
-      about this in the Nix manual
-      <link
-      xlink:href="https://nixos.org/nix/manual/#ssec-values">here</link>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     Booleans
-    </term>
-    <listitem>
-     <para>
-      These can be <literal>true</literal> or <literal>false</literal>, e.g.
-<programlisting>
-<xref linkend="opt-networking.firewall.enable"/> = true;
-<xref linkend="opt-networking.firewall.allowPing"/> = false;
-</programlisting>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     Integers
-    </term>
-    <listitem>
-     <para>
-      For example,
-<programlisting>
-<xref linkend="opt-boot.kernel.sysctl"/>."net.ipv4.tcp_keepalive_time" = 60;
-</programlisting>
-      (Note that here the attribute name
-      <literal>net.ipv4.tcp_keepalive_time</literal> is enclosed in quotes to
-      prevent it from being interpreted as a set named <literal>net</literal>
-      containing a set named <literal>ipv4</literal>, and so on. This is
-      because it’s not a NixOS option but the literal name of a Linux kernel
-      setting.)
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     Sets
-    </term>
-    <listitem>
-     <para>
-      Sets were introduced above. They are name/value pairs enclosed in braces,
-      as in the option definition
-<programlisting>
-<xref linkend="opt-fileSystems"/>."/boot" =
-  { device = "/dev/sda1";
-    fsType = "ext4";
-    options = [ "rw" "data=ordered" "relatime" ];
-  };
-</programlisting>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     Lists
-    </term>
-    <listitem>
-     <para>
-      The important thing to note about lists is that list elements are
-      separated by whitespace, like this:
-<programlisting>
-<xref linkend="opt-boot.kernelModules"/> = [ "fuse" "kvm-intel" "coretemp" ];
-</programlisting>
-      List elements can be any other type, e.g. sets:
-<programlisting>
-swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];
-</programlisting>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     Packages
-    </term>
-    <listitem>
-     <para>
-      Usually, the packages you need are already part of the Nix Packages
-      collection, which is a set that can be accessed through the function
-      argument <varname>pkgs</varname>. Typical uses:
-<programlisting>
-<xref linkend="opt-environment.systemPackages"/> =
-  [ pkgs.thunderbird
-    pkgs.emacs
-  ];
-
-<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql_10;
-</programlisting>
-      The latter option definition changes the default PostgreSQL package used
-      by NixOS’s PostgreSQL service to 10.x. For more information on
-      packages, including how to add new ones, see
-      <xref linkend="sec-custom-packages"/>.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/config-syntax.chapter.md b/nixpkgs/nixos/doc/manual/configuration/config-syntax.chapter.md
new file mode 100644
index 000000000000..56d093c0f6e8
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/config-syntax.chapter.md
@@ -0,0 +1,19 @@
+# Configuration Syntax {#sec-configuration-syntax}
+
+The NixOS configuration file `/etc/nixos/configuration.nix` is actually
+a *Nix expression*, which is the Nix package manager's purely functional
+language for describing how to build packages and configurations. This
+means you have all the expressive power of that language at your
+disposal, including the ability to abstract over common patterns, which
+is very useful when managing complex systems. The syntax and semantics
+of the Nix language are fully described in the [Nix
+manual](https://nixos.org/nix/manual/#chap-writing-nix-expressions), but
+here we give a short overview of the most important constructs useful in
+NixOS configuration files.
+
+```{=docbook}
+<xi:include href="config-file.section.xml" />
+<xi:include href="abstractions.section.xml" />
+<xi:include href="modularity.section.xml" />
+<xi:include href="summary.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/config-syntax.xml b/nixpkgs/nixos/doc/manual/configuration/config-syntax.xml
deleted file mode 100644
index a374c6a87074..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/config-syntax.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-configuration-syntax">
- <title>Configuration Syntax</title>
- <para>
-  The NixOS configuration file
-  <filename>/etc/nixos/configuration.nix</filename> is actually a <emphasis>Nix
-  expression</emphasis>, which is the Nix package manager’s purely functional
-  language for describing how to build packages and configurations. This means
-  you have all the expressive power of that language at your disposal,
-  including the ability to abstract over common patterns, which is very useful
-  when managing complex systems. The syntax and semantics of the Nix language
-  are fully described in the
-  <link
-xlink:href="https://nixos.org/nix/manual/#chap-writing-nix-expressions">Nix
-  manual</link>, but here we give a short overview of the most important
-  constructs useful in NixOS configuration files.
- </para>
- <xi:include href="config-file.xml" />
- <xi:include href="../from_md/configuration/abstractions.section.xml" />
- <xi:include href="modularity.xml" />
- <xi:include href="summary.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/configuration.xml b/nixpkgs/nixos/doc/manual/configuration/configuration.xml
index 6949189b8883..b04316cfa48e 100644
--- a/nixpkgs/nixos/doc/manual/configuration/configuration.xml
+++ b/nixpkgs/nixos/doc/manual/configuration/configuration.xml
@@ -13,19 +13,19 @@
    effect after you run <command>nixos-rebuild</command>.
   </para>
  </partintro>
- <xi:include href="config-syntax.xml" />
- <xi:include href="package-mgmt.xml" />
- <xi:include href="user-mgmt.xml" />
- <xi:include href="file-systems.xml" />
- <xi:include href="x-windows.xml" />
- <xi:include href="wayland.xml" />
- <xi:include href="gpu-accel.xml" />
- <xi:include href="xfce.xml" />
- <xi:include href="networking.xml" />
- <xi:include href="linux-kernel.xml" />
- <xi:include href="subversion.xml" />
+ <xi:include href="../from_md/configuration/config-syntax.chapter.xml" />
+ <xi:include href="../from_md/configuration/package-mgmt.chapter.xml" />
+ <xi:include href="../from_md/configuration/user-mgmt.chapter.xml" />
+ <xi:include href="../from_md/configuration/file-systems.chapter.xml" />
+ <xi:include href="../from_md/configuration/x-windows.chapter.xml" />
+ <xi:include href="../from_md/configuration/wayland.chapter.xml" />
+ <xi:include href="../from_md/configuration/gpu-accel.chapter.xml" />
+ <xi:include href="../from_md/configuration/xfce.chapter.xml" />
+ <xi:include href="../from_md/configuration/networking.chapter.xml" />
+ <xi:include href="../from_md/configuration/linux-kernel.chapter.xml" />
+ <xi:include href="../from_md/configuration/subversion.chapter.xml" />
  <xi:include href="../generated/modules.xml" xpointer="xpointer(//section[@id='modules']/*)" />
- <xi:include href="profiles.xml" />
- <xi:include href="kubernetes.xml" />
+ <xi:include href="../from_md/configuration/profiles.chapter.xml" />
+ <xi:include href="../from_md/configuration/kubernetes.chapter.xml" />
 <!-- Apache; libvirtd virtualisation -->
 </part>
diff --git a/nixpkgs/nixos/doc/manual/configuration/customizing-packages.section.md b/nixpkgs/nixos/doc/manual/configuration/customizing-packages.section.md
new file mode 100644
index 000000000000..bceeeb2d7a16
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/customizing-packages.section.md
@@ -0,0 +1,74 @@
+# Customising Packages {#sec-customising-packages}
+
+Some packages in Nixpkgs have options to enable or disable optional
+functionality or change other aspects of the package. For instance, the
+Firefox wrapper package (which provides Firefox with a set of plugins
+such as the Adobe Flash player) has an option to enable the Google Talk
+plugin. It can be set in `configuration.nix` as follows:
+`nixpkgs.config.firefox.enableGoogleTalkPlugin = true;`
+
+::: {.warning}
+Unfortunately, Nixpkgs currently lacks a way to query available
+configuration options.
+:::
+
+Apart from high-level options, it's possible to tweak a package in
+almost arbitrary ways, such as changing or disabling dependencies of a
+package. For instance, the Emacs package in Nixpkgs by default has a
+dependency on GTK 2. If you want to build it against GTK 3, you can
+specify that as follows:
+
+```nix
+environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ];
+```
+
+The function `override` performs the call to the Nix function that
+produces Emacs, with the original arguments amended by the set of
+arguments specified by you. So here the function argument `gtk` gets the
+value `pkgs.gtk3`, causing Emacs to depend on GTK 3. (The parentheses
+are necessary because in Nix, function application binds more weakly
+than list construction, so without them,
+[](#opt-environment.systemPackages)
+would be a list with two elements.)
+
+Even greater customisation is possible using the function
+`overrideAttrs`. While the `override` mechanism above overrides the
+arguments of a package function, `overrideAttrs` allows changing the
+*attributes* passed to `mkDerivation`. This permits changing any aspect
+of the package, such as the source code. For instance, if you want to
+override the source code of Emacs, you can say:
+
+```nix
+environment.systemPackages = [
+  (pkgs.emacs.overrideAttrs (oldAttrs: {
+    name = "emacs-25.0-pre";
+    src = /path/to/my/emacs/tree;
+  }))
+];
+```
+
+Here, `overrideAttrs` takes the Nix derivation specified by `pkgs.emacs`
+and produces a new derivation in which the original's `name` and `src`
+attribute have been replaced by the given values by re-calling
+`stdenv.mkDerivation`. The original attributes are accessible via the
+function argument, which is conventionally named `oldAttrs`.
+
+The overrides shown above are not global. They do not affect the
+original package; other packages in Nixpkgs continue to depend on the
+original rather than the customised package. This means that if another
+package in your system depends on the original package, you end up with
+two instances of the package. If you want to have everything depend on
+your customised instance, you can apply a *global* override as follows:
+
+```nix
+nixpkgs.config.packageOverrides = pkgs:
+  { emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };
+  };
+```
+
+The effect of this definition is essentially equivalent to modifying the
+`emacs` attribute in the Nixpkgs source tree. Any package in Nixpkgs
+that depends on `emacs` will be passed your customised instance.
+(However, the value `pkgs.emacs` in `nixpkgs.config.packageOverrides`
+refers to the original rather than overridden instance, to prevent an
+infinite recursion.)
diff --git a/nixpkgs/nixos/doc/manual/configuration/customizing-packages.xml b/nixpkgs/nixos/doc/manual/configuration/customizing-packages.xml
deleted file mode 100644
index 34e6ab4b24d6..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/customizing-packages.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-customising-packages">
- <title>Customising Packages</title>
-
- <para>
-  Some packages in Nixpkgs have options to enable or disable optional
-  functionality or change other aspects of the package. For instance, the
-  Firefox wrapper package (which provides Firefox with a set of plugins such as
-  the Adobe Flash player) has an option to enable the Google Talk plugin. It
-  can be set in <filename>configuration.nix</filename> as follows: <filename>
-  nixpkgs.config.firefox.enableGoogleTalkPlugin = true; </filename>
- </para>
-
- <warning>
-  <para>
-   Unfortunately, Nixpkgs currently lacks a way to query available
-   configuration options.
-  </para>
- </warning>
-
- <para>
-  Apart from high-level options, it’s possible to tweak a package in almost
-  arbitrary ways, such as changing or disabling dependencies of a package. For
-  instance, the Emacs package in Nixpkgs by default has a dependency on GTK 2.
-  If you want to build it against GTK 3, you can specify that as follows:
-<programlisting>
-<xref linkend="opt-environment.systemPackages"/> = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ];
-</programlisting>
-  The function <varname>override</varname> performs the call to the Nix
-  function that produces Emacs, with the original arguments amended by the set
-  of arguments specified by you. So here the function argument
-  <varname>gtk</varname> gets the value <literal>pkgs.gtk3</literal>, causing
-  Emacs to depend on GTK 3. (The parentheses are necessary because in Nix,
-  function application binds more weakly than list construction, so without
-  them, <xref linkend="opt-environment.systemPackages"/> would be a list with
-  two elements.)
- </para>
-
- <para>
-  Even greater customisation is possible using the function
-  <varname>overrideAttrs</varname>. While the <varname>override</varname>
-  mechanism above overrides the arguments of a package function,
-  <varname>overrideAttrs</varname> allows changing the
-  <emphasis>attributes</emphasis> passed to <literal>mkDerivation</literal>.
-  This permits changing any aspect of the package, such as the source code. For
-  instance, if you want to override the source code of Emacs, you can say:
-<programlisting>
-<xref linkend="opt-environment.systemPackages"/> = [
-  (pkgs.emacs.overrideAttrs (oldAttrs: {
-    name = "emacs-25.0-pre";
-    src = /path/to/my/emacs/tree;
-  }))
-];
-</programlisting>
-  Here, <varname>overrideAttrs</varname> takes the Nix derivation specified by
-  <varname>pkgs.emacs</varname> and produces a new derivation in which the
-  original’s <literal>name</literal> and <literal>src</literal> attribute
-  have been replaced by the given values by re-calling
-  <literal>stdenv.mkDerivation</literal>. The original attributes are
-  accessible via the function argument, which is conventionally named
-  <varname>oldAttrs</varname>.
- </para>
-
- <para>
-  The overrides shown above are not global. They do not affect the original
-  package; other packages in Nixpkgs continue to depend on the original rather
-  than the customised package. This means that if another package in your
-  system depends on the original package, you end up with two instances of the
-  package. If you want to have everything depend on your customised instance,
-  you can apply a <emphasis>global</emphasis> override as follows:
-<screen>
-nixpkgs.config.packageOverrides = pkgs:
-  { emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };
-  };
-</screen>
-  The effect of this definition is essentially equivalent to modifying the
-  <literal>emacs</literal> attribute in the Nixpkgs source tree. Any package in
-  Nixpkgs that depends on <literal>emacs</literal> will be passed your
-  customised instance. (However, the value <literal>pkgs.emacs</literal> in
-  <varname>nixpkgs.config.packageOverrides</varname> refers to the original
-  rather than overridden instance, to prevent an infinite recursion.)
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/declarative-packages.section.md b/nixpkgs/nixos/doc/manual/configuration/declarative-packages.section.md
new file mode 100644
index 000000000000..337cdf8472e4
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/declarative-packages.section.md
@@ -0,0 +1,46 @@
+# Declarative Package Management {#sec-declarative-package-mgmt}
+
+With declarative package management, you specify which packages you want
+on your system by setting the option
+[](#opt-environment.systemPackages). For instance, adding the
+following line to `configuration.nix` enables the Mozilla Thunderbird
+email application:
+
+```nix
+environment.systemPackages = [ pkgs.thunderbird ];
+```
+
+The effect of this specification is that the Thunderbird package from
+Nixpkgs will be built or downloaded as part of the system when you run
+`nixos-rebuild switch`.
+
+::: {.note}
+Some packages require additional global configuration such as D-Bus or
+systemd service registration so adding them to
+[](#opt-environment.systemPackages) might not be sufficient. You are
+advised to check the [list of options](#ch-options) whether a NixOS
+module for the package does not exist.
+:::
+
+You can get a list of the available packages as follows:
+
+```ShellSession
+$ nix-env -qaP '*' --description
+nixos.firefox   firefox-23.0   Mozilla Firefox - the browser, reloaded
+...
+```
+
+The first column in the output is the *attribute name*, such as
+`nixos.thunderbird`.
+
+Note: the `nixos` prefix tells us that we want to get the package from
+the `nixos` channel and works only in CLI tools. In declarative
+configuration use `pkgs` prefix (variable).
+
+To "uninstall" a package, simply remove it from
+[](#opt-environment.systemPackages) and run `nixos-rebuild switch`.
+
+```{=docbook}
+<xi:include href="customizing-packages.section.xml" />
+<xi:include href="adding-custom-packages.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/declarative-packages.xml b/nixpkgs/nixos/doc/manual/configuration/declarative-packages.xml
deleted file mode 100644
index cd84d1951d24..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/declarative-packages.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-declarative-package-mgmt">
- <title>Declarative Package Management</title>
-
- <para>
-  With declarative package management, you specify which packages you want on
-  your system by setting the option
-  <xref linkend="opt-environment.systemPackages"/>. For instance, adding the
-  following line to <filename>configuration.nix</filename> enables the Mozilla
-  Thunderbird email application:
-<programlisting>
-<xref linkend="opt-environment.systemPackages"/> = [ pkgs.thunderbird ];
-</programlisting>
-  The effect of this specification is that the Thunderbird package from Nixpkgs
-  will be built or downloaded as part of the system when you run
-  <command>nixos-rebuild switch</command>.
- </para>
-
- <note>
-  <para>
-   Some packages require additional global configuration such as D-Bus or systemd service registration so adding them to <xref linkend="opt-environment.systemPackages"/> might not be sufficient. You are advised to check the <link xlink:href="#ch-options">list of options</link> whether a NixOS module for the package does not exist.
-  </para>
- </note>
-
- <para>
-  You can get a list of the available packages as follows:
-<screen>
-<prompt>$ </prompt>nix-env -qaP '*' --description
-nixos.firefox   firefox-23.0   Mozilla Firefox - the browser, reloaded
-<replaceable>...</replaceable>
-</screen>
-  The first column in the output is the <emphasis>attribute name</emphasis>,
-  such as <literal>nixos.thunderbird</literal>.
- </para>
- <para>
-  Note: the <literal>nixos</literal> prefix tells us that we want to get the
-  package from the <literal>nixos</literal> channel and works only in CLI tools.
-
-  In declarative configuration use <literal>pkgs</literal> prefix (variable).
- </para>
-
- <para>
-  To “uninstall” a package, simply remove it from
-  <xref linkend="opt-environment.systemPackages"/> and run
-  <command>nixos-rebuild switch</command>.
- </para>
-
- <xi:include href="customizing-packages.xml" />
-
- <xi:include href="adding-custom-packages.xml" />
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/file-systems.chapter.md b/nixpkgs/nixos/doc/manual/configuration/file-systems.chapter.md
new file mode 100644
index 000000000000..901e2e4f181b
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/file-systems.chapter.md
@@ -0,0 +1,42 @@
+# File Systems {#ch-file-systems}
+
+You can define file systems using the `fileSystems` configuration
+option. For instance, the following definition causes NixOS to mount the
+Ext4 file system on device `/dev/disk/by-label/data` onto the mount
+point `/data`:
+
+```nix
+fileSystems."/data" =
+  { device = "/dev/disk/by-label/data";
+    fsType = "ext4";
+  };
+```
+
+This will create an entry in `/etc/fstab`, which will generate a
+corresponding [systemd.mount](https://www.freedesktop.org/software/systemd/man/systemd.mount.html)
+unit via [systemd-fstab-generator](https://www.freedesktop.org/software/systemd/man/systemd-fstab-generator.html).
+The filesystem will be mounted automatically unless `"noauto"` is
+present in [options](#opt-fileSystems._name_.options). `"noauto"`
+filesystems can be mounted explicitly using `systemctl` e.g.
+`systemctl start data.mount`. Mount points are created automatically if they don't
+already exist. For `device`, it's best to use the topology-independent
+device aliases in `/dev/disk/by-label` and `/dev/disk/by-uuid`, as these
+don't change if the topology changes (e.g. if a disk is moved to another
+IDE controller).
+
+You can usually omit the file system type (`fsType`), since `mount` can
+usually detect the type and load the necessary kernel module
+automatically. However, if the file system is needed at early boot (in
+the initial ramdisk) and is not `ext2`, `ext3` or `ext4`, then it's best
+to specify `fsType` to ensure that the kernel module is available.
+
+::: {.note}
+System startup will fail if any of the filesystems fails to mount,
+dropping you to the emergency shell. You can make a mount asynchronous
+and non-critical by adding `options = [ "nofail" ];`.
+:::
+
+```{=docbook}
+<xi:include href="luks-file-systems.section.xml" />
+<xi:include href="sshfs-file-systems.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/file-systems.xml b/nixpkgs/nixos/doc/manual/configuration/file-systems.xml
deleted file mode 100644
index 42c59844ff4a..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/file-systems.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="ch-file-systems">
- <title>File Systems</title>
- <para>
-  You can define file systems using the <option>fileSystems</option>
-  configuration option. For instance, the following definition causes NixOS to
-  mount the Ext4 file system on device
-  <filename>/dev/disk/by-label/data</filename> onto the mount point
-  <filename>/data</filename>:
-<programlisting>
-<xref linkend="opt-fileSystems"/>."/data" =
-  { device = "/dev/disk/by-label/data";
-    fsType = "ext4";
-  };
-</programlisting>
-  This will create an entry in <filename>/etc/fstab</filename>, which will
-  generate a corresponding
-  <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.mount.html">systemd.mount</link>
-  unit via
-  <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd-fstab-generator.html">systemd-fstab-generator</link>.
-  The filesystem will be mounted automatically unless
-  <literal>"noauto"</literal> is present in <link
-  linkend="opt-fileSystems._name_.options">options</link>.
-  <literal>"noauto"</literal> filesystems can be mounted explicitly using
-  <command>systemctl</command> e.g. <command>systemctl start
-  data.mount</command>.
-  Mount points are created automatically if they don’t already exist. For
-  <option><link linkend="opt-fileSystems._name_.device">device</link></option>,
-  it’s best to use the topology-independent device aliases in
-  <filename>/dev/disk/by-label</filename> and
-  <filename>/dev/disk/by-uuid</filename>, as these don’t change if the
-  topology changes (e.g. if a disk is moved to another IDE controller).
- </para>
- <para>
-  You can usually omit the file system type
-  (<option><link linkend="opt-fileSystems._name_.fsType">fsType</link></option>),
-  since <command>mount</command> can usually detect the type and load the
-  necessary kernel module automatically. However, if the file system is needed
-  at early boot (in the initial ramdisk) and is not <literal>ext2</literal>,
-  <literal>ext3</literal> or <literal>ext4</literal>, then it’s best to
-  specify <option>fsType</option> to ensure that the kernel module is
-  available.
- </para>
- <note>
-  <para>
-   System startup will fail if any of the filesystems fails to mount, dropping
-   you to the emergency shell. You can make a mount asynchronous and
-   non-critical by adding
-   <literal><link linkend="opt-fileSystems._name_.options">options</link> = [
-   "nofail" ];</literal>.
-  </para>
- </note>
- <xi:include href="luks-file-systems.xml" />
- <xi:include href="../from_md/configuration/sshfs-file-systems.section.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/firewall.section.md b/nixpkgs/nixos/doc/manual/configuration/firewall.section.md
new file mode 100644
index 000000000000..dbf0ffb9273e
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/firewall.section.md
@@ -0,0 +1,32 @@
+# Firewall {#sec-firewall}
+
+NixOS has a simple stateful firewall that blocks incoming connections
+and other unexpected packets. The firewall applies to both IPv4 and IPv6
+traffic. It is enabled by default. It can be disabled as follows:
+
+```nix
+networking.firewall.enable = false;
+```
+
+If the firewall is enabled, you can open specific TCP ports to the
+outside world:
+
+```nix
+networking.firewall.allowedTCPPorts = [ 80 443 ];
+```
+
+Note that TCP port 22 (ssh) is opened automatically if the SSH daemon is
+enabled (`services.openssh.enable = true`). UDP ports can be opened through
+[](#opt-networking.firewall.allowedUDPPorts).
+
+To open ranges of TCP ports:
+
+```nix
+networking.firewall.allowedTCPPortRanges = [
+  { from = 4000; to = 4007; }
+  { from = 8000; to = 8010; }
+];
+```
+
+Similarly, UDP port ranges can be opened through
+[](#opt-networking.firewall.allowedUDPPortRanges).
diff --git a/nixpkgs/nixos/doc/manual/configuration/firewall.xml b/nixpkgs/nixos/doc/manual/configuration/firewall.xml
deleted file mode 100644
index 47a19ac82c0f..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/firewall.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-firewall">
- <title>Firewall</title>
-
- <para>
-  NixOS has a simple stateful firewall that blocks incoming connections and
-  other unexpected packets. The firewall applies to both IPv4 and IPv6 traffic.
-  It is enabled by default. It can be disabled as follows:
-<programlisting>
-<xref linkend="opt-networking.firewall.enable"/> = false;
-</programlisting>
-  If the firewall is enabled, you can open specific TCP ports to the outside
-  world:
-<programlisting>
-<xref linkend="opt-networking.firewall.allowedTCPPorts"/> = [ 80 443 ];
-</programlisting>
-  Note that TCP port 22 (ssh) is opened automatically if the SSH daemon is
-  enabled (<option><xref linkend="opt-services.openssh.enable"/> =
-  true</option>). UDP ports can be opened through
-  <xref linkend="opt-networking.firewall.allowedUDPPorts"/>.
- </para>
-
- <para>
-  To open ranges of TCP ports:
-<programlisting>
-<xref linkend="opt-networking.firewall.allowedTCPPortRanges"/> = [
-  { from = 4000; to = 4007; }
-  { from = 8000; to = 8010; }
-];
-</programlisting>
-  Similarly, UDP port ranges can be opened through
-  <xref linkend="opt-networking.firewall.allowedUDPPortRanges"/>.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/gpu-accel.chapter.md b/nixpkgs/nixos/doc/manual/configuration/gpu-accel.chapter.md
new file mode 100644
index 000000000000..08b6af5d98ae
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/gpu-accel.chapter.md
@@ -0,0 +1,204 @@
+# GPU acceleration {#sec-gpu-accel}
+
+NixOS provides various APIs that benefit from GPU hardware acceleration,
+such as VA-API and VDPAU for video playback; OpenGL and Vulkan for 3D
+graphics; and OpenCL for general-purpose computing. This chapter
+describes how to set up GPU hardware acceleration (as far as this is not
+done automatically) and how to verify that hardware acceleration is
+indeed used.
+
+Most of the aforementioned APIs are agnostic with regards to which
+display server is used. Consequently, these instructions should apply
+both to the X Window System and Wayland compositors.
+
+## OpenCL {#sec-gpu-accel-opencl}
+
+[OpenCL](https://en.wikipedia.org/wiki/OpenCL) is a general compute API.
+It is used by various applications such as Blender and Darktable to
+accelerate certain operations.
+
+OpenCL applications load drivers through the *Installable Client Driver*
+(ICD) mechanism. In this mechanism, an ICD file specifies the path to
+the OpenCL driver for a particular GPU family. In NixOS, there are two
+ways to make ICD files visible to the ICD loader. The first is through
+the `OCL_ICD_VENDORS` environment variable. This variable can contain a
+directory which is scanned by the ICL loader for ICD files. For example:
+
+```ShellSession
+$ export \
+  OCL_ICD_VENDORS=`nix-build '<nixpkgs>' --no-out-link -A rocm-opencl-icd`/etc/OpenCL/vendors/
+```
+
+The second mechanism is to add the OpenCL driver package to
+[](#opt-hardware.opengl.extraPackages).
+This links the ICD file under `/run/opengl-driver`, where it will be visible
+to the ICD loader.
+
+The proper installation of OpenCL drivers can be verified through the
+`clinfo` command of the clinfo package. This command will report the
+number of hardware devices that is found and give detailed information
+for each device:
+
+```ShellSession
+$ clinfo | head -n3
+Number of platforms  1
+Platform Name        AMD Accelerated Parallel Processing
+Platform Vendor      Advanced Micro Devices, Inc.
+```
+
+### AMD {#sec-gpu-accel-opencl-amd}
+
+Modern AMD [Graphics Core
+Next](https://en.wikipedia.org/wiki/Graphics_Core_Next) (GCN) GPUs are
+supported through the rocm-opencl-icd package. Adding this package to
+[](#opt-hardware.opengl.extraPackages)
+enables OpenCL support:
+
+```nix
+hardware.opengl.extraPackages = [
+  rocm-opencl-icd
+];
+```
+
+### Intel {#sec-gpu-accel-opencl-intel}
+
+[Intel Gen8 and later
+GPUs](https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units#Gen8)
+are supported by the Intel NEO OpenCL runtime that is provided by the
+intel-compute-runtime package. For Gen7 GPUs, the deprecated Beignet
+runtime can be used, which is provided by the beignet package. The
+proprietary Intel OpenCL runtime, in the intel-ocl package, is an
+alternative for Gen7 GPUs.
+
+The intel-compute-runtime, beignet, or intel-ocl package can be added to
+[](#opt-hardware.opengl.extraPackages)
+to enable OpenCL support. For example, for Gen8 and later GPUs, the following
+configuration can be used:
+
+```nix
+hardware.opengl.extraPackages = [
+  intel-compute-runtime
+];
+```
+
+## Vulkan {#sec-gpu-accel-vulkan}
+
+[Vulkan](https://en.wikipedia.org/wiki/Vulkan_(API)) is a graphics and
+compute API for GPUs. It is used directly by games or indirectly though
+compatibility layers like
+[DXVK](https://github.com/doitsujin/dxvk/wiki).
+
+By default, if [](#opt-hardware.opengl.driSupport)
+is enabled, mesa is installed and provides Vulkan for supported hardware.
+
+Similar to OpenCL, Vulkan drivers are loaded through the *Installable
+Client Driver* (ICD) mechanism. ICD files for Vulkan are JSON files that
+specify the path to the driver library and the supported Vulkan version.
+All successfully loaded drivers are exposed to the application as
+different GPUs. In NixOS, there are two ways to make ICD files visible
+to Vulkan applications: an environment variable and a module option.
+
+The first option is through the `VK_ICD_FILENAMES` environment variable.
+This variable can contain multiple JSON files, separated by `:`. For
+example:
+
+```ShellSession
+$ export \
+  VK_ICD_FILENAMES=`nix-build '<nixpkgs>' --no-out-link -A amdvlk`/share/vulkan/icd.d/amd_icd64.json
+```
+
+The second mechanism is to add the Vulkan driver package to
+[](#opt-hardware.opengl.extraPackages).
+This links the ICD file under `/run/opengl-driver`, where it will be
+visible to the ICD loader.
+
+The proper installation of Vulkan drivers can be verified through the
+`vulkaninfo` command of the vulkan-tools package. This command will
+report the hardware devices and drivers found, in this example output
+amdvlk and radv:
+
+```ShellSession
+$ vulkaninfo | grep GPU
+                GPU id  : 0 (Unknown AMD GPU)
+                GPU id  : 1 (AMD RADV NAVI10 (LLVM 9.0.1))
+     ...
+GPU0:
+        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
+        deviceName     = Unknown AMD GPU
+GPU1:
+        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
+```
+
+A simple graphical application that uses Vulkan is `vkcube` from the
+vulkan-tools package.
+
+### AMD {#sec-gpu-accel-vulkan-amd}
+
+Modern AMD [Graphics Core
+Next](https://en.wikipedia.org/wiki/Graphics_Core_Next) (GCN) GPUs are
+supported through either radv, which is part of mesa, or the amdvlk
+package. Adding the amdvlk package to
+[](#opt-hardware.opengl.extraPackages)
+makes amdvlk the default driver and hides radv and lavapipe from the device list.
+A specific driver can be forced as follows:
+
+```nix
+hardware.opengl.extraPackages = [
+  pkgs.amdvlk
+];
+
+# To enable Vulkan support for 32-bit applications, also add:
+hardware.opengl.extraPackages32 = [
+  pkgs.driversi686Linux.amdvlk
+];
+
+# Force radv
+environment.variables.AMD_VULKAN_ICD = "RADV";
+# Or
+environment.variables.VK_ICD_FILENAMES =
+  "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
+```
+
+## Common issues {#sec-gpu-accel-common-issues}
+
+### User permissions {#sec-gpu-accel-common-issues-permissions}
+
+Except where noted explicitly, it should not be necessary to adjust user
+permissions to use these acceleration APIs. In the default
+configuration, GPU devices have world-read/write permissions
+(`/dev/dri/renderD*`) or are tagged as `uaccess` (`/dev/dri/card*`). The
+access control lists of devices with the `uaccess` tag will be updated
+automatically when a user logs in through `systemd-logind`. For example,
+if the user *jane* is logged in, the access control list should look as
+follows:
+
+```ShellSession
+$ getfacl /dev/dri/card0
+# file: dev/dri/card0
+# owner: root
+# group: video
+user::rw-
+user:jane:rw-
+group::rw-
+mask::rw-
+other::---
+```
+
+If you disabled (this functionality of) `systemd-logind`, you may need
+to add the user to the `video` group and log in again.
+
+### Mixing different versions of nixpkgs {#sec-gpu-accel-common-issues-mixing-nixpkgs}
+
+The *Installable Client Driver* (ICD) mechanism used by OpenCL and
+Vulkan loads runtimes into its address space using `dlopen`. Mixing an
+ICD loader mechanism and runtimes from different version of nixpkgs may
+not work. For example, if the ICD loader uses an older version of glibc
+than the runtime, the runtime may not be loadable due to missing
+symbols. Unfortunately, the loader will generally be quiet about such
+issues.
+
+If you suspect that you are running into library version mismatches
+between an ICL loader and a runtime, you could run an application with
+the `LD_DEBUG` variable set to get more diagnostic information. For
+example, OpenCL can be tested with `LD_DEBUG=files clinfo`, which should
+report missing symbols.
diff --git a/nixpkgs/nixos/doc/manual/configuration/gpu-accel.xml b/nixpkgs/nixos/doc/manual/configuration/gpu-accel.xml
deleted file mode 100644
index 9aa9be86a061..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/gpu-accel.xml
+++ /dev/null
@@ -1,262 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-gpu-accel">
-  <title>GPU acceleration</title>
-
-  <para>
-    NixOS provides various APIs that benefit from GPU hardware
-    acceleration, such as VA-API and VDPAU for video playback; OpenGL and
-    Vulkan for 3D graphics; and OpenCL for general-purpose computing.
-    This chapter describes how to set up GPU hardware acceleration (as far
-    as this is not done automatically) and how to verify that hardware
-    acceleration is indeed used.
-  </para>
-
-  <para>
-    Most of the aforementioned APIs are agnostic with regards to which
-    display server is used. Consequently, these instructions should apply
-    both to the X Window System and Wayland compositors.
-  </para>
-
-  <section xml:id="sec-gpu-accel-opencl">
-    <title>OpenCL</title>
-
-    <para>
-      <link xlink:href="https://en.wikipedia.org/wiki/OpenCL">OpenCL</link> is a
-      general compute API. It is used by various applications such as
-      Blender and Darktable to accelerate certain operations.
-    </para>
-
-    <para>
-      OpenCL applications load drivers through the <emphasis>Installable Client
-      Driver</emphasis> (ICD) mechanism. In this mechanism, an ICD file
-      specifies the path to the OpenCL driver for a particular GPU family.
-      In NixOS, there are two ways to make ICD files visible to the ICD
-      loader. The first is through the <varname>OCL_ICD_VENDORS</varname>
-      environment variable. This variable can contain a directory which
-      is scanned by the ICL loader for ICD files. For example:
-
-      <screen><prompt>$</prompt> export \
-  OCL_ICD_VENDORS=`nix-build '&lt;nixpkgs&gt;' --no-out-link -A rocm-opencl-icd`/etc/OpenCL/vendors/</screen>
-    </para>
-
-    <para>
-      The second mechanism is to add the OpenCL driver package to
-      <xref linkend="opt-hardware.opengl.extraPackages"/>. This links the
-      ICD file under <filename>/run/opengl-driver</filename>, where it will
-      be visible to the ICD loader.
-    </para>
-
-    <para>
-      The proper installation of OpenCL drivers can be verified through
-      the <command>clinfo</command> command of the <package>clinfo</package>
-      package. This command will report the number of hardware devices
-      that is found and give detailed information for each device:
-    </para>
-
-    <screen><prompt>$</prompt> clinfo | head -n3
-Number of platforms  1
-Platform Name        AMD Accelerated Parallel Processing
-Platform Vendor      Advanced Micro Devices, Inc.</screen>
-
-    <section xml:id="sec-gpu-accel-opencl-amd">
-      <title>AMD</title>
-
-      <para>
-       Modern AMD <link
-       xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
-       Core Next</link> (GCN) GPUs are supported through the
-       <package>rocm-opencl-icd</package> package. Adding this package to
-       <xref linkend="opt-hardware.opengl.extraPackages"/> enables OpenCL
-       support:
-
-       <programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
-         rocm-opencl-icd
-       ];</programlisting>
-      </para>
-    </section>
-
-    <section xml:id="sec-gpu-accel-opencl-intel">
-      <title>Intel</title>
-
-      <para>
-       <link
-         xlink:href="https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units#Gen8">Intel
-       Gen8 and later GPUs</link> are supported by the Intel NEO OpenCL
-       runtime that is provided by the
-       <package>intel-compute-runtime</package> package. For Gen7 GPUs,
-       the deprecated Beignet runtime can be used, which is provided
-       by the <package>beignet</package> package. The proprietary Intel
-       OpenCL runtime, in the <package>intel-ocl</package> package, is
-       an alternative for Gen7 GPUs.
-      </para>
-
-      <para>
-       The <package>intel-compute-runtime</package>, <package>beignet</package>,
-       or <package>intel-ocl</package> package can be added to
-       <xref linkend="opt-hardware.opengl.extraPackages"/> to enable OpenCL
-       support. For example, for Gen8 and later GPUs, the following
-       configuration can be used:
-
-      <programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
-        intel-compute-runtime
-      ];</programlisting>
-
-      </para>
-    </section>
-  </section>
-
-  <section xml:id="sec-gpu-accel-vulkan">
-    <title>Vulkan</title>
-
-    <para>
-      <link xlink:href="https://en.wikipedia.org/wiki/Vulkan_(API)">Vulkan</link> is a
-      graphics and compute API for GPUs. It is used directly by games or indirectly though
-      compatibility layers like <link xlink:href="https://github.com/doitsujin/dxvk/wiki">DXVK</link>.
-    </para>
-
-    <para>
-     By default, if <xref linkend="opt-hardware.opengl.driSupport"/> is enabled,
-     <package>mesa</package> is installed and provides Vulkan for supported hardware.
-    </para>
-
-    <para>
-      Similar to OpenCL, Vulkan drivers are loaded through the <emphasis>Installable Client
-      Driver</emphasis> (ICD) mechanism. ICD files for Vulkan are JSON files that specify
-      the path to the driver library and the supported Vulkan version. All successfully
-      loaded drivers are exposed to the application as different GPUs.
-      In NixOS, there are two ways to make ICD files visible to Vulkan applications: an
-      environment variable and a module option.
-    </para>
-
-    <para>
-      The first option is through the <varname>VK_ICD_FILENAMES</varname>
-      environment variable. This variable can contain multiple JSON files, separated by
-      <literal>:</literal>. For example:
-
-      <screen><prompt>$</prompt> export \
-  VK_ICD_FILENAMES=`nix-build '&lt;nixpkgs&gt;' --no-out-link -A amdvlk`/share/vulkan/icd.d/amd_icd64.json</screen>
-    </para>
-
-    <para>
-      The second mechanism is to add the Vulkan driver package to
-      <xref linkend="opt-hardware.opengl.extraPackages"/>. This links the
-      ICD file under <filename>/run/opengl-driver</filename>, where it will
-      be visible to the ICD loader.
-    </para>
-
-    <para>
-      The proper installation of Vulkan drivers can be verified through
-      the <command>vulkaninfo</command> command of the <package>vulkan-tools</package>
-      package. This command will report the hardware devices and drivers found,
-      in this example output amdvlk and radv:
-    </para>
-
-    <screen><prompt>$</prompt> vulkaninfo | grep GPU
-                GPU id  : 0 (Unknown AMD GPU)
-                GPU id  : 1 (AMD RADV NAVI10 (LLVM 9.0.1))
-     ...
-GPU0:
-        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
-        deviceName     = Unknown AMD GPU
-GPU1:
-        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU</screen>
-
-    <para>
-      A simple graphical application that uses Vulkan is <command>vkcube</command>
-      from the <package>vulkan-tools</package> package.
-    </para>
-
-    <section xml:id="sec-gpu-accel-vulkan-amd">
-      <title>AMD</title>
-
-      <para>
-       Modern AMD <link
-       xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
-       Core Next</link> (GCN) GPUs are supported through either radv, which is
-       part of <package>mesa</package>, or the <package>amdvlk</package> package.
-       Adding the <package>amdvlk</package> package to
-       <xref linkend="opt-hardware.opengl.extraPackages"/> makes amdvlk the
-       default driver and hides radv and lavapipe from the device list. A
-       specific driver can be forced as follows:
-
-       <programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
-         pkgs.<package>amdvlk</package>
-       ];
-
-       # To enable Vulkan support for 32-bit applications, also add:
-       <xref linkend="opt-hardware.opengl.extraPackages32"/> = [
-         pkgs.driversi686Linux.<package>amdvlk</package>
-       ];
-
-       # Force radv
-       <xref linkend="opt-environment.variables"/>.AMD_VULKAN_ICD = "RADV";
-       # Or
-       <xref linkend="opt-environment.variables"/>.VK_ICD_FILENAMES =
-         "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
-       </programlisting>
-      </para>
-    </section>
-  </section>
-
-  <section xml:id="sec-gpu-accel-common-issues">
-   <title>Common issues</title>
-
-   <section xml:id="sec-gpu-accel-common-issues-permissions">
-    <title>User permissions</title>
-
-    <para>
-     Except where noted explicitly, it should not be necessary to
-     adjust user permissions to use these acceleration APIs. In the default
-     configuration, GPU devices have world-read/write permissions
-     (<filename>/dev/dri/renderD*</filename>) or are tagged as
-     <code>uaccess</code> (<filename>/dev/dri/card*</filename>).  The
-     access control lists of devices with the <varname>uaccess</varname>
-     tag will be updated automatically when a user logs in through
-     <command>systemd-logind</command>. For example, if the user
-     <emphasis>jane</emphasis> is logged in, the access control list
-     should look as follows:
-
-     <screen><prompt>$</prompt> getfacl /dev/dri/card0
-# file: dev/dri/card0
-# owner: root
-# group: video
-user::rw-
-user:jane:rw-
-group::rw-
-mask::rw-
-other::---</screen>
-
-     If you disabled (this functionality of) <command>systemd-logind</command>,
-     you may need to add the user to the <code>video</code> group and
-     log in again.
-    </para>
-   </section>
-
-   <section xml:id="sec-gpu-accel-common-issues-mixing-nixpkgs">
-    <title>Mixing different versions of nixpkgs</title>
-
-    <para>
-     The <emphasis>Installable Client Driver</emphasis> (ICD)
-     mechanism used by OpenCL and Vulkan loads runtimes into its address
-     space using <code>dlopen</code>. Mixing an ICD loader mechanism and
-     runtimes from different version of nixpkgs may not work. For example,
-     if the ICD loader uses an older version of <package>glibc</package>
-     than the runtime, the runtime may not be loadable due to
-     missing symbols. Unfortunately, the loader will generally be quiet
-     about such issues.
-    </para>
-
-    <para>
-     If you suspect that you are running into library version mismatches
-     between an ICL loader and a runtime, you could run an application with
-     the <code>LD_DEBUG</code> variable set to get more diagnostic
-     information. For example, OpenCL can be tested with
-     <code>LD_DEBUG=files clinfo</code>, which should report missing
-     symbols.
-    </para>
-   </section>
-  </section>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/ipv4-config.section.md b/nixpkgs/nixos/doc/manual/configuration/ipv4-config.section.md
new file mode 100644
index 000000000000..c73024b856d7
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/ipv4-config.section.md
@@ -0,0 +1,35 @@
+# IPv4 Configuration {#sec-ipv4}
+
+By default, NixOS uses DHCP (specifically, `dhcpcd`) to automatically
+configure network interfaces. However, you can configure an interface
+manually as follows:
+
+```nix
+networking.interfaces.eth0.ipv4.addresses = [ {
+  address = "192.168.1.2";
+  prefixLength = 24;
+} ];
+```
+
+Typically you'll also want to set a default gateway and set of name
+servers:
+
+```nix
+networking.defaultGateway = "192.168.1.1";
+networking.nameservers = [ "8.8.8.8" ];
+```
+
+::: {.note}
+Statically configured interfaces are set up by the systemd service
+`interface-name-cfg.service`. The default gateway and name server
+configuration is performed by `network-setup.service`.
+:::
+
+The host name is set using [](#opt-networking.hostName):
+
+```nix
+networking.hostName = "cartman";
+```
+
+The default host name is `nixos`. Set it to the empty string (`""`) to
+allow the DHCP server to provide the host name.
diff --git a/nixpkgs/nixos/doc/manual/configuration/ipv4-config.xml b/nixpkgs/nixos/doc/manual/configuration/ipv4-config.xml
deleted file mode 100644
index 884becf0979a..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/ipv4-config.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-ipv4">
- <title>IPv4 Configuration</title>
-
- <para>
-  By default, NixOS uses DHCP (specifically, <command>dhcpcd</command>) to
-  automatically configure network interfaces. However, you can configure an
-  interface manually as follows:
-<programlisting>
-<link linkend="opt-networking.interfaces._name_.ipv4.addresses">networking.interfaces.eth0.ipv4.addresses</link> = [ {
-  address = "192.168.1.2";
-  prefixLength = 24;
-} ];
-</programlisting>
-  Typically you’ll also want to set a default gateway and set of name
-  servers:
-<programlisting>
-<xref linkend="opt-networking.defaultGateway"/> = "192.168.1.1";
-<xref linkend="opt-networking.nameservers"/> = [ "8.8.8.8" ];
-</programlisting>
- </para>
-
- <note>
-  <para>
-   Statically configured interfaces are set up by the systemd service
-   <replaceable>interface-name</replaceable><literal>-cfg.service</literal>.
-   The default gateway and name server configuration is performed by
-   <literal>network-setup.service</literal>.
-  </para>
- </note>
-
- <para>
-  The host name is set using <xref linkend="opt-networking.hostName"/>:
-<programlisting>
-<xref linkend="opt-networking.hostName"/> = "cartman";
-</programlisting>
-  The default host name is <literal>nixos</literal>. Set it to the empty string
-  (<literal>""</literal>) to allow the DHCP server to provide the host name.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/ipv6-config.section.md b/nixpkgs/nixos/doc/manual/configuration/ipv6-config.section.md
new file mode 100644
index 000000000000..ce66f53ed472
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/ipv6-config.section.md
@@ -0,0 +1,42 @@
+# IPv6 Configuration {#sec-ipv6}
+
+IPv6 is enabled by default. Stateless address autoconfiguration is used
+to automatically assign IPv6 addresses to all interfaces, and Privacy
+Extensions (RFC 4946) are enabled by default. You can adjust the default
+for this by setting [](#opt-networking.tempAddresses). This option
+may be overridden on a per-interface basis by
+[](#opt-networking.interfaces._name_.tempAddress). You can disable
+IPv6 support globally by setting:
+
+```nix
+networking.enableIPv6 = false;
+```
+
+You can disable IPv6 on a single interface using a normal sysctl (in
+this example, we use interface `eth0`):
+
+```nix
+boot.kernel.sysctl."net.ipv6.conf.eth0.disable_ipv6" = true;
+```
+
+As with IPv4 networking interfaces are automatically configured via
+DHCPv6. You can configure an interface manually:
+
+```nix
+networking.interfaces.eth0.ipv6.addresses = [ {
+  address = "fe00:aa:bb:cc::2";
+  prefixLength = 64;
+} ];
+```
+
+For configuring a gateway, optionally with explicitly specified
+interface:
+
+```nix
+networking.defaultGateway6 = {
+  address = "fe00::1";
+  interface = "enp0s3";
+};
+```
+
+See [](#sec-ipv4) for similar examples and additional information.
diff --git a/nixpkgs/nixos/doc/manual/configuration/ipv6-config.xml b/nixpkgs/nixos/doc/manual/configuration/ipv6-config.xml
deleted file mode 100644
index 45e85dbf3dfd..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/ipv6-config.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-ipv6">
- <title>IPv6 Configuration</title>
-
- <para>
-  IPv6 is enabled by default. Stateless address autoconfiguration is used to
-  automatically assign IPv6 addresses to all interfaces, and Privacy
-  Extensions (RFC 4946) are enabled by default. You can adjust the default
-  for this by setting <xref linkend="opt-networking.tempAddresses"/>.
-  This option may be overridden on a per-interface basis by
-  <xref linkend="opt-networking.interfaces._name_.tempAddress"/>.
-  You can disable IPv6 support globally by setting:
-<programlisting>
-<xref linkend="opt-networking.enableIPv6"/> = false;
-</programlisting>
- </para>
-
- <para>
-  You can disable IPv6 on a single interface using a normal sysctl (in this
-  example, we use interface <varname>eth0</varname>):
-<programlisting>
-<xref linkend="opt-boot.kernel.sysctl"/>."net.ipv6.conf.eth0.disable_ipv6" = true;
-</programlisting>
- </para>
-
- <para>
-  As with IPv4 networking interfaces are automatically configured via DHCPv6.
-  You can configure an interface manually:
-<programlisting>
-<link linkend="opt-networking.interfaces._name_.ipv6.addresses">networking.interfaces.eth0.ipv6.addresses</link> = [ {
-  address = "fe00:aa:bb:cc::2";
-  prefixLength = 64;
-} ];
-</programlisting>
- </para>
-
- <para>
-  For configuring a gateway, optionally with explicitly specified interface:
-<programlisting>
-<xref linkend="opt-networking.defaultGateway6"/> = {
-  address = "fe00::1";
-  interface = "enp0s3";
-};
-</programlisting>
- </para>
-
- <para>
-  See <xref linkend='sec-ipv4' /> for similar examples and additional
-  information.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/kubernetes.chapter.md b/nixpkgs/nixos/doc/manual/configuration/kubernetes.chapter.md
new file mode 100644
index 000000000000..93787577be9b
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/kubernetes.chapter.md
@@ -0,0 +1,104 @@
+# Kubernetes {#sec-kubernetes}
+
+The NixOS Kubernetes module is a collective term for a handful of
+individual submodules implementing the Kubernetes cluster components.
+
+There are generally two ways of enabling Kubernetes on NixOS. One way is
+to enable and configure cluster components appropriately by hand:
+
+```nix
+services.kubernetes = {
+  apiserver.enable = true;
+  controllerManager.enable = true;
+  scheduler.enable = true;
+  addonManager.enable = true;
+  proxy.enable = true;
+  flannel.enable = true;
+};
+```
+
+Another way is to assign cluster roles (\"master\" and/or \"node\") to
+the host. This enables apiserver, controllerManager, scheduler,
+addonManager, kube-proxy and etcd:
+
+```nix
+services.kubernetes.roles = [ "master" ];
+```
+
+While this will enable the kubelet and kube-proxy only:
+
+```nix
+services.kubernetes.roles = [ "node" ];
+```
+
+Assigning both the master and node roles is usable if you want a single
+node Kubernetes cluster for dev or testing purposes:
+
+```nix
+services.kubernetes.roles = [ "master" "node" ];
+```
+
+Note: Assigning either role will also default both
+[](#opt-services.kubernetes.flannel.enable)
+and [](#opt-services.kubernetes.easyCerts)
+to true. This sets up flannel as CNI and activates automatic PKI bootstrapping.
+
+As of kubernetes 1.10.X it has been deprecated to open non-tls-enabled
+ports on kubernetes components. Thus, from NixOS 19.03 all plain HTTP
+ports have been disabled by default. While opening insecure ports is
+still possible, it is recommended not to bind these to other interfaces
+than loopback. To re-enable the insecure port on the apiserver, see options:
+[](#opt-services.kubernetes.apiserver.insecurePort) and
+[](#opt-services.kubernetes.apiserver.insecureBindAddress)
+
+::: {.note}
+As of NixOS 19.03, it is mandatory to configure:
+[](#opt-services.kubernetes.masterAddress).
+The masterAddress must be resolveable and routeable by all cluster nodes.
+In single node clusters, this can be set to `localhost`.
+:::
+
+Role-based access control (RBAC) authorization mode is enabled by
+default. This means that anonymous requests to the apiserver secure port
+will expectedly cause a permission denied error. All cluster components
+must therefore be configured with x509 certificates for two-way tls
+communication. The x509 certificate subject section determines the roles
+and permissions granted by the apiserver to perform clusterwide or
+namespaced operations. See also: [ Using RBAC
+Authorization](https://kubernetes.io/docs/reference/access-authn-authz/rbac/).
+
+The NixOS kubernetes module provides an option for automatic certificate
+bootstrapping and configuration,
+[](#opt-services.kubernetes.easyCerts).
+The PKI bootstrapping process involves setting up a certificate authority (CA)
+daemon (cfssl) on the kubernetes master node. cfssl generates a CA-cert
+for the cluster, and uses the CA-cert for signing subordinate certs issued
+to each of the cluster components. Subsequently, the certmgr daemon monitors
+active certificates and renews them when needed. For single node Kubernetes
+clusters, setting [](#opt-services.kubernetes.easyCerts)
+= true is sufficient and no further action is required. For joining extra node
+machines to an existing cluster on the other hand, establishing initial
+trust is mandatory.
+
+To add new nodes to the cluster: On any (non-master) cluster node where
+[](#opt-services.kubernetes.easyCerts)
+is enabled, the helper script `nixos-kubernetes-node-join` is available on PATH.
+Given a token on stdin, it will copy the token to the kubernetes secrets directory
+and restart the certmgr service. As requested certificates are issued, the
+script will restart kubernetes cluster components as needed for them to
+pick up new keypairs.
+
+::: {.note}
+Multi-master (HA) clusters are not supported by the easyCerts module.
+:::
+
+In order to interact with an RBAC-enabled cluster as an administrator,
+one needs to have cluster-admin privileges. By default, when easyCerts
+is enabled, a cluster-admin kubeconfig file is generated and linked into
+`/etc/kubernetes/cluster-admin.kubeconfig` as determined by
+[](#opt-services.kubernetes.pki.etcClusterAdminKubeconfig).
+`export KUBECONFIG=/etc/kubernetes/cluster-admin.kubeconfig` will make
+kubectl use this kubeconfig to access and authenticate the cluster. The
+cluster-admin kubeconfig references an auto-generated keypair owned by
+root. Thus, only root on the kubernetes master may obtain cluster-admin
+rights by means of this file.
diff --git a/nixpkgs/nixos/doc/manual/configuration/kubernetes.xml b/nixpkgs/nixos/doc/manual/configuration/kubernetes.xml
deleted file mode 100644
index 54a100e44795..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/kubernetes.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-kubernetes">
- <title>Kubernetes</title>
- <para>
-  The NixOS Kubernetes module is a collective term for a handful of individual
-  submodules implementing the Kubernetes cluster components.
- </para>
- <para>
-  There are generally two ways of enabling Kubernetes on NixOS. One way is to
-  enable and configure cluster components appropriately by hand:
-<programlisting>
-services.kubernetes = {
-  apiserver.enable = true;
-  controllerManager.enable = true;
-  scheduler.enable = true;
-  addonManager.enable = true;
-  proxy.enable = true;
-  flannel.enable = true;
-};
-</programlisting>
-  Another way is to assign cluster roles ("master" and/or "node") to the host.
-  This enables apiserver, controllerManager, scheduler, addonManager,
-  kube-proxy and etcd:
-<programlisting>
-<xref linkend="opt-services.kubernetes.roles"/> = [ "master" ];
-</programlisting>
-  While this will enable the kubelet and kube-proxy only:
-<programlisting>
-<xref linkend="opt-services.kubernetes.roles"/> = [ "node" ];
-</programlisting>
-  Assigning both the master and node roles is usable if you want a single node
-  Kubernetes cluster for dev or testing purposes:
-<programlisting>
-<xref linkend="opt-services.kubernetes.roles"/> = [ "master" "node" ];
-</programlisting>
-  Note: Assigning either role will also default both
-  <xref linkend="opt-services.kubernetes.flannel.enable"/> and
-  <xref linkend="opt-services.kubernetes.easyCerts"/> to true. This sets up
-  flannel as CNI and activates automatic PKI bootstrapping.
- </para>
- <para>
-  As of kubernetes 1.10.X it has been deprecated to open non-tls-enabled ports
-  on kubernetes components. Thus, from NixOS 19.03 all plain HTTP ports have
-  been disabled by default. While opening insecure ports is still possible, it
-  is recommended not to bind these to other interfaces than loopback. To
-  re-enable the insecure port on the apiserver, see options:
-  <xref linkend="opt-services.kubernetes.apiserver.insecurePort"/> and
-  <xref linkend="opt-services.kubernetes.apiserver.insecureBindAddress"/>
- </para>
- <note>
-  <para>
-   As of NixOS 19.03, it is mandatory to configure:
-   <xref linkend="opt-services.kubernetes.masterAddress"/>. The masterAddress
-   must be resolveable and routeable by all cluster nodes. In single node
-   clusters, this can be set to <literal>localhost</literal>.
-  </para>
- </note>
- <para>
-  Role-based access control (RBAC) authorization mode is enabled by default.
-  This means that anonymous requests to the apiserver secure port will
-  expectedly cause a permission denied error. All cluster components must
-  therefore be configured with x509 certificates for two-way tls communication.
-  The x509 certificate subject section determines the roles and permissions
-  granted by the apiserver to perform clusterwide or namespaced operations. See
-  also:
-  <link
-     xlink:href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">
-  Using RBAC Authorization</link>.
- </para>
- <para>
-  The NixOS kubernetes module provides an option for automatic certificate
-  bootstrapping and configuration,
-  <xref linkend="opt-services.kubernetes.easyCerts"/>. The PKI bootstrapping
-  process involves setting up a certificate authority (CA) daemon (cfssl) on
-  the kubernetes master node. cfssl generates a CA-cert for the cluster, and
-  uses the CA-cert for signing subordinate certs issued to each of the cluster
-  components. Subsequently, the certmgr daemon monitors active certificates and
-  renews them when needed. For single node Kubernetes clusters, setting
-  <xref linkend="opt-services.kubernetes.easyCerts"/> = true is sufficient and
-  no further action is required. For joining extra node machines to an existing
-  cluster on the other hand, establishing initial trust is mandatory.
- </para>
- <para>
-  To add new nodes to the cluster: On any (non-master) cluster node where
-  <xref linkend="opt-services.kubernetes.easyCerts"/> is enabled, the helper
-  script <literal>nixos-kubernetes-node-join</literal> is available on PATH.
-  Given a token on stdin, it will copy the token to the kubernetes secrets
-  directory and restart the certmgr service. As requested certificates are
-  issued, the script will restart kubernetes cluster components as needed for
-  them to pick up new keypairs.
- </para>
- <note>
-  <para>
-   Multi-master (HA) clusters are not supported by the easyCerts module.
-  </para>
- </note>
- <para>
-  In order to interact with an RBAC-enabled cluster as an administrator, one
-  needs to have cluster-admin privileges. By default, when easyCerts is
-  enabled, a cluster-admin kubeconfig file is generated and linked into
-  <literal>/etc/kubernetes/cluster-admin.kubeconfig</literal> as determined by
-  <xref linkend="opt-services.kubernetes.pki.etcClusterAdminKubeconfig"/>.
-  <literal>export KUBECONFIG=/etc/kubernetes/cluster-admin.kubeconfig</literal>
-  will make kubectl use this kubeconfig to access and authenticate the cluster.
-  The cluster-admin kubeconfig references an auto-generated keypair owned by
-  root. Thus, only root on the kubernetes master may obtain cluster-admin
-  rights by means of this file.
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/linux-kernel.chapter.md b/nixpkgs/nixos/doc/manual/configuration/linux-kernel.chapter.md
new file mode 100644
index 000000000000..aad6d49c72c3
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/linux-kernel.chapter.md
@@ -0,0 +1,135 @@
+# Linux Kernel {#sec-kernel-config}
+
+You can override the Linux kernel and associated packages using the
+option `boot.kernelPackages`. For instance, this selects the Linux 3.10
+kernel:
+
+```nix
+boot.kernelPackages = pkgs.linuxPackages_3_10;
+```
+
+Note that this not only replaces the kernel, but also packages that are
+specific to the kernel version, such as the NVIDIA video drivers. This
+ensures that driver packages are consistent with the kernel.
+
+The default Linux kernel configuration should be fine for most users.
+You can see the configuration of your current kernel with the following
+command:
+
+```ShellSession
+zcat /proc/config.gz
+```
+
+If you want to change the kernel configuration, you can use the
+`packageOverrides` feature (see [](#sec-customising-packages)). For
+instance, to enable support for the kernel debugger KGDB:
+
+```nix
+nixpkgs.config.packageOverrides = pkgs:
+  { linux_3_4 = pkgs.linux_3_4.override {
+      extraConfig =
+        ''
+          KGDB y
+        '';
+    };
+  };
+```
+
+`extraConfig` takes a list of Linux kernel configuration options, one
+per line. The name of the option should not include the prefix
+`CONFIG_`. The option value is typically `y`, `n` or `m` (to build
+something as a kernel module).
+
+Kernel modules for hardware devices are generally loaded automatically
+by `udev`. You can force a module to be loaded via
+[](#opt-boot.kernelModules), e.g.
+
+```nix
+boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];
+```
+
+If the module is required early during the boot (e.g. to mount the root
+file system), you can use [](#opt-boot.initrd.kernelModules):
+
+```nix
+boot.initrd.kernelModules = [ "cifs" ];
+```
+
+This causes the specified modules and their dependencies to be added to
+the initial ramdisk.
+
+Kernel runtime parameters can be set through
+[](#opt-boot.kernel.sysctl), e.g.
+
+```nix
+boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120;
+```
+
+sets the kernel's TCP keepalive time to 120 seconds. To see the
+available parameters, run `sysctl -a`.
+
+## Customize your kernel {#sec-linux-config-customizing}
+
+The first step before compiling the kernel is to generate an appropriate
+`.config` configuration. Either you pass your own config via the
+`configfile` setting of `linuxManualConfig`:
+
+```nix
+custom-kernel = super.linuxManualConfig {
+  inherit (super) stdenv hostPlatform;
+  inherit (linux_4_9) src;
+  version = "${linux_4_9.version}-custom";
+
+  configfile = /home/me/my_kernel_config;
+  allowImportFromDerivation = true;
+};
+```
+
+You can edit the config with this snippet (by default `make
+   menuconfig` won\'t work out of the box on nixos):
+
+```ShellSession
+nix-shell -E 'with import <nixpkgs> {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})'
+```
+
+or you can let nixpkgs generate the configuration. Nixpkgs generates it
+via answering the interactive kernel utility `make config`. The answers
+depend on parameters passed to
+`pkgs/os-specific/linux/kernel/generic.nix` (which you can influence by
+overriding `extraConfig, autoModules,
+   modDirVersion, preferBuiltin, extraConfig`).
+
+```nix
+mptcp93.override ({
+  name="mptcp-local";
+
+  ignoreConfigErrors = true;
+  autoModules = false;
+  kernelPreferBuiltin = true;
+
+  enableParallelBuilding = true;
+
+  extraConfig = ''
+    DEBUG_KERNEL y
+    FRAME_POINTER y
+    KGDB y
+    KGDB_SERIAL_CONSOLE y
+    DEBUG_INFO y
+  '';
+});
+```
+
+## Developing kernel modules {#sec-linux-config-developing-modules}
+
+When developing kernel modules it\'s often convenient to run
+edit-compile-run loop as quickly as possible. See below snippet as an
+example of developing `mellanox` drivers.
+
+```ShellSession
+$ nix-build '<nixpkgs>' -A linuxPackages.kernel.dev
+$ nix-shell '<nixpkgs>' -A linuxPackages.kernel
+$ unpackPhase
+$ cd linux-*
+$ make -C $dev/lib/modules/*/build M=$(pwd)/drivers/net/ethernet/mellanox modules
+# insmod ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/linux-kernel.xml b/nixpkgs/nixos/doc/manual/configuration/linux-kernel.xml
deleted file mode 100644
index 529ac1b1cd46..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/linux-kernel.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-kernel-config">
- <title>Linux Kernel</title>
- <para>
-  You can override the Linux kernel and associated packages using the option
-  <option>boot.kernelPackages</option>. For instance, this selects the Linux
-  3.10 kernel:
-<programlisting>
-<xref linkend="opt-boot.kernelPackages"/> = pkgs.linuxPackages_3_10;
-</programlisting>
-  Note that this not only replaces the kernel, but also packages that are
-  specific to the kernel version, such as the NVIDIA video drivers. This
-  ensures that driver packages are consistent with the kernel.
- </para>
- <para>
-  The default Linux kernel configuration should be fine for most users. You can
-  see the configuration of your current kernel with the following command:
-<programlisting>
-zcat /proc/config.gz
-</programlisting>
-  If you want to change the kernel configuration, you can use the
-  <option>packageOverrides</option> feature (see
-  <xref
-linkend="sec-customising-packages" />). For instance, to enable support
-  for the kernel debugger KGDB:
-<programlisting>
-nixpkgs.config.packageOverrides = pkgs:
-  { linux_3_4 = pkgs.linux_3_4.override {
-      extraConfig =
-        ''
-          KGDB y
-        '';
-    };
-  };
-</programlisting>
-  <varname>extraConfig</varname> takes a list of Linux kernel configuration
-  options, one per line. The name of the option should not include the prefix
-  <literal>CONFIG_</literal>. The option value is typically
-  <literal>y</literal>, <literal>n</literal> or <literal>m</literal> (to build
-  something as a kernel module).
- </para>
- <para>
-  Kernel modules for hardware devices are generally loaded automatically by
-  <command>udev</command>. You can force a module to be loaded via
-  <xref linkend="opt-boot.kernelModules"/>, e.g.
-<programlisting>
-<xref linkend="opt-boot.kernelModules"/> = [ "fuse" "kvm-intel" "coretemp" ];
-</programlisting>
-  If the module is required early during the boot (e.g. to mount the root file
-  system), you can use <xref linkend="opt-boot.initrd.kernelModules"/>:
-<programlisting>
-<xref linkend="opt-boot.initrd.kernelModules"/> = [ "cifs" ];
-</programlisting>
-  This causes the specified modules and their dependencies to be added to the
-  initial ramdisk.
- </para>
- <para>
-  Kernel runtime parameters can be set through
-  <xref linkend="opt-boot.kernel.sysctl"/>, e.g.
-<programlisting>
-<xref linkend="opt-boot.kernel.sysctl"/>."net.ipv4.tcp_keepalive_time" = 120;
-</programlisting>
-  sets the kernel’s TCP keepalive time to 120 seconds. To see the available
-  parameters, run <command>sysctl -a</command>.
- </para>
- <section xml:id="sec-linux-config-customizing">
-  <title>Customize your kernel</title>
-
-  <para>
-   The first step before compiling the kernel is to generate an appropriate
-   <literal>.config</literal> configuration. Either you pass your own config
-   via the <literal>configfile</literal> setting of
-   <literal>linuxManualConfig</literal>:
-<screen><![CDATA[
-  custom-kernel = super.linuxManualConfig {
-    inherit (super) stdenv hostPlatform;
-    inherit (linux_4_9) src;
-    version = "${linux_4_9.version}-custom";
-
-    configfile = /home/me/my_kernel_config;
-    allowImportFromDerivation = true;
-  };
-  ]]></screen>
-   You can edit the config with this snippet (by default <command>make
-   menuconfig</command> won't work out of the box on nixos):
-<screen><![CDATA[
-      nix-shell -E 'with import <nixpkgs> {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})'
-  ]]></screen>
-   or you can let nixpkgs generate the configuration. Nixpkgs generates it via
-   answering the interactive kernel utility <command>make config</command>. The
-   answers depend on parameters passed to
-   <filename>pkgs/os-specific/linux/kernel/generic.nix</filename> (which you
-   can influence by overriding <literal>extraConfig, autoModules,
-   modDirVersion, preferBuiltin, extraConfig</literal>).
-<screen><![CDATA[
-
-  mptcp93.override ({
-      name="mptcp-local";
-
-      ignoreConfigErrors = true;
-      autoModules = false;
-      kernelPreferBuiltin = true;
-
-      enableParallelBuilding = true;
-
-      extraConfig = ''
-        DEBUG_KERNEL y
-        FRAME_POINTER y
-        KGDB y
-        KGDB_SERIAL_CONSOLE y
-        DEBUG_INFO y
-      '';
-    });
-  ]]></screen>
-  </para>
- </section>
- <section xml:id="sec-linux-config-developing-modules">
-  <title>Developing kernel modules</title>
-
-  <para>
-   When developing kernel modules it's often convenient to run edit-compile-run
-   loop as quickly as possible. See below snippet as an example of developing
-   <literal>mellanox</literal> drivers.
-  </para>
-
-<screen>
-<prompt>$ </prompt>nix-build '&lt;nixpkgs>' -A linuxPackages.kernel.dev
-<prompt>$ </prompt>nix-shell '&lt;nixpkgs>' -A linuxPackages.kernel
-<prompt>$ </prompt>unpackPhase
-<prompt>$ </prompt>cd linux-*
-<prompt>$ </prompt>make -C $dev/lib/modules/*/build M=$(pwd)/drivers/net/ethernet/mellanox modules
-<prompt># </prompt>insmod ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko
-</screen>
- </section>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/luks-file-systems.section.md b/nixpkgs/nixos/doc/manual/configuration/luks-file-systems.section.md
new file mode 100644
index 000000000000..b5d0407d1659
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/luks-file-systems.section.md
@@ -0,0 +1,77 @@
+# LUKS-Encrypted File Systems {#sec-luks-file-systems}
+
+NixOS supports file systems that are encrypted using *LUKS* (Linux
+Unified Key Setup). For example, here is how you create an encrypted
+Ext4 file system on the device
+`/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d`:
+
+```ShellSession
+# cryptsetup luksFormat /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d
+
+WARNING!
+========
+This will overwrite data on /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d irrevocably.
+
+Are you sure? (Type uppercase yes): YES
+Enter LUKS passphrase: ***
+Verify passphrase: ***
+
+# cryptsetup luksOpen /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d crypted
+Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: ***
+
+# mkfs.ext4 /dev/mapper/crypted
+```
+
+The LUKS volume should be automatically picked up by
+`nixos-generate-config`, but you might want to verify that your
+`hardware-configuration.nix` looks correct. To manually ensure that the
+system is automatically mounted at boot time as `/`, add the following
+to `configuration.nix`:
+
+```nix
+boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d";
+fileSystems."/".device = "/dev/mapper/crypted";
+```
+
+Should grub be used as bootloader, and `/boot` is located on an
+encrypted partition, it is necessary to add the following grub option:
+
+```nix
+boot.loader.grub.enableCryptodisk = true;
+```
+
+## FIDO2 {#sec-luks-file-systems-fido2}
+
+NixOS also supports unlocking your LUKS-Encrypted file system using a
+FIDO2 compatible token. In the following example, we will create a new
+FIDO2 credential and add it as a new key to our existing device
+`/dev/sda2`:
+
+```ShellSession
+# export FIDO2_LABEL="/dev/sda2 @ $HOSTNAME"
+# fido2luks credential "$FIDO2_LABEL"
+f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
+
+# fido2luks -i add-key /dev/sda2 f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
+Password:
+Password (again):
+Old password:
+Old password (again):
+Added to key to device /dev/sda2, slot: 2
+```
+
+To ensure that this file system is decrypted using the FIDO2 compatible
+key, add the following to `configuration.nix`:
+
+```nix
+boot.initrd.luks.fido2Support = true;
+boot.initrd.luks.devices."/dev/sda2".fido2.credential = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";
+```
+
+You can also use the FIDO2 passwordless setup, but for security reasons,
+you might want to enable it only when your device is PIN protected, such
+as [Trezor](https://trezor.io/).
+
+```nix
+boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess = true;
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/luks-file-systems.xml b/nixpkgs/nixos/doc/manual/configuration/luks-file-systems.xml
deleted file mode 100644
index d8654d71ac00..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/luks-file-systems.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-luks-file-systems">
- <title>LUKS-Encrypted File Systems</title>
-
- <para>
-  NixOS supports file systems that are encrypted using
-  <emphasis>LUKS</emphasis> (Linux Unified Key Setup). For example, here is how
-  you create an encrypted Ext4 file system on the device
-  <filename>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</filename>:
-<screen>
-<prompt># </prompt>cryptsetup luksFormat <replaceable>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</replaceable>
-
-WARNING!
-========
-This will overwrite data on /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d irrevocably.
-
-Are you sure? (Type uppercase yes): YES
-Enter LUKS passphrase: ***
-Verify passphrase: ***
-
-<prompt># </prompt>cryptsetup luksOpen <replaceable>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</replaceable> <replaceable>crypted</replaceable>
-Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: ***
-
-<prompt># </prompt>mkfs.ext4 /dev/mapper/<replaceable>crypted</replaceable>
-</screen>
-  The LUKS volume should be automatically picked up by
-  <command>nixos-generate-config</command>, but you might want to verify that your
-  <filename>hardware-configuration.nix</filename> looks correct.
-
-  To manually ensure that the system is automatically mounted at boot time as
-  <filename>/</filename>, add the following to
-  <filename>configuration.nix</filename>:
-<programlisting>
-<link linkend="opt-boot.initrd.luks.devices._name_.device">boot.initrd.luks.devices.crypted.device</link> = "<replaceable>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</replaceable>";
-<xref linkend="opt-fileSystems"/>."/".device = "/dev/mapper/<replaceable>crypted</replaceable>";
-</programlisting>
-  Should grub be used as bootloader, and <filename>/boot</filename> is located
-  on an encrypted partition, it is necessary to add the following grub option:
-<programlisting><xref linkend="opt-boot.loader.grub.enableCryptodisk"/> = true;</programlisting>
- </para>
-  <section xml:id="sec-luks-file-systems-fido2">
-  <title>FIDO2</title>
-
-  <para>
-   NixOS also supports unlocking your LUKS-Encrypted file system using a FIDO2 compatible token. In the following example, we will create a new FIDO2 credential
-   and add it as a new key to our existing device <filename>/dev/sda2</filename>:
-
-   <screen>
-<prompt># </prompt>export FIDO2_LABEL="<replaceable>/dev/sda2</replaceable> @ $HOSTNAME"
-<prompt># </prompt>fido2luks credential "$FIDO2_LABEL"
-f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
-
-<prompt># </prompt>fido2luks -i add-key <replaceable>/dev/sda2</replaceable> <replaceable>f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7</replaceable>
-Password:
-Password (again):
-Old password:
-Old password (again):
-Added to key to device /dev/sda2, slot: 2
-</screen>
-
-  To ensure that this file system is decrypted using the FIDO2 compatible key, add the following to <filename>configuration.nix</filename>:
-<programlisting>
-<link linkend="opt-boot.initrd.luks.fido2Support">boot.initrd.luks.fido2Support</link> = true;
-<link linkend="opt-boot.initrd.luks.devices._name_.fido2.credential">boot.initrd.luks.devices."<replaceable>/dev/sda2</replaceable>".fido2.credential</link> = "<replaceable>f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7</replaceable>";
-</programlisting>
-
-  You can also use the FIDO2 passwordless setup, but for security reasons, you might want to enable it only when your device is PIN protected, such as <link xlink:href="https://trezor.io/">Trezor</link>.
-
-<programlisting>
-<link linkend="opt-boot.initrd.luks.devices._name_.fido2.passwordLess">boot.initrd.luks.devices."<replaceable>/dev/sda2</replaceable>".fido2.passwordLess</link> = true;
-</programlisting>
-  </para>
- </section>
-
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/modularity.section.md b/nixpkgs/nixos/doc/manual/configuration/modularity.section.md
new file mode 100644
index 000000000000..3395ace20c4f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/modularity.section.md
@@ -0,0 +1,133 @@
+# Modularity {#sec-modularity}
+
+The NixOS configuration mechanism is modular. If your
+`configuration.nix` becomes too big, you can split it into multiple
+files. Likewise, if you have multiple NixOS configurations (e.g. for
+different computers) with some commonality, you can move the common
+configuration into a shared file.
+
+Modules have exactly the same syntax as `configuration.nix`. In fact,
+`configuration.nix` is itself a module. You can use other modules by
+including them from `configuration.nix`, e.g.:
+
+```nix
+{ config, pkgs, ... }:
+
+{ imports = [ ./vpn.nix ./kde.nix ];
+  services.httpd.enable = true;
+  environment.systemPackages = [ pkgs.emacs ];
+  ...
+}
+```
+
+Here, we include two modules from the same directory, `vpn.nix` and
+`kde.nix`. The latter might look like this:
+
+```nix
+{ config, pkgs, ... }:
+
+{ services.xserver.enable = true;
+  services.xserver.displayManager.sddm.enable = true;
+  services.xserver.desktopManager.plasma5.enable = true;
+  environment.systemPackages = [ pkgs.vim ];
+}
+```
+
+Note that both `configuration.nix` and `kde.nix` define the option
+[](#opt-environment.systemPackages). When multiple modules define an
+option, NixOS will try to *merge* the definitions. In the case of
+[](#opt-environment.systemPackages), that's easy: the lists of
+packages can simply be concatenated. The value in `configuration.nix` is
+merged last, so for list-type options, it will appear at the end of the
+merged list. If you want it to appear first, you can use `mkBefore`:
+
+```nix
+boot.kernelModules = mkBefore [ "kvm-intel" ];
+```
+
+This causes the `kvm-intel` kernel module to be loaded before any other
+kernel modules.
+
+For other types of options, a merge may not be possible. For instance,
+if two modules define [](#opt-services.httpd.adminAddr),
+`nixos-rebuild` will give an error:
+
+```plain
+The unique option `services.httpd.adminAddr' is defined multiple times, in `/etc/nixos/httpd.nix' and `/etc/nixos/configuration.nix'.
+```
+
+When that happens, it's possible to force one definition take precedence
+over the others:
+
+```nix
+services.httpd.adminAddr = pkgs.lib.mkForce "bob@example.org";
+```
+
+When using multiple modules, you may need to access configuration values
+defined in other modules. This is what the `config` function argument is
+for: it contains the complete, merged system configuration. That is,
+`config` is the result of combining the configurations returned by every
+module [^1] . For example, here is a module that adds some packages to
+[](#opt-environment.systemPackages) only if
+[](#opt-services.xserver.enable) is set to `true` somewhere else:
+
+```nix
+{ config, pkgs, ... }:
+
+{ environment.systemPackages =
+    if config.services.xserver.enable then
+      [ pkgs.firefox
+        pkgs.thunderbird
+      ]
+    else
+      [ ];
+}
+```
+
+With multiple modules, it may not be obvious what the final value of a
+configuration option is. The command `nixos-option` allows you to find
+out:
+
+```ShellSession
+$ nixos-option services.xserver.enable
+true
+
+$ nixos-option boot.kernelModules
+[ "tun" "ipv6" "loop" ... ]
+```
+
+Interactive exploration of the configuration is possible using `nix
+  repl`, a read-eval-print loop for Nix expressions. A typical use:
+
+```ShellSession
+$ nix repl '<nixpkgs/nixos>'
+
+nix-repl> config.networking.hostName
+"mandark"
+
+nix-repl> map (x: x.hostName) config.services.httpd.virtualHosts
+[ "example.org" "example.gov" ]
+```
+
+While abstracting your configuration, you may find it useful to generate
+modules using code, instead of writing files. The example below would
+have the same effect as importing a file which sets those options.
+
+```nix
+{ config, pkgs, ... }:
+
+let netConfig = hostName: {
+  networking.hostName = hostName;
+  networking.useDHCP = false;
+};
+
+in
+
+{ imports = [ (netConfig "nixos.localdomain") ]; }
+```
+
+[^1]: If you're wondering how it's possible that the (indirect) *result*
+    of a function is passed as an *input* to that same function: that's
+    because Nix is a "lazy" language --- it only computes values when
+    they are needed. This works as long as no individual configuration
+    value depends on itself.
diff --git a/nixpkgs/nixos/doc/manual/configuration/modularity.xml b/nixpkgs/nixos/doc/manual/configuration/modularity.xml
deleted file mode 100644
index d6eee4e9d76e..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/modularity.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-modularity">
- <title>Modularity</title>
-
- <para>
-  The NixOS configuration mechanism is modular. If your
-  <filename>configuration.nix</filename> becomes too big, you can split it into
-  multiple files. Likewise, if you have multiple NixOS configurations (e.g. for
-  different computers) with some commonality, you can move the common
-  configuration into a shared file.
- </para>
-
- <para>
-  Modules have exactly the same syntax as
-  <filename>configuration.nix</filename>. In fact,
-  <filename>configuration.nix</filename> is itself a module. You can use other
-  modules by including them from <filename>configuration.nix</filename>, e.g.:
-<programlisting>
-{ config, pkgs, ... }:
-
-{ imports = [ ./vpn.nix ./kde.nix ];
-  <xref linkend="opt-services.httpd.enable"/> = true;
-  <xref linkend="opt-environment.systemPackages"/> = [ pkgs.emacs ];
-  <replaceable>...</replaceable>
-}
-</programlisting>
-  Here, we include two modules from the same directory,
-  <filename>vpn.nix</filename> and <filename>kde.nix</filename>. The latter
-  might look like this:
-<programlisting>
-{ config, pkgs, ... }:
-
-{ <xref linkend="opt-services.xserver.enable"/> = true;
-  <xref linkend="opt-services.xserver.displayManager.sddm.enable"/> = true;
-  <xref linkend="opt-services.xserver.desktopManager.plasma5.enable"/> = true;
-  <xref linkend="opt-environment.systemPackages"/> = [ pkgs.vim ];
-}
-</programlisting>
-  Note that both <filename>configuration.nix</filename> and
-  <filename>kde.nix</filename> define the option
-  <xref linkend="opt-environment.systemPackages"/>. When multiple modules
-  define an option, NixOS will try to <emphasis>merge</emphasis> the
-  definitions. In the case of <xref linkend="opt-environment.systemPackages"/>,
-  that’s easy: the lists of packages can simply be concatenated. The value in
-  <filename>configuration.nix</filename> is merged last, so for list-type
-  options, it will appear at the end of the merged list. If you want it to
-  appear first, you can use <varname>mkBefore</varname>:
-<programlisting>
-<xref linkend="opt-boot.kernelModules"/> = mkBefore [ "kvm-intel" ];
-</programlisting>
-  This causes the <literal>kvm-intel</literal> kernel module to be loaded
-  before any other kernel modules.
- </para>
-
- <para>
-  For other types of options, a merge may not be possible. For instance, if two
-  modules define <xref linkend="opt-services.httpd.adminAddr"/>,
-  <command>nixos-rebuild</command> will give an error:
-<screen>
-The unique option `services.httpd.adminAddr' is defined multiple times, in `/etc/nixos/httpd.nix' and `/etc/nixos/configuration.nix'.
-</screen>
-  When that happens, it’s possible to force one definition take precedence
-  over the others:
-<programlisting>
-<xref linkend="opt-services.httpd.adminAddr"/> = pkgs.lib.mkForce "bob@example.org";
-</programlisting>
- </para>
-
- <para>
-  When using multiple modules, you may need to access configuration values
-  defined in other modules. This is what the <varname>config</varname> function
-  argument is for: it contains the complete, merged system configuration. That
-  is, <varname>config</varname> is the result of combining the configurations
-  returned by every module
-  <footnote xml:id="footnote-nix-is-lazy">
-   <para>
-    If you’re wondering how it’s possible that the (indirect)
-    <emphasis>result</emphasis> of a function is passed as an
-    <emphasis>input</emphasis> to that same function: that’s because Nix is a
-    “lazy” language — it only computes values when they are needed. This
-    works as long as no individual configuration value depends on itself.
-   </para>
-  </footnote>
-  . For example, here is a module that adds some packages to
-  <xref linkend="opt-environment.systemPackages"/> only if
-  <xref linkend="opt-services.xserver.enable"/> is set to
-  <literal>true</literal> somewhere else:
-<programlisting>
-{ config, pkgs, ... }:
-
-{ <xref linkend="opt-environment.systemPackages"/> =
-    if config.<xref linkend="opt-services.xserver.enable"/> then
-      [ pkgs.firefox
-        pkgs.thunderbird
-      ]
-    else
-      [ ];
-}
-</programlisting>
- </para>
-
- <para>
-  With multiple modules, it may not be obvious what the final value of a
-  configuration option is. The command <option>nixos-option</option> allows you
-  to find out:
-<screen>
-<prompt>$ </prompt>nixos-option <xref linkend="opt-services.xserver.enable"/>
-true
-
-<prompt>$ </prompt>nixos-option <xref linkend="opt-boot.kernelModules"/>
-[ "tun" "ipv6" "loop" <replaceable>...</replaceable> ]
-</screen>
-  Interactive exploration of the configuration is possible using <command>nix
-  repl</command>, a read-eval-print loop for Nix expressions. A typical use:
-<screen>
-<prompt>$ </prompt>nix repl '&lt;nixpkgs/nixos>'
-
-<prompt>nix-repl> </prompt>config.<xref linkend="opt-networking.hostName"/>
-"mandark"
-
-<prompt>nix-repl> </prompt>map (x: x.hostName) config.<xref linkend="opt-services.httpd.virtualHosts"/>
-[ "example.org" "example.gov" ]
-</screen>
- </para>
-
- <para>
-  While abstracting your configuration, you may find it useful to generate
-  modules using code, instead of writing files. The example below would have
-  the same effect as importing a file which sets those options.
-<programlisting>
-{ config, pkgs, ... }:
-
-let netConfig = hostName: {
-  networking.hostName = hostName;
-  networking.useDHCP = false;
-};
-
-in
-
-{ imports = [ (netConfig "nixos.localdomain") ]; }
-</programlisting>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/network-manager.section.md b/nixpkgs/nixos/doc/manual/configuration/network-manager.section.md
new file mode 100644
index 000000000000..4bda21d34a10
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/network-manager.section.md
@@ -0,0 +1,42 @@
+# NetworkManager {#sec-networkmanager}
+
+To facilitate network configuration, some desktop environments use
+NetworkManager. You can enable NetworkManager by setting:
+
+```nix
+networking.networkmanager.enable = true;
+```
+
+some desktop managers (e.g., GNOME) enable NetworkManager automatically
+for you.
+
+All users that should have permission to change network settings must
+belong to the `networkmanager` group:
+
+```nix
+users.users.alice.extraGroups = [ "networkmanager" ];
+```
+
+NetworkManager is controlled using either `nmcli` or `nmtui`
+(curses-based terminal user interface). See their manual pages for
+details on their usage. Some desktop environments (GNOME, KDE) have
+their own configuration tools for NetworkManager. On XFCE, there is no
+configuration tool for NetworkManager by default: by enabling
+[](#opt-programs.nm-applet.enable), the graphical applet will be
+installed and will launch automatically when the graphical session is
+started.
+
+::: {.note}
+`networking.networkmanager` and `networking.wireless` (WPA Supplicant)
+can be used together if desired. To do this you need to instruct
+NetworkManager to ignore those interfaces like:
+
+```nix
+networking.networkmanager.unmanaged = [
+   "*" "except:type:wwan" "except:type:gsm"
+];
+```
+
+Refer to the option description for the exact syntax and references to
+external documentation.
+:::
diff --git a/nixpkgs/nixos/doc/manual/configuration/network-manager.xml b/nixpkgs/nixos/doc/manual/configuration/network-manager.xml
deleted file mode 100644
index 94d229fd803f..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/network-manager.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-networkmanager">
- <title>NetworkManager</title>
-
- <para>
-  To facilitate network configuration, some desktop environments use
-  NetworkManager. You can enable NetworkManager by setting:
-<programlisting>
-<xref linkend="opt-networking.networkmanager.enable"/> = true;
-</programlisting>
-  some desktop managers (e.g., GNOME) enable NetworkManager automatically for
-  you.
- </para>
-
- <para>
-  All users that should have permission to change network settings must belong
-  to the <code>networkmanager</code> group:
-<programlisting>
-<link linkend="opt-users.users._name_.extraGroups">users.users.alice.extraGroups</link> = [ "networkmanager" ];
-</programlisting>
- </para>
-
- <para>
-  NetworkManager is controlled using either <command>nmcli</command> or
-  <command>nmtui</command> (curses-based terminal user interface). See their
-  manual pages for details on their usage. Some desktop environments (GNOME,
-  KDE) have their own configuration tools for NetworkManager. On XFCE, there is
-  no configuration tool for NetworkManager by default: by enabling <xref linkend="opt-programs.nm-applet.enable"/>, the
-  graphical applet will be installed and will launch automatically when the graphical session is started.
- </para>
-
- <note>
-  <para>
-   <code>networking.networkmanager</code> and <code>networking.wireless</code>
-   (WPA Supplicant) can be used together if desired. To do this you need to instruct
-   NetworkManager to ignore those interfaces like:
-<programlisting>
-<xref linkend="opt-networking.networkmanager.unmanaged"/> = [
-   "*" "except:type:wwan" "except:type:gsm"
-];
-</programlisting>
-   Refer to the option description for the exact syntax and references to external documentation.
-  </para>
- </note>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/networking.chapter.md b/nixpkgs/nixos/doc/manual/configuration/networking.chapter.md
new file mode 100644
index 000000000000..529dc0610bda
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/networking.chapter.md
@@ -0,0 +1,16 @@
+# Networking {#sec-networking}
+
+This section describes how to configure networking components
+on your NixOS machine.
+
+```{=docbook}
+<xi:include href="network-manager.section.xml" />
+<xi:include href="ssh.section.xml" />
+<xi:include href="ipv4-config.section.xml" />
+<xi:include href="ipv6-config.section.xml" />
+<xi:include href="firewall.section.xml" />
+<xi:include href="wireless.section.xml" />
+<xi:include href="ad-hoc-network-config.section.xml" />
+<xi:include href="renaming-interfaces.section.xml" />
+```
+<!-- TODO: OpenVPN, NAT -->
diff --git a/nixpkgs/nixos/doc/manual/configuration/networking.xml b/nixpkgs/nixos/doc/manual/configuration/networking.xml
deleted file mode 100644
index 8369e9c9c852..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/networking.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-networking">
- <title>Networking</title>
- <para>
-  This section describes how to configure networking components on your NixOS
-  machine.
- </para>
- <xi:include href="network-manager.xml" />
- <xi:include href="ssh.xml" />
- <xi:include href="ipv4-config.xml" />
- <xi:include href="ipv6-config.xml" />
- <xi:include href="firewall.xml" />
- <xi:include href="wireless.xml" />
- <xi:include href="ad-hoc-network-config.xml" />
- <xi:include href="renaming-interfaces.xml" />
-<!-- TODO: OpenVPN, NAT -->
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/package-mgmt.chapter.md b/nixpkgs/nixos/doc/manual/configuration/package-mgmt.chapter.md
new file mode 100644
index 000000000000..a6c414be59a9
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/package-mgmt.chapter.md
@@ -0,0 +1,18 @@
+# Package Management {#sec-package-management}
+
+This section describes how to add additional packages to your system.
+NixOS has two distinct styles of package management:
+
+-   *Declarative*, where you declare what packages you want in your
+    `configuration.nix`. Every time you run `nixos-rebuild`, NixOS will
+    ensure that you get a consistent set of binaries corresponding to
+    your specification.
+
+-   *Ad hoc*, where you install, upgrade and uninstall packages via the
+    `nix-env` command. This style allows mixing packages from different
+    Nixpkgs versions. It's the only choice for non-root users.
+
+```{=docbook}
+<xi:include href="declarative-packages.section.xml" />
+<xi:include href="ad-hoc-packages.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/package-mgmt.xml b/nixpkgs/nixos/doc/manual/configuration/package-mgmt.xml
deleted file mode 100644
index e8ac5d0681a9..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/package-mgmt.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-package-management">
- <title>Package Management</title>
- <para>
-  This section describes how to add additional packages to your system. NixOS
-  has two distinct styles of package management:
-  <itemizedlist>
-   <listitem>
-    <para>
-     <emphasis>Declarative</emphasis>, where you declare what packages you want
-     in your <filename>configuration.nix</filename>. Every time you run
-     <command>nixos-rebuild</command>, NixOS will ensure that you get a
-     consistent set of binaries corresponding to your specification.
-    </para>
-   </listitem>
-   <listitem>
-    <para>
-     <emphasis>Ad hoc</emphasis>, where you install, upgrade and uninstall
-     packages via the <command>nix-env</command> command. This style allows
-     mixing packages from different Nixpkgs versions. It’s the only choice
-     for non-root users.
-    </para>
-   </listitem>
-  </itemizedlist>
- </para>
- <xi:include href="declarative-packages.xml" />
- <xi:include href="ad-hoc-packages.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles.chapter.md b/nixpkgs/nixos/doc/manual/configuration/profiles.chapter.md
new file mode 100644
index 000000000000..b4ae1b7d3faa
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles.chapter.md
@@ -0,0 +1,34 @@
+# Profiles {#ch-profiles}
+
+In some cases, it may be desirable to take advantage of commonly-used,
+predefined configurations provided by nixpkgs, but different from those
+that come as default. This is a role fulfilled by NixOS\'s Profiles,
+which come as files living in `<nixpkgs/nixos/modules/profiles>`. That
+is to say, expected usage is to add them to the imports list of your
+`/etc/configuration.nix` as such:
+
+```nix
+imports = [
+  <nixpkgs/nixos/modules/profiles/profile-name.nix>
+];
+```
+
+Even if some of these profiles seem only useful in the context of
+install media, many are actually intended to be used in real installs.
+
+What follows is a brief explanation on the purpose and use-case for each
+profile. Detailing each option configured by each one is out of scope.
+
+```{=docbook}
+<xi:include href="profiles/all-hardware.section.xml" />
+<xi:include href="profiles/base.section.xml" />
+<xi:include href="profiles/clone-config.section.xml" />
+<xi:include href="profiles/demo.section.xml" />
+<xi:include href="profiles/docker-container.section.xml" />
+<xi:include href="profiles/graphical.section.xml" />
+<xi:include href="profiles/hardened.section.xml" />
+<xi:include href="profiles/headless.section.xml" />
+<xi:include href="profiles/installation-device.section.xml" />
+<xi:include href="profiles/minimal.section.xml" />
+<xi:include href="profiles/qemu-guest.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles.xml b/nixpkgs/nixos/doc/manual/configuration/profiles.xml
deleted file mode 100644
index 9d08f7f7bed2..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="ch-profiles">
- <title>Profiles</title>
- <para>
-  In some cases, it may be desirable to take advantage of commonly-used,
-  predefined configurations provided by nixpkgs, but different from those that
-  come as default. This is a role fulfilled by NixOS's Profiles, which come as
-  files living in <filename>&lt;nixpkgs/nixos/modules/profiles&gt;</filename>.
-  That is to say, expected usage is to add them to the imports list of your
-  <filename>/etc/configuration.nix</filename> as such:
- </para>
-<programlisting>
-  imports = [
-   &lt;nixpkgs/nixos/modules/profiles/profile-name.nix&gt;
-  ];
-</programlisting>
- <para>
-  Even if some of these profiles seem only useful in the context of install
-  media, many are actually intended to be used in real installs.
- </para>
- <para>
-  What follows is a brief explanation on the purpose and use-case for each
-  profile. Detailing each option configured by each one is out of scope.
- </para>
- <xi:include href="profiles/all-hardware.xml" />
- <xi:include href="profiles/base.xml" />
- <xi:include href="profiles/clone-config.xml" />
- <xi:include href="profiles/demo.xml" />
- <xi:include href="profiles/docker-container.xml" />
- <xi:include href="profiles/graphical.xml" />
- <xi:include href="profiles/hardened.xml" />
- <xi:include href="profiles/headless.xml" />
- <xi:include href="profiles/installation-device.xml" />
- <xi:include href="profiles/minimal.xml" />
- <xi:include href="profiles/qemu-guest.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.section.md
new file mode 100644
index 000000000000..e2dd7c76089c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.section.md
@@ -0,0 +1,11 @@
+# All Hardware {#sec-profile-all-hardware}
+
+Enables all hardware supported by NixOS: i.e., all firmware is included, and
+all devices from which one may boot are enabled in the initrd. Its primary
+use is in the NixOS installation CDs.
+
+The enabled kernel modules include support for SATA and PATA, SCSI
+(partially), USB, Firewire (untested), Virtio (QEMU, KVM, etc.), VMware, and
+Hyper-V. Additionally, [](#opt-hardware.enableAllFirmware) is
+enabled, and the firmware for the ZyDAS ZD1211 chipset is specifically
+installed.
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.xml
deleted file mode 100644
index 2936f71069d5..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/all-hardware.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-all-hardware">
- <title>All Hardware</title>
-
- <para>
-  Enables all hardware supported by NixOS: i.e., all firmware is included, and
-  all devices from which one may boot are enabled in the initrd. Its primary
-  use is in the NixOS installation CDs.
- </para>
-
- <para>
-  The enabled kernel modules include support for SATA and PATA, SCSI
-  (partially), USB, Firewire (untested), Virtio (QEMU, KVM, etc.), VMware, and
-  Hyper-V. Additionally, <xref linkend="opt-hardware.enableAllFirmware"/> is
-  enabled, and the firmware for the ZyDAS ZD1211 chipset is specifically
-  installed.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/base.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/base.section.md
new file mode 100644
index 000000000000..59b3068fda32
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/base.section.md
@@ -0,0 +1,7 @@
+# Base {#sec-profile-base}
+
+Defines the software packages included in the "minimal" installation CD. It
+installs several utilities useful in a simple recovery or install media, such
+as a text-mode web browser, and tools for manipulating block devices,
+networking, hardware diagnostics, and filesystems (with their respective
+kernel modules).
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/base.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/base.xml
deleted file mode 100644
index b75f6ba25b4f..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/base.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-base">
- <title>Base</title>
-
- <para>
-  Defines the software packages included in the "minimal" installation CD. It
-  installs several utilities useful in a simple recovery or install media, such
-  as a text-mode web browser, and tools for manipulating block devices,
-  networking, hardware diagnostics, and filesystems (with their respective
-  kernel modules).
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.section.md
new file mode 100644
index 000000000000..e2583715e517
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.section.md
@@ -0,0 +1,11 @@
+# Clone Config {#sec-profile-clone-config}
+
+This profile is used in installer images. It provides an editable
+configuration.nix that imports all the modules that were also used when
+creating the image in the first place. As a result it allows users to edit
+and rebuild the live-system.
+
+On images where the installation media also becomes an installation target,
+copying over `configuration.nix` should be disabled by
+setting `installer.cloneConfig` to `false`.
+For example, this is done in `sd-image-aarch64-installer.nix`.
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.xml
deleted file mode 100644
index 9c70cf352041..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/clone-config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-clone-config">
- <title>Clone Config</title>
-
- <para>
-  This profile is used in installer images. It provides an editable
-  configuration.nix that imports all the modules that were also used when
-  creating the image in the first place. As a result it allows users to edit
-  and rebuild the live-system.
- </para>
-
- <para>
-  On images where the installation media also becomes an installation target,
-  copying over <literal>configuration.nix</literal> should be disabled by
-  setting <literal>installer.cloneConfig</literal> to <literal>false</literal>.
-  For example, this is done in <literal>sd-image-aarch64-installer.nix</literal>.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/demo.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/demo.section.md
new file mode 100644
index 000000000000..0a0df483c123
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/demo.section.md
@@ -0,0 +1,4 @@
+# Demo {#sec-profile-demo}
+
+This profile just enables a `demo` user, with password `demo`, uid `1000`, `wheel` group and
+[autologin in the SDDM display manager](#opt-services.xserver.displayManager.autoLogin).
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/demo.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/demo.xml
deleted file mode 100644
index bc801bb3dc5b..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/demo.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-demo">
- <title>Demo</title>
-
- <para>
-  This profile just enables a <systemitem class="username">demo</systemitem>
-  user, with password <literal>demo</literal>, uid <literal>1000</literal>,
-  <systemitem class="groupname">wheel</systemitem> group and
-  <link linkend="opt-services.xserver.displayManager.autoLogin">autologin in the SDDM display manager</link>.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.section.md
new file mode 100644
index 000000000000..f3e29b92f5e6
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.section.md
@@ -0,0 +1,7 @@
+# Docker Container {#sec-profile-docker-container}
+
+This is the profile from which the Docker images are generated. It prepares a
+working system by importing the [Minimal](#sec-profile-minimal) and
+[Clone Config](#sec-profile-clone-config) profiles, and
+setting appropriate configuration options that are useful inside a container
+context, like [](#opt-boot.isContainer).
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.xml
deleted file mode 100644
index efa7b8f24c43..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/docker-container.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-docker-container">
- <title>Docker Container</title>
-
- <para>
-  This is the profile from which the Docker images are generated. It prepares a
-  working system by importing the
-  <link linkend="sec-profile-minimal">Minimal</link> and
-  <link linkend="sec-profile-clone-config">Clone Config</link> profiles, and
-  setting appropriate configuration options that are useful inside a container
-  context, like <xref linkend="opt-boot.isContainer"/>.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/graphical.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/graphical.section.md
new file mode 100644
index 000000000000..aaea5c8c0288
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/graphical.section.md
@@ -0,0 +1,10 @@
+# Graphical {#sec-profile-graphical}
+
+Defines a NixOS configuration with the Plasma 5 desktop. It's used by the
+graphical installation CD.
+
+It sets [](#opt-services.xserver.enable),
+[](#opt-services.xserver.displayManager.sddm.enable),
+[](#opt-services.xserver.desktopManager.plasma5.enable),
+and [](#opt-services.xserver.libinput.enable) to true. It also
+includes glxinfo and firefox in the system packages list.
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/graphical.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/graphical.xml
deleted file mode 100644
index cc6d0825d241..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/graphical.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-graphical">
- <title>Graphical</title>
-
- <para>
-  Defines a NixOS configuration with the Plasma 5 desktop. It's used by the
-  graphical installation CD.
- </para>
-
- <para>
-  It sets <xref linkend="opt-services.xserver.enable"/>,
-  <xref linkend="opt-services.xserver.displayManager.sddm.enable"/>,
-  <xref linkend="opt-services.xserver.desktopManager.plasma5.enable"/>, and
-  <xref linkend="opt-services.xserver.libinput.enable"/> to true. It also
-  includes glxinfo and firefox in the system packages list.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/hardened.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/hardened.section.md
new file mode 100644
index 000000000000..9fb5e18c384a
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/hardened.section.md
@@ -0,0 +1,20 @@
+# Hardened {#sec-profile-hardened}
+
+A profile with most (vanilla) hardening options enabled by default,
+potentially at the cost of stability, features and performance.
+
+This includes a hardened kernel, and limiting the system information
+available to processes through the `/sys` and
+`/proc` filesystems. It also disables the User Namespaces
+feature of the kernel, which stops Nix from being able to build anything
+(this particular setting can be overriden via
+[](#opt-security.allowUserNamespaces)). See the
+[profile source](https://github.com/nixos/nixpkgs/tree/master/nixos/modules/profiles/hardened.nix)
+for further detail on which settings are altered.
+
+::: {.warning}
+This profile enables options that are known to affect system
+stability. If you experience any stability issues when using the
+profile, try disabling it. If you report an issue and use this
+profile, always mention that you do.
+:::
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/hardened.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/hardened.xml
deleted file mode 100644
index 4a51754cc7ae..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/hardened.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-hardened">
- <title>Hardened</title>
-
- <para>
-  A profile with most (vanilla) hardening options enabled by default,
-  potentially at the cost of stability, features and performance.
- </para>
-
- <para>
-  This includes a hardened kernel, and limiting the system information
-  available to processes through the <filename>/sys</filename> and
-  <filename>/proc</filename> filesystems. It also disables the User Namespaces
-  feature of the kernel, which stops Nix from being able to build anything
-  (this particular setting can be overriden via
-  <xref linkend="opt-security.allowUserNamespaces"/>). See the
-  <literal
-   xlink:href="https://github.com/nixos/nixpkgs/tree/master/nixos/modules/profiles/hardened.nix">
-  profile source</literal> for further detail on which settings are altered.
- </para>
- <warning>
-   <para>
-     This profile enables options that are known to affect system
-     stability. If you experience any stability issues when using the
-     profile, try disabling it. If you report an issue and use this
-     profile, always mention that you do.
-   </para>
- </warning>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/headless.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/headless.section.md
new file mode 100644
index 000000000000..d185a9a774b7
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/headless.section.md
@@ -0,0 +1,9 @@
+# Headless {#sec-profile-headless}
+
+Common configuration for headless machines (e.g., Amazon EC2 instances).
+
+Disables [sound](#opt-sound.enable),
+[vesa](#opt-boot.vesa), serial consoles,
+[emergency mode](#opt-systemd.enableEmergencyMode),
+[grub splash images](#opt-boot.loader.grub.splashImage)
+and configures the kernel to reboot automatically on panic.
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/headless.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/headless.xml
deleted file mode 100644
index 1b64497ebf7f..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/headless.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-headless">
- <title>Headless</title>
-
- <para>
-  Common configuration for headless machines (e.g., Amazon EC2 instances).
- </para>
-
- <para>
-  Disables <link linkend="opt-sound.enable">sound</link>,
-  <link linkend="opt-boot.vesa">vesa</link>, serial consoles,
-  <link linkend="opt-systemd.enableEmergencyMode">emergency mode</link>,
-  <link linkend="opt-boot.loader.grub.splashImage">grub splash images</link>
-  and configures the kernel to reboot automatically on panic.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.section.md
new file mode 100644
index 000000000000..ae9f8fa7757f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.section.md
@@ -0,0 +1,24 @@
+# Installation Device {#sec-profile-installation-device}
+
+Provides a basic configuration for installation devices like CDs.
+This enables redistributable firmware, includes the
+[Clone Config profile](#sec-profile-clone-config)
+and a copy of the Nixpkgs channel, so `nixos-install`
+works out of the box.
+
+Documentation for [Nixpkgs](#opt-documentation.enable)
+and [NixOS](#opt-documentation.nixos.enable) are
+forcefully enabled (to override the
+[Minimal profile](#sec-profile-minimal) preference); the
+NixOS manual is shown automatically on TTY 8, udisks is disabled.
+Autologin is enabled as `nixos` user, while passwordless
+login as both `root` and `nixos` is possible.
+Passwordless `sudo` is enabled too.
+[wpa_supplicant](#opt-networking.wireless.enable) is
+enabled, but configured to not autostart.
+
+It is explained how to login, start the ssh server, and if available,
+how to start the display manager.
+
+Several settings are tweaked so that the installer has a better chance of
+succeeding under low-memory environments.
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.xml
deleted file mode 100644
index 192ae955b689..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/installation-device.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-installation-device">
- <title>Installation Device</title>
-
- <para>
-  Provides a basic configuration for installation devices like CDs.
-  This enables redistributable firmware, includes the
-  <link linkend="sec-profile-clone-config">Clone Config profile</link>
-  and a copy of the Nixpkgs channel, so <command>nixos-install</command>
-  works out of the box.
- </para>
- <para>
-  Documentation for <link linkend="opt-documentation.enable">Nixpkgs</link>
-  and <link linkend="opt-documentation.nixos.enable">NixOS</link> are
-  forcefully enabled (to override the
-  <link linkend="sec-profile-minimal">Minimal profile</link> preference); the
-  NixOS manual is shown automatically on TTY 8, udisks is disabled.
-  Autologin is enabled as <literal>nixos</literal> user, while passwordless
-  login as both <literal>root</literal> and <literal>nixos</literal> is possible.
-  Passwordless <command>sudo</command> is enabled too.
-  <link linkend="opt-networking.wireless.enable">wpa_supplicant</link> is
-  enabled, but configured to not autostart.
- </para>
- <para>
-  It is explained how to login, start the ssh server, and if available,
-  how to start the display manager.
- </para>
-
- <para>
-  Several settings are tweaked so that the installer has a better chance of
-  succeeding under low-memory environments.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/minimal.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/minimal.section.md
new file mode 100644
index 000000000000..02a3b65ae422
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/minimal.section.md
@@ -0,0 +1,9 @@
+# Minimal {#sec-profile-minimal}
+
+This profile defines a small NixOS configuration. It does not contain any
+graphical stuff. It's a very short file that enables
+[noXlibs](#opt-environment.noXlibs), sets
+[](#opt-i18n.supportedLocales) to
+only support the user-selected locale,
+[disables packages' documentation](#opt-documentation.enable),
+and [disables sound](#opt-sound.enable).
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/minimal.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/minimal.xml
deleted file mode 100644
index 179f2d0be64b..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/minimal.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-minimal">
- <title>Minimal</title>
-
- <para>
-  This profile defines a small NixOS configuration. It does not contain any
-  graphical stuff. It's a very short file that enables
-  <link linkend="opt-environment.noXlibs">noXlibs</link>, sets
-  <link linkend="opt-i18n.supportedLocales">i18n.supportedLocales</link> to
-  only support the user-selected locale,
-  <link linkend="opt-documentation.enable">disables packages' documentation
-  </link>, and <link linkend="opt-sound.enable">disables sound</link>.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.section.md b/nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.section.md
new file mode 100644
index 000000000000..d7e3cae9cb0f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.section.md
@@ -0,0 +1,7 @@
+# QEMU Guest {#sec-profile-qemu-guest}
+
+This profile contains common configuration for virtual machines running under
+QEMU (using virtio).
+
+It makes virtio modules available on the initrd and sets the system time from
+the hardware clock to work around a bug in qemu-kvm.
diff --git a/nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.xml b/nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.xml
deleted file mode 100644
index 3ed97b94b510..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/profiles/qemu-guest.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-profile-qemu-guest">
- <title>QEMU Guest</title>
-
- <para>
-  This profile contains common configuration for virtual machines running under
-  QEMU (using virtio).
- </para>
-
- <para>
-  It makes virtio modules available on the initrd and sets the system time from
-  the hardware clock to work around a bug in qemu-kvm.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.section.md b/nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.section.md
new file mode 100644
index 000000000000..b124e8303fee
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.section.md
@@ -0,0 +1,51 @@
+# Renaming network interfaces {#sec-rename-ifs}
+
+NixOS uses the udev [predictable naming
+scheme](https://systemd.io/PREDICTABLE_INTERFACE_NAMES/) to assign names
+to network interfaces. This means that by default cards are not given
+the traditional names like `eth0` or `eth1`, whose order can change
+unpredictably across reboots. Instead, relying on physical locations and
+firmware information, the scheme produces names like `ens1`, `enp2s0`,
+etc.
+
+These names are predictable but less memorable and not necessarily
+stable: for example installing new hardware or changing firmware
+settings can result in a [name
+change](https://github.com/systemd/systemd/issues/3715#issue-165347602).
+If this is undesirable, for example if you have a single ethernet card,
+you can revert to the traditional scheme by setting
+[](#opt-networking.usePredictableInterfaceNames)
+to `false`.
+
+## Assigning custom names {#sec-custom-ifnames}
+
+In case there are multiple interfaces of the same type, it's better to
+assign custom names based on the device hardware address. For example,
+we assign the name `wan` to the interface with MAC address
+`52:54:00:12:01:01` using a netword link unit:
+
+```nix
+systemd.network.links."10-wan" = {
+  matchConfig.MACAddress = "52:54:00:12:01:01";
+  linkConfig.Name = "wan";
+};
+```
+
+Note that links are directly read by udev, *not networkd*, and will work
+even if networkd is disabled.
+
+Alternatively, we can use a plain old udev rule:
+
+```nix
+services.udev.initrdRules = ''
+  SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \
+  ATTR{address}=="52:54:00:12:01:01", KERNEL=="eth*", NAME="wan"
+'';
+```
+
+::: {.warning}
+The rule must be installed in the initrd using
+`services.udev.initrdRules`, not the usual `services.udev.extraRules`
+option. This is to avoid race conditions with other programs controlling
+the interface.
+:::
diff --git a/nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.xml b/nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.xml
deleted file mode 100644
index d760bb3a4dac..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/renaming-interfaces.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-rename-ifs">
- <title>Renaming network interfaces</title>
-
- <para>
-  NixOS uses the udev
-  <link xlink:href="https://systemd.io/PREDICTABLE_INTERFACE_NAMES/">predictable naming scheme</link>
-  to assign names to network interfaces. This means that by default
-  cards are not given the traditional names like
-  <literal>eth0</literal> or <literal>eth1</literal>, whose order can
-  change unpredictably across reboots. Instead, relying on physical
-  locations and firmware information, the scheme produces names like
-  <literal>ens1</literal>, <literal>enp2s0</literal>, etc.
- </para>
-
- <para>
-  These names are predictable but less memorable and not necessarily
-  stable: for example installing new hardware or changing firmware
-  settings can result in a
-  <link xlink:href="https://github.com/systemd/systemd/issues/3715#issue-165347602">name change</link>.
-  If this is undesirable, for example if you have a single ethernet
-  card, you can revert to the traditional scheme by setting
-  <xref linkend="opt-networking.usePredictableInterfaceNames"/> to
-  <literal>false</literal>.
- </para>
-
- <section xml:id="sec-custom-ifnames">
-  <title>Assigning custom names</title>
-  <para>
-   In case there are multiple interfaces of the same type, it’s better to
-   assign custom names based on the device hardware address. For
-   example, we assign the name <literal>wan</literal> to the interface
-   with MAC address <literal>52:54:00:12:01:01</literal> using a
-   netword link unit:
-  </para>
-  <programlisting>
- <link linkend="opt-systemd.network.links">systemd.network.links."10-wan"</link> = {
-   matchConfig.MACAddress = "52:54:00:12:01:01";
-   linkConfig.Name = "wan";
- };
-  </programlisting>
-  <para>
-   Note that links are directly read by udev, <emphasis>not networkd</emphasis>,
-   and will work even if networkd is disabled.
-  </para>
-  <para>
-   Alternatively, we can use a plain old udev rule:
-  </para>
-  <programlisting>
- <link linkend="opt-services.udev.initrdRules">services.udev.initrdRules</link> = ''
-  SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \
-  ATTR{address}=="52:54:00:12:01:01", KERNEL=="eth*", NAME="wan"
- '';
-  </programlisting>
-
-  <warning><para>
-   The rule must be installed in the initrd using
-   <literal>services.udev.initrdRules</literal>, not the usual
-   <literal>services.udev.extraRules</literal> option. This is to avoid race
-   conditions with other programs controlling the interface.
-  </para></warning>
- </section>
-
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/ssh.section.md b/nixpkgs/nixos/doc/manual/configuration/ssh.section.md
new file mode 100644
index 000000000000..cba81eb43f49
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/ssh.section.md
@@ -0,0 +1,19 @@
+# Secure Shell Access {#sec-ssh}
+
+Secure shell (SSH) access to your machine can be enabled by setting:
+
+```nix
+services.openssh.enable = true;
+```
+
+By default, root logins using a password are disallowed. They can be
+disabled entirely by setting
+[](#opt-services.openssh.permitRootLogin) to `"no"`.
+
+You can declaratively specify authorised RSA/DSA public keys for a user
+as follows:
+
+```nix
+users.users.alice.openssh.authorizedKeys.keys =
+  [ "ssh-dss AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/ssh.xml b/nixpkgs/nixos/doc/manual/configuration/ssh.xml
deleted file mode 100644
index 95ad3edff935..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/ssh.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-ssh">
- <title>Secure Shell Access</title>
-
- <para>
-  Secure shell (SSH) access to your machine can be enabled by setting:
-<programlisting>
-<xref linkend="opt-services.openssh.enable"/> = true;
-</programlisting>
-  By default, root logins using a password are disallowed. They can be disabled
-  entirely by setting <xref linkend="opt-services.openssh.permitRootLogin"/> to
-  <literal>"no"</literal>.
- </para>
-
- <para>
-  You can declaratively specify authorised RSA/DSA public keys for a user as
-  follows:
-<!-- FIXME: this might not work if the user is unmanaged. -->
-<programlisting>
-<link linkend="opt-users.users._name_.openssh.authorizedKeys.keys">users.users.alice.openssh.authorizedKeys.keys</link> =
-  [ "ssh-dss AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];
-</programlisting>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/sshfs-file-systems.section.md b/nixpkgs/nixos/doc/manual/configuration/sshfs-file-systems.section.md
index 4625fce03d58..4dd1b203a249 100644
--- a/nixpkgs/nixos/doc/manual/configuration/sshfs-file-systems.section.md
+++ b/nixpkgs/nixos/doc/manual/configuration/sshfs-file-systems.section.md
@@ -34,7 +34,7 @@ SHA256:yjxl3UbTn31fLWeyLYTAKYJPRmzknjQZoyG8gSNEoIE my-user@workstation
 To keep the key safe, change the ownership to `root:root` and make sure the permissions are `600`:
 OpenSSH normally refuses to use the key if it's not well-protected.
 
-The file system can be configured in NixOS via the usual [fileSystems](options.html#opt-fileSystems) option.
+The file system can be configured in NixOS via the usual [fileSystems](#opt-fileSystems) option.
 Here's a typical setup:
 ```nix
 {
diff --git a/nixpkgs/nixos/doc/manual/configuration/subversion.chapter.md b/nixpkgs/nixos/doc/manual/configuration/subversion.chapter.md
new file mode 100644
index 000000000000..84f9c2703378
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/subversion.chapter.md
@@ -0,0 +1,102 @@
+# Subversion {#module-services-subversion}
+
+[Subversion](https://subversion.apache.org/) is a centralized
+version-control system. It can use a [variety of
+protocols](http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.choosing)
+for communication between client and server.
+
+## Subversion inside Apache HTTP {#module-services-subversion-apache-httpd}
+
+This section focuses on configuring a web-based server on top of the
+Apache HTTP server, which uses
+[WebDAV](http://www.webdav.org/)/[DeltaV](http://www.webdav.org/deltav/WWW10/deltav-intro.htm)
+for communication.
+
+For more information on the general setup, please refer to the [the
+appropriate section of the Subversion
+book](http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.httpd).
+
+To configure, include in `/etc/nixos/configuration.nix` code to activate
+Apache HTTP, setting [](#opt-services.httpd.adminAddr)
+appropriately:
+
+```nix
+services.httpd.enable = true;
+services.httpd.adminAddr = ...;
+networking.firewall.allowedTCPPorts = [ 80 443 ];
+```
+
+For a simple Subversion server with basic authentication, configure the
+Subversion module for Apache as follows, setting `hostName` and
+`documentRoot` appropriately, and `SVNParentPath` to the parent
+directory of the repositories, `AuthzSVNAccessFile` to the location of
+the `.authz` file describing access permission, and `AuthUserFile` to
+the password file.
+
+```nix
+services.httpd.extraModules = [
+    # note that order is *super* important here
+    { name = "dav_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so"; }
+    { name = "authz_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so"; }
+  ];
+  services.httpd.virtualHosts = {
+    "svn" = {
+       hostName = HOSTNAME;
+       documentRoot = DOCUMENTROOT;
+       locations."/svn".extraConfig = ''
+           DAV svn
+           SVNParentPath REPO_PARENT
+           AuthzSVNAccessFile ACCESS_FILE
+           AuthName "SVN Repositories"
+           AuthType Basic
+           AuthUserFile PASSWORD_FILE
+           Require valid-user
+      '';
+    }
+```
+
+The key `"svn"` is just a symbolic name identifying the virtual host.
+The `"/svn"` in `locations."/svn".extraConfig` is the path underneath
+which the repositories will be served.
+
+[This page](https://wiki.archlinux.org/index.php/Subversion) explains
+how to set up the Subversion configuration itself. This boils down to
+the following:
+
+Underneath `REPO_PARENT` repositories can be set up as follows:
+
+```ShellSession
+$ svn create REPO_NAME
+```
+
+Repository files need to be accessible by `wwwrun`:
+
+```ShellSession
+$ chown -R wwwrun:wwwrun REPO_PARENT
+```
+
+The password file `PASSWORD_FILE` can be created as follows:
+
+```ShellSession
+$ htpasswd -cs PASSWORD_FILE USER_NAME
+```
+
+Additional users can be set up similarly, omitting the `c` flag:
+
+```ShellSession
+$ htpasswd -s PASSWORD_FILE USER_NAME
+```
+
+The file describing access permissions `ACCESS_FILE` will look something
+like the following:
+
+```nix
+[/]
+* = r
+
+[REPO_NAME:/]
+USER_NAME = rw
+```
+
+The Subversion repositories will be accessible as
+`http://HOSTNAME/svn/REPO_NAME`.
diff --git a/nixpkgs/nixos/doc/manual/configuration/subversion.xml b/nixpkgs/nixos/doc/manual/configuration/subversion.xml
deleted file mode 100644
index 940d63cc4e6d..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/subversion.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="module-services-subversion">
-  <title>Subversion</title>
-
- <para>
-  <link xlink:href="https://subversion.apache.org/">Subversion</link>
-  is a centralized version-control system.  It can use a <link
-  xlink:href="http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.choosing">variety
-  of protocols</link> for communication between client and server.
- </para>
- <section xml:id="module-services-subversion-apache-httpd">
-  <title>Subversion inside Apache HTTP</title>
-
-   <para>
-   This section focuses on configuring a web-based server on top of
-   the Apache HTTP server, which uses
-   <link xlink:href="http://www.webdav.org/">WebDAV</link>/<link
-   xlink:href="http://www.webdav.org/deltav/WWW10/deltav-intro.htm">DeltaV</link>
-   for communication.
-   </para>
-
-   <para>For more information on the general setup, please refer to
-   the <link
-   xlink:href="http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.httpd">the
-   appropriate section of the Subversion book</link>.
-   </para>
-
-   <para>To configure, include in
-   <literal>/etc/nixos/configuration.nix</literal> code to activate
-   Apache HTTP, setting <xref linkend="opt-services.httpd.adminAddr" />
-   appropriately:
-   </para>
-
-    <para>
-<programlisting>
-  services.httpd.enable = true;
-  services.httpd.adminAddr = ...;
-  networking.firewall.allowedTCPPorts = [ 80 443 ];
-</programlisting>
-    </para>
-
-    <para>For a simple Subversion server with basic authentication,
-    configure the Subversion module for Apache as follows, setting
-    <literal>hostName</literal> and <literal>documentRoot</literal>
-    appropriately, and <literal>SVNParentPath</literal> to the parent
-    directory of the repositories,
-    <literal>AuthzSVNAccessFile</literal> to the location of the
-    <code>.authz</code> file describing access permission, and
-    <literal>AuthUserFile</literal> to the password file.
-    </para>
-    <para>
-<programlisting>
-services.httpd.extraModules = [
-    # note that order is *super* important here
-    { name = "dav_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so"; }
-    { name = "authz_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so"; }
-  ];
-  services.httpd.virtualHosts = {
-    "svn" = {
-       hostName = HOSTNAME;
-       documentRoot = DOCUMENTROOT;
-       locations."/svn".extraConfig = ''
-           DAV svn
-           SVNParentPath REPO_PARENT
-           AuthzSVNAccessFile ACCESS_FILE
-           AuthName "SVN Repositories"
-           AuthType Basic
-           AuthUserFile PASSWORD_FILE
-           Require valid-user
-      '';
-    }
-</programlisting>
-    </para>
-
-    <para>
-    The key <code>"svn"</code> is just a symbolic name identifying the
-    virtual host.  The <code>"/svn"</code> in
-    <code>locations."/svn".extraConfig</code> is the path underneath
-    which the repositories will be served.
-    </para>
-
-    <para><link
-              xlink:href="https://wiki.archlinux.org/index.php/Subversion">This
-    page</link> explains how to set up the Subversion configuration
-    itself.  This boils down to the following:
-    </para>
-    <para>
-      Underneath <literal>REPO_PARENT</literal> repositories can be set up
-      as follows:
-    </para>
-    <para>
-<screen>
-<prompt>$ </prompt> svn create REPO_NAME
-</screen>
-    </para>
-    <para>Repository files need to be accessible by
-    <literal>wwwrun</literal>:
-    </para>
-    <para>
-<screen>
-<prompt>$ </prompt> chown -R wwwrun:wwwrun REPO_PARENT
-</screen>
-    </para>
-    <para>
-      The password file <literal>PASSWORD_FILE</literal> can be created as follows:
-    </para>
-    <para>
-<screen>
-<prompt>$ </prompt> htpasswd -cs PASSWORD_FILE USER_NAME
-</screen>
-    </para>
-    <para>
-    Additional users can be set up similarly, omitting the
-    <code>c</code> flag:
-    </para>
-    <para>
-<screen>
-<prompt>$ </prompt> htpasswd -s PASSWORD_FILE USER_NAME
-</screen>
-    </para>
-    <para>
-      The file describing access permissions
-      <literal>ACCESS_FILE</literal> will look something like
-      the following:
-    </para>
-    <para>
-<programlisting>
-[/]
-* = r
-
-[REPO_NAME:/]
-USER_NAME = rw
-</programlisting>
-    </para>
-    <para>The Subversion repositories will be accessible as <code>http://HOSTNAME/svn/REPO_NAME</code>.</para>
- </section>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/summary.section.md b/nixpkgs/nixos/doc/manual/configuration/summary.section.md
new file mode 100644
index 000000000000..8abbbe257fd9
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/summary.section.md
@@ -0,0 +1,46 @@
+# Syntax Summary {#sec-nix-syntax-summary}
+
+Below is a summary of the most important syntactic constructs in the Nix
+expression language. It's not complete. In particular, there are many
+other built-in functions. See the [Nix
+manual](https://nixos.org/nix/manual/#chap-writing-nix-expressions) for
+the rest.
+
+| Example                                       | Description                                                                                                        |
+|-----------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
+| *Basic values*                                |                                                                                                                    |
+| `"Hello world"`                               | A string                                                                                                           |
+| `"${pkgs.bash}/bin/sh"`                       | A string containing an expression (expands to `"/nix/store/hash-bash-version/bin/sh"`)                             |
+| `true`, `false`                               | Booleans                                                                                                           |
+| `123`                                         | An integer                                                                                                         |
+| `./foo.png`                                   | A path (relative to the containing Nix expression)                                                                 |
+| *Compound values*                             |                                                                                                                    |
+| `{ x = 1; y = 2; }`                           | A set with attributes named `x` and `y`                                                                            |
+| `{ foo.bar = 1; }`                            | A nested set, equivalent to `{ foo = { bar = 1; }; }`                                                              |
+| `rec { x = "foo"; y = x + "bar"; }`           | A recursive set, equivalent to `{ x = "foo"; y = "foobar"; }`                                                      |
+| `[ "foo" "bar" ]`                             | A list with two elements                                                                                           |
+| *Operators*                                   |                                                                                                                    |
+| `"foo" + "bar"`                               | String concatenation                                                                                               |
+| `1 + 2`                                       | Integer addition                                                                                                   |
+| `"foo" == "f" + "oo"`                         | Equality test (evaluates to `true`)                                                                                |
+| `"foo" != "bar"`                              | Inequality test (evaluates to `true`)                                                                              |
+| `!true`                                       | Boolean negation                                                                                                   |
+| `{ x = 1; y = 2; }.x`                         | Attribute selection (evaluates to `1`)                                                                             |
+| `{ x = 1; y = 2; }.z or 3`                    | Attribute selection with default (evaluates to `3`)                                                                |
+| `{ x = 1; y = 2; } // { z = 3; }`             | Merge two sets (attributes in the right-hand set taking precedence)                                                |
+| *Control structures*                          |                                                                                                                    |
+| `if 1 + 1 == 2 then "yes!" else "no!"`        | Conditional expression                                                                                             |
+| `assert 1 + 1 == 2; "yes!"`                   | Assertion check (evaluates to `"yes!"`). See [](#sec-assertions) for using assertions in modules                   |
+| `let x = "foo"; y = "bar"; in x + y`          | Variable definition                                                                                                |
+| `with pkgs.lib; head [ 1 2 3 ]`               | Add all attributes from the given set to the scope (evaluates to `1`)                                              |
+| *Functions (lambdas)*                         |                                                                                                                    |
+| `x: x + 1`                                    | A function that expects an integer and returns it increased by 1                                                   |
+| `(x: x + 1) 100`                              | A function call (evaluates to 101)                                                                                 |
+| `let inc = x: x + 1; in inc (inc (inc 100))`  | A function bound to a variable and subsequently called by name (evaluates to 103)                                  |
+| `{ x, y }: x + y`                             | A function that expects a set with required attributes `x` and `y` and concatenates them                           |
+| `{ x, y ? "bar" }: x + y`                     | A function that expects a set with required attribute `x` and optional `y`, using `"bar"` as default value for `y` |
+| `{ x, y, ... }: x + y`                        | A function that expects a set with required attributes `x` and `y` and ignores any other attributes                |
+| `{ x, y } @ args: x + y`                      | A function that expects a set with required attributes `x` and `y`, and binds the whole set to `args`              |
+| *Built-in functions*                          |                                                                                                                    |
+| `import ./foo.nix`                            | Load and return Nix expression in given file                                                                       |
+| `map (x: x + x) [ 1 2 3 ]`                    | Apply a function to every element of a list (evaluates to `[ 2 4 6 ]`)                                             |
diff --git a/nixpkgs/nixos/doc/manual/configuration/summary.xml b/nixpkgs/nixos/doc/manual/configuration/summary.xml
deleted file mode 100644
index 289face16de9..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/summary.xml
+++ /dev/null
@@ -1,227 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-    xmlns:xlink="http://www.w3.org/1999/xlink"
-    xmlns:xi="http://www.w3.org/2001/XInclude"
-    version="5.0"
-    xml:id="sec-nix-syntax-summary">
- <title>Syntax Summary</title>
-
- <para>
-  Below is a summary of the most important syntactic constructs in the Nix
-  expression language. It’s not complete. In particular, there are many other
-  built-in functions. See the
-  <link
-xlink:href="https://nixos.org/nix/manual/#chap-writing-nix-expressions">Nix
-  manual</link> for the rest.
- </para>
-
- <informaltable frame='none'>
-  <tgroup cols='2'>
-   <colspec colname='c1' rowsep='1' colsep='1' />
-   <colspec colname='c2' rowsep='1' />
-   <thead>
-    <row>
-     <entry>Example</entry>
-     <entry>Description</entry>
-    </row>
-   </thead>
-   <tbody>
-    <row>
-     <entry namest="c1" nameend="c2"><emphasis>Basic values</emphasis>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>"Hello world"</literal>
-     </entry>
-     <entry>A string</entry>
-    </row>
-    <row>
-     <entry><literal>"${pkgs.bash}/bin/sh"</literal>
-     </entry>
-     <entry>A string containing an expression (expands to <literal>"/nix/store/<replaceable>hash</replaceable>-bash-<replaceable>version</replaceable>/bin/sh"</literal>)</entry>
-    </row>
-    <row>
-     <entry><literal>true</literal>, <literal>false</literal>
-     </entry>
-     <entry>Booleans</entry>
-    </row>
-    <row>
-     <entry><literal>123</literal>
-     </entry>
-     <entry>An integer</entry>
-    </row>
-    <row>
-     <entry><literal>./foo.png</literal>
-     </entry>
-     <entry>A path (relative to the containing Nix expression)</entry>
-    </row>
-    <row>
-     <entry namest="c1" nameend="c2"><emphasis>Compound values</emphasis>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>{ x = 1; y = 2; }</literal>
-     </entry>
-     <entry>A set with attributes named <literal>x</literal> and <literal>y</literal>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>{ foo.bar = 1; }</literal>
-     </entry>
-     <entry>A nested set, equivalent to <literal>{ foo = { bar = 1; }; }</literal>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>rec { x = "foo"; y = x + "bar"; }</literal>
-     </entry>
-     <entry>A recursive set, equivalent to <literal>{ x = "foo"; y = "foobar"; }</literal>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>[ "foo" "bar" ]</literal>
-     </entry>
-     <entry>A list with two elements</entry>
-    </row>
-    <row>
-     <entry namest="c1" nameend="c2"><emphasis>Operators</emphasis>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>"foo" + "bar"</literal>
-     </entry>
-     <entry>String concatenation</entry>
-    </row>
-    <row>
-     <entry><literal>1 + 2</literal>
-     </entry>
-     <entry>Integer addition</entry>
-    </row>
-    <row>
-     <entry><literal>"foo" == "f" + "oo"</literal>
-     </entry>
-     <entry>Equality test (evaluates to <literal>true</literal>)</entry>
-    </row>
-    <row>
-     <entry><literal>"foo" != "bar"</literal>
-     </entry>
-     <entry>Inequality test (evaluates to <literal>true</literal>)</entry>
-    </row>
-    <row>
-     <entry><literal>!true</literal>
-     </entry>
-     <entry>Boolean negation</entry>
-    </row>
-    <row>
-     <entry><literal>{ x = 1; y = 2; }.x</literal>
-     </entry>
-     <entry>Attribute selection (evaluates to <literal>1</literal>)</entry>
-    </row>
-    <row>
-     <entry><literal>{ x = 1; y = 2; }.z or 3</literal>
-     </entry>
-     <entry>Attribute selection with default (evaluates to <literal>3</literal>)</entry>
-    </row>
-    <row>
-     <entry><literal>{ x = 1; y = 2; } // { z = 3; }</literal>
-     </entry>
-     <entry>Merge two sets (attributes in the right-hand set taking precedence)</entry>
-    </row>
-    <row>
-     <entry namest="c1" nameend="c2"><emphasis>Control structures</emphasis>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>if 1 + 1 == 2 then "yes!" else "no!"</literal>
-     </entry>
-     <entry>Conditional expression</entry>
-    </row>
-    <row>
-     <entry><literal>assert 1 + 1 == 2; "yes!"</literal>
-     </entry>
-     <entry>Assertion check (evaluates to <literal>"yes!"</literal>). See <xref
-    linkend="sec-assertions"/> for using assertions in modules</entry>
-    </row>
-    <row>
-     <entry><literal>let x = "foo"; y = "bar"; in x + y</literal>
-     </entry>
-     <entry>Variable definition</entry>
-    </row>
-    <row>
-     <entry><literal>with pkgs.lib; head [ 1 2 3 ]</literal>
-     </entry>
-     <entry>Add all attributes from the given set to the scope
-        (evaluates to <literal>1</literal>)</entry>
-    </row>
-    <row>
-     <entry namest="c1" nameend="c2"><emphasis>Functions (lambdas)</emphasis>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>x: x + 1</literal>
-     </entry>
-     <entry>A function that expects an integer and returns it increased by 1</entry>
-    </row>
-    <row>
-     <entry><literal>(x: x + 1) 100</literal>
-     </entry>
-     <entry>A function call (evaluates to 101)</entry>
-    </row>
-    <row>
-     <entry><literal>let inc = x: x + 1; in inc (inc (inc 100))</literal>
-     </entry>
-     <entry>A function bound to a variable and subsequently called by name (evaluates to 103)</entry>
-    </row>
-    <row>
-     <entry><literal>{ x, y }: x + y</literal>
-     </entry>
-     <entry>A function that expects a set with required attributes
-        <literal>x</literal> and <literal>y</literal> and concatenates
-        them</entry>
-    </row>
-    <row>
-     <entry><literal>{ x, y ? "bar" }: x + y</literal>
-     </entry>
-     <entry>A function that expects a set with required attribute
-        <literal>x</literal> and optional <literal>y</literal>, using
-        <literal>"bar"</literal> as default value for
-        <literal>y</literal>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>{ x, y, ... }: x + y</literal>
-     </entry>
-     <entry>A function that expects a set with required attributes
-        <literal>x</literal> and <literal>y</literal> and ignores any
-        other attributes</entry>
-    </row>
-    <row>
-     <entry><literal>{ x, y } @ args: x + y</literal>
-     </entry>
-     <entry>A function that expects a set with required attributes
-        <literal>x</literal> and <literal>y</literal>, and binds the
-        whole set to <literal>args</literal>
-     </entry>
-    </row>
-    <row>
-     <entry namest="c1" nameend="c2"><emphasis>Built-in functions</emphasis>
-     </entry>
-    </row>
-    <row>
-     <entry><literal>import ./foo.nix</literal>
-     </entry>
-     <entry>Load and return Nix expression in given file</entry>
-    </row>
-    <row>
-     <entry><literal>map (x: x + x) [ 1 2 3 ]</literal>
-     </entry>
-     <entry>Apply a function to every element of a list (evaluates to <literal>[ 2 4 6 ]</literal>)</entry>
-    </row>
-<!--
-      <row>
-        <entry><literal>throw "Urgh"</literal></entry>
-        <entry>Raise an error condition</entry>
-      </row>
-      -->
-   </tbody>
-  </tgroup>
- </informaltable>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/user-mgmt.chapter.md b/nixpkgs/nixos/doc/manual/configuration/user-mgmt.chapter.md
new file mode 100644
index 000000000000..37990664a8f1
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/user-mgmt.chapter.md
@@ -0,0 +1,92 @@
+# User Management {#sec-user-management}
+
+NixOS supports both declarative and imperative styles of user
+management. In the declarative style, users are specified in
+`configuration.nix`. For instance, the following states that a user
+account named `alice` shall exist:
+
+```nix
+users.users.alice = {
+  isNormalUser = true;
+  home = "/home/alice";
+  description = "Alice Foobar";
+  extraGroups = [ "wheel" "networkmanager" ];
+  openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
+};
+```
+
+Note that `alice` is a member of the `wheel` and `networkmanager`
+groups, which allows her to use `sudo` to execute commands as `root` and
+to configure the network, respectively. Also note the SSH public key
+that allows remote logins with the corresponding private key. Users
+created in this way do not have a password by default, so they cannot
+log in via mechanisms that require a password. However, you can use the
+`passwd` program to set a password, which is retained across invocations
+of `nixos-rebuild`.
+
+If you set [](#opt-users.mutableUsers) to
+false, then the contents of `/etc/passwd` and `/etc/group` will be congruent
+to your NixOS configuration. For instance, if you remove a user from
+[](#opt-users.users) and run nixos-rebuild, the user
+account will cease to exist. Also, imperative commands for managing users and
+groups, such as useradd, are no longer available. Passwords may still be
+assigned by setting the user\'s
+[hashedPassword](#opt-users.users._name_.hashedPassword) option. A
+hashed password can be generated using `mkpasswd -m
+  sha-512`.
+
+A user ID (uid) is assigned automatically. You can also specify a uid
+manually by adding
+
+```nix
+uid = 1000;
+```
+
+to the user specification.
+
+Groups can be specified similarly. The following states that a group
+named `students` shall exist:
+
+```nix
+users.groups.students.gid = 1000;
+```
+
+As with users, the group ID (gid) is optional and will be assigned
+automatically if it's missing.
+
+In the imperative style, users and groups are managed by commands such
+as `useradd`, `groupmod` and so on. For instance, to create a user
+account named `alice`:
+
+```ShellSession
+# useradd -m alice
+```
+
+To make all nix tools available to this new user use \`su - USER\` which
+opens a login shell (==shell that loads the profile) for given user.
+This will create the \~/.nix-defexpr symlink. So run:
+
+```ShellSession
+# su - alice -c "true"
+```
+
+The flag `-m` causes the creation of a home directory for the new user,
+which is generally what you want. The user does not have an initial
+password and therefore cannot log in. A password can be set using the
+`passwd` utility:
+
+```ShellSession
+# passwd alice
+Enter new UNIX password: ***
+Retype new UNIX password: ***
+```
+
+A user can be deleted using `userdel`:
+
+```ShellSession
+# userdel -r alice
+```
+
+The flag `-r` deletes the user's home directory. Accounts can be
+modified using `usermod`. Unix groups can be managed using `groupadd`,
+`groupmod` and `groupdel`.
diff --git a/nixpkgs/nixos/doc/manual/configuration/user-mgmt.xml b/nixpkgs/nixos/doc/manual/configuration/user-mgmt.xml
deleted file mode 100644
index e83e7b75ef54..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/user-mgmt.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-user-management">
- <title>User Management</title>
- <para>
-  NixOS supports both declarative and imperative styles of user management. In
-  the declarative style, users are specified in
-  <filename>configuration.nix</filename>. For instance, the following states
-  that a user account named <literal>alice</literal> shall exist:
-<programlisting>
-<xref linkend="opt-users.users"/>.alice = {
-  <link linkend="opt-users.users._name_.isNormalUser">isNormalUser</link> = true;
-  <link linkend="opt-users.users._name_.home">home</link> = "/home/alice";
-  <link linkend="opt-users.users._name_.description">description</link> = "Alice Foobar";
-  <link linkend="opt-users.users._name_.extraGroups">extraGroups</link> = [ "wheel" "networkmanager" ];
-  <link linkend="opt-users.users._name_.openssh.authorizedKeys.keys">openssh.authorizedKeys.keys</link> = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
-};
-</programlisting>
-  Note that <literal>alice</literal> is a member of the
-  <literal>wheel</literal> and <literal>networkmanager</literal> groups, which
-  allows her to use <command>sudo</command> to execute commands as
-  <literal>root</literal> and to configure the network, respectively. Also note
-  the SSH public key that allows remote logins with the corresponding private
-  key. Users created in this way do not have a password by default, so they
-  cannot log in via mechanisms that require a password. However, you can use
-  the <command>passwd</command> program to set a password, which is retained
-  across invocations of <command>nixos-rebuild</command>.
- </para>
- <para>
-  If you set <xref linkend="opt-users.mutableUsers"/> to false, then the
-  contents of <literal>/etc/passwd</literal> and <literal>/etc/group</literal>
-  will be congruent to your NixOS configuration. For instance, if you remove a
-  user from <xref linkend="opt-users.users"/> and run nixos-rebuild, the user
-  account will cease to exist. Also, imperative commands for managing users and
-  groups, such as useradd, are no longer available. Passwords may still be
-  assigned by setting the user's
-  <link linkend="opt-users.users._name_.hashedPassword">hashedPassword</link>
-  option. A hashed password can be generated using <command>mkpasswd -m
-  sha-512</command>.
- </para>
- <para>
-  A user ID (uid) is assigned automatically. You can also specify a uid
-  manually by adding
-<programlisting>
-uid = 1000;
-</programlisting>
-  to the user specification.
- </para>
- <para>
-  Groups can be specified similarly. The following states that a group named
-  <literal>students</literal> shall exist:
-<programlisting>
-<xref linkend="opt-users.groups"/>.students.gid = 1000;
-</programlisting>
-  As with users, the group ID (gid) is optional and will be assigned
-  automatically if it’s missing.
- </para>
- <para>
-  In the imperative style, users and groups are managed by commands such as
-  <command>useradd</command>, <command>groupmod</command> and so on. For
-  instance, to create a user account named <literal>alice</literal>:
-<screen>
-<prompt># </prompt>useradd -m <replaceable>alice</replaceable></screen>
-  To make all nix tools available to this new user use `su - USER` which opens
-  a login shell (==shell that loads the profile) for given user. This will
-  create the ~/.nix-defexpr symlink. So run:
-<screen>
-<prompt># </prompt>su - <replaceable>alice</replaceable> -c "true"</screen>
-  The flag <option>-m</option> causes the creation of a home directory for the
-  new user, which is generally what you want. The user does not have an initial
-  password and therefore cannot log in. A password can be set using the
-  <command>passwd</command> utility:
-<screen>
-<prompt># </prompt>passwd <replaceable>alice</replaceable>
-Enter new UNIX password: ***
-Retype new UNIX password: ***
-</screen>
-  A user can be deleted using <command>userdel</command>:
-<screen>
-<prompt># </prompt>userdel -r <replaceable>alice</replaceable></screen>
-  The flag <option>-r</option> deletes the user’s home directory. Accounts
-  can be modified using <command>usermod</command>. Unix groups can be managed
-  using <command>groupadd</command>, <command>groupmod</command> and
-  <command>groupdel</command>.
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/wayland.chapter.md b/nixpkgs/nixos/doc/manual/configuration/wayland.chapter.md
new file mode 100644
index 000000000000..a3a46aa3da6f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/wayland.chapter.md
@@ -0,0 +1,27 @@
+# Wayland {#sec-wayland}
+
+While X11 (see [](#sec-x11)) is still the primary display technology
+on NixOS, Wayland support is steadily improving. Where X11 separates the
+X Server and the window manager, on Wayland those are combined: a
+Wayland Compositor is like an X11 window manager, but also embeds the
+Wayland \'Server\' functionality. This means it is sufficient to install
+a Wayland Compositor such as sway without separately enabling a Wayland
+server:
+
+```nix
+programs.sway.enable = true;
+```
+
+This installs the sway compositor along with some essential utilities.
+Now you can start sway from the TTY console.
+
+If you are using a wlroots-based compositor, like sway, and want to be
+able to share your screen, you might want to activate this option:
+
+```nix
+xdg.portal.wlr.enable = true;
+```
+
+and configure Pipewire using
+[](#opt-services.pipewire.enable)
+and related options.
diff --git a/nixpkgs/nixos/doc/manual/configuration/wayland.xml b/nixpkgs/nixos/doc/manual/configuration/wayland.xml
deleted file mode 100644
index 2aefda3e22c0..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/wayland.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-wayland">
- <title>Wayland</title>
-
- <para>
-  While X11 (see <xref linkend="sec-x11"/>) is still the primary display
-  technology on NixOS, Wayland support is steadily improving.
-  Where X11 separates the X Server and the window manager, on Wayland those
-  are combined: a Wayland Compositor is like an X11 window manager, but also
-  embeds the Wayland 'Server' functionality. This means it is sufficient to
-  install a Wayland Compositor such as <package>sway</package> without
-  separately enabling a Wayland server:
-<programlisting>
-<xref linkend="opt-programs.sway.enable"/> = true;
-</programlisting>
-  This installs the <package>sway</package> compositor along with some
-  essential utilities. Now you can start <package>sway</package> from the TTY
-  console.
- </para>
-
- <para>
-  If you are using a wlroots-based compositor, like sway, and want to be able to
-  share your screen, you might want to activate this option:
-<programlisting>
-<xref linkend="opt-xdg.portal.wlr.enable"/> = true;
-</programlisting>
-  and configure Pipewire using <xref linkend="opt-services.pipewire.enable"/>
-  and related options.
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/wireless.section.md b/nixpkgs/nixos/doc/manual/configuration/wireless.section.md
new file mode 100644
index 000000000000..6b223d843ac5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/wireless.section.md
@@ -0,0 +1,67 @@
+# Wireless Networks {#sec-wireless}
+
+For a desktop installation using NetworkManager (e.g., GNOME), you just
+have to make sure the user is in the `networkmanager` group and you can
+skip the rest of this section on wireless networks.
+
+NixOS will start wpa_supplicant for you if you enable this setting:
+
+```nix
+networking.wireless.enable = true;
+```
+
+NixOS lets you specify networks for wpa_supplicant declaratively:
+
+```nix
+networking.wireless.networks = {
+  echelon = {                # SSID with no spaces or special characters
+    psk = "abcdefgh";
+  };
+  "echelon's AP" = {         # SSID with spaces and/or special characters
+    psk = "ijklmnop";
+  };
+  echelon = {                # Hidden SSID
+    hidden = true;
+    psk = "qrstuvwx";
+  };
+  free.wifi = {};            # Public wireless network
+};
+```
+
+Be aware that keys will be written to the nix store in plaintext! When
+no networks are set, it will default to using a configuration file at
+`/etc/wpa_supplicant.conf`. You should edit this file yourself to define
+wireless networks, WPA keys and so on (see wpa_supplicant.conf(5)).
+
+If you are using WPA2 you can generate pskRaw key using
+`wpa_passphrase`:
+
+```ShellSession
+$ wpa_passphrase ESSID PSK
+network={
+        ssid="echelon"
+        #psk="abcdefgh"
+        psk=dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435
+}
+```
+
+```nix
+networking.wireless.networks = {
+  echelon = {
+    pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435";
+  };
+}
+```
+
+or you can use it to directly generate the `wpa_supplicant.conf`:
+
+```ShellSession
+# wpa_passphrase ESSID PSK > /etc/wpa_supplicant.conf
+```
+
+After you have edited the `wpa_supplicant.conf`, you need to restart the
+wpa_supplicant service.
+
+```ShellSession
+# systemctl restart wpa_supplicant.service
+```
diff --git a/nixpkgs/nixos/doc/manual/configuration/wireless.xml b/nixpkgs/nixos/doc/manual/configuration/wireless.xml
deleted file mode 100644
index 247d29d58314..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/wireless.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-wireless">
- <title>Wireless Networks</title>
-
- <para>
-  For a desktop installation using NetworkManager (e.g., GNOME), you just have
-  to make sure the user is in the <code>networkmanager</code> group and you can
-  skip the rest of this section on wireless networks.
- </para>
-
- <para>
-  NixOS will start wpa_supplicant for you if you enable this setting:
-<programlisting>
-<xref linkend="opt-networking.wireless.enable"/> = true;
-</programlisting>
-  NixOS lets you specify networks for wpa_supplicant declaratively:
-<programlisting>
-<xref linkend="opt-networking.wireless.networks"/> = {
-  echelon = {                # SSID with no spaces or special characters
-    psk = "abcdefgh";
-  };
-  "echelon's AP" = {         # SSID with spaces and/or special characters
-    psk = "ijklmnop";
-  };
-  echelon = {                # Hidden SSID
-    hidden = true;
-    psk = "qrstuvwx";
-  };
-  free.wifi = {};            # Public wireless network
-};
-</programlisting>
-  Be aware that keys will be written to the nix store in plaintext! When no
-  networks are set, it will default to using a configuration file at
-  <literal>/etc/wpa_supplicant.conf</literal>. You should edit this file
-  yourself to define wireless networks, WPA keys and so on (see <citerefentry>
-  <refentrytitle>wpa_supplicant.conf</refentrytitle>
-  <manvolnum>5</manvolnum> </citerefentry>).
- </para>
-
- <para>
-  If you are using WPA2 you can generate pskRaw key using
-  <command>wpa_passphrase</command>:
-<screen>
-<prompt>$ </prompt>wpa_passphrase ESSID PSK
-network={
-        ssid="echelon"
-        #psk="abcdefgh"
-        psk=dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435
-}
-</screen>
-<programlisting>
-<xref linkend="opt-networking.wireless.networks"/> = {
-  echelon = {
-    pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435";
-  };
-}
-</programlisting>
-  or you can use it to directly generate the
-  <literal>wpa_supplicant.conf</literal>:
-<screen>
-<prompt># </prompt>wpa_passphrase ESSID PSK > /etc/wpa_supplicant.conf</screen>
-  After you have edited the <literal>wpa_supplicant.conf</literal>, you need to
-  restart the wpa_supplicant service.
-<screen>
-<prompt># </prompt>systemctl restart wpa_supplicant.service</screen>
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/x-windows.chapter.md b/nixpkgs/nixos/doc/manual/configuration/x-windows.chapter.md
new file mode 100644
index 000000000000..2c80b786b267
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/x-windows.chapter.md
@@ -0,0 +1,337 @@
+# X Window System {#sec-x11}
+
+The X Window System (X11) provides the basis of NixOS' graphical user
+interface. It can be enabled as follows:
+
+```nix
+services.xserver.enable = true;
+```
+
+The X server will automatically detect and use the appropriate video
+driver from a set of X.org drivers (such as `vesa` and `intel`). You can
+also specify a driver manually, e.g.
+
+```nix
+services.xserver.videoDrivers = [ "r128" ];
+```
+
+to enable X.org's `xf86-video-r128` driver.
+
+You also need to enable at least one desktop or window manager.
+Otherwise, you can only log into a plain undecorated `xterm` window.
+Thus you should pick one or more of the following lines:
+
+```nix
+services.xserver.desktopManager.plasma5.enable = true;
+services.xserver.desktopManager.xfce.enable = true;
+services.xserver.desktopManager.gnome.enable = true;
+services.xserver.desktopManager.mate.enable = true;
+services.xserver.windowManager.xmonad.enable = true;
+services.xserver.windowManager.twm.enable = true;
+services.xserver.windowManager.icewm.enable = true;
+services.xserver.windowManager.i3.enable = true;
+services.xserver.windowManager.herbstluftwm.enable = true;
+```
+
+NixOS's default *display manager* (the program that provides a graphical
+login prompt and manages the X server) is LightDM. You can select an
+alternative one by picking one of the following lines:
+
+```nix
+services.xserver.displayManager.sddm.enable = true;
+services.xserver.displayManager.gdm.enable = true;
+```
+
+You can set the keyboard layout (and optionally the layout variant):
+
+```nix
+services.xserver.layout = "de";
+services.xserver.xkbVariant = "neo";
+```
+
+The X server is started automatically at boot time. If you don't want
+this to happen, you can set:
+
+```nix
+services.xserver.autorun = false;
+```
+
+The X server can then be started manually:
+
+```ShellSession
+# systemctl start display-manager.service
+```
+
+On 64-bit systems, if you want OpenGL for 32-bit programs such as in
+Wine, you should also set the following:
+
+```nix
+hardware.opengl.driSupport32Bit = true;
+```
+
+## Auto-login {#sec-x11-auto-login .unnumbered}
+
+The x11 login screen can be skipped entirely, automatically logging you
+into your window manager and desktop environment when you boot your
+computer.
+
+This is especially helpful if you have disk encryption enabled. Since
+you already have to provide a password to decrypt your disk, entering a
+second password to login can be redundant.
+
+To enable auto-login, you need to define your default window manager and
+desktop environment. If you wanted no desktop environment and i3 as your
+your window manager, you\'d define:
+
+```nix
+services.xserver.displayManager.defaultSession = "none+i3";
+```
+
+Every display manager in NixOS supports auto-login, here is an example
+using lightdm for a user `alice`:
+
+```nix
+services.xserver.displayManager.lightdm.enable = true;
+services.xserver.displayManager.autoLogin.enable = true;
+services.xserver.displayManager.autoLogin.user = "alice";
+```
+
+## Intel Graphics drivers {#sec-x11--graphics-cards-intel .unnumbered}
+
+There are two choices for Intel Graphics drivers in X.org: `modesetting`
+(included in the xorg-server itself) and `intel` (provided by the
+package xf86-video-intel).
+
+The default and recommended is `modesetting`. It is a generic driver
+which uses the kernel [mode
+setting](https://en.wikipedia.org/wiki/Mode_setting) (KMS) mechanism. It
+supports Glamor (2D graphics acceleration via OpenGL) and is actively
+maintained but may perform worse in some cases (like in old chipsets).
+
+The second driver, `intel`, is specific to Intel GPUs, but not
+recommended by most distributions: it lacks several modern features (for
+example, it doesn\'t support Glamor) and the package hasn\'t been
+officially updated since 2015.
+
+The results vary depending on the hardware, so you may have to try both
+drivers. Use the option
+[](#opt-services.xserver.videoDrivers)
+to set one. The recommended configuration for modern systems is:
+
+```nix
+services.xserver.videoDrivers = [ "modesetting" ];
+services.xserver.useGlamor = true;
+```
+
+If you experience screen tearing no matter what, this configuration was
+reported to resolve the issue:
+
+```nix
+services.xserver.videoDrivers = [ "intel" ];
+services.xserver.deviceSection = ''
+  Option "DRI" "2"
+  Option "TearFree" "true"
+'';
+```
+
+Note that this will likely downgrade the performance compared to
+`modesetting` or `intel` with DRI 3 (default).
+
+## Proprietary NVIDIA drivers {#sec-x11-graphics-cards-nvidia .unnumbered}
+
+NVIDIA provides a proprietary driver for its graphics cards that has
+better 3D performance than the X.org drivers. It is not enabled by
+default because it's not free software. You can enable it as follows:
+
+```nix
+services.xserver.videoDrivers = [ "nvidia" ];
+```
+
+Or if you have an older card, you may have to use one of the legacy
+drivers:
+
+```nix
+services.xserver.videoDrivers = [ "nvidiaLegacy390" ];
+services.xserver.videoDrivers = [ "nvidiaLegacy340" ];
+services.xserver.videoDrivers = [ "nvidiaLegacy304" ];
+```
+
+You may need to reboot after enabling this driver to prevent a clash
+with other kernel modules.
+
+## Proprietary AMD drivers {#sec-x11--graphics-cards-amd .unnumbered}
+
+AMD provides a proprietary driver for its graphics cards that is not
+enabled by default because it's not Free Software, is often broken in
+nixpkgs and as of this writing doesn\'t offer more features or
+performance. If you still want to use it anyway, you need to explicitly
+set:
+
+```nix
+services.xserver.videoDrivers = [ "amdgpu-pro" ];
+```
+
+You will need to reboot after enabling this driver to prevent a clash
+with other kernel modules.
+
+## Touchpads {#sec-x11-touchpads .unnumbered}
+
+Support for Synaptics touchpads (found in many laptops such as the Dell
+Latitude series) can be enabled as follows:
+
+```nix
+services.xserver.libinput.enable = true;
+```
+
+The driver has many options (see [](#ch-options)).
+For instance, the following disables tap-to-click behavior:
+
+```nix
+services.xserver.libinput.touchpad.tapping = false;
+```
+
+Note: the use of `services.xserver.synaptics` is deprecated since NixOS
+17.09.
+
+## GTK/Qt themes {#sec-x11-gtk-and-qt-themes .unnumbered}
+
+GTK themes can be installed either to user profile or system-wide (via
+`environment.systemPackages`). To make Qt 5 applications look similar to
+GTK ones, you can use the following configuration:
+
+```nix
+qt5.enable = true;
+qt5.platformTheme = "gtk2";
+qt5.style = "gtk2";
+```
+
+## Custom XKB layouts {#custom-xkb-layouts .unnumbered}
+
+It is possible to install custom [ XKB
+](https://en.wikipedia.org/wiki/X_keyboard_extension) keyboard layouts
+using the option `services.xserver.extraLayouts`.
+
+As a first example, we are going to create a layout based on the basic
+US layout, with an additional layer to type some greek symbols by
+pressing the right-alt key.
+
+Create a file called `us-greek` with the following content (under a
+directory called `symbols`; it\'s an XKB peculiarity that will help with
+testing):
+
+```nix
+xkb_symbols "us-greek"
+{
+  include "us(basic)"            // includes the base US keys
+  include "level3(ralt_switch)"  // configures right alt as a third level switch
+
+  key <LatA> { [ a, A, Greek_alpha ] };
+  key <LatB> { [ b, B, Greek_beta  ] };
+  key <LatG> { [ g, G, Greek_gamma ] };
+  key <LatD> { [ d, D, Greek_delta ] };
+  key <LatZ> { [ z, Z, Greek_zeta  ] };
+};
+```
+
+A minimal layout specification must include the following:
+
+```nix
+services.xserver.extraLayouts.us-greek = {
+  description = "US layout with alt-gr greek";
+  languages   = [ "eng" ];
+  symbolsFile = /yourpath/symbols/us-greek;
+};
+```
+
+::: {.note}
+The name (after `extraLayouts.`) should match the one given to the
+`xkb_symbols` block.
+:::
+
+Applying this customization requires rebuilding several packages, and a
+broken XKB file can lead to the X session crashing at login. Therefore,
+you\'re strongly advised to **test your layout before applying it**:
+
+```ShellSession
+$ nix-shell -p xorg.xkbcomp
+$ setxkbmap -I/yourpath us-greek -print | xkbcomp -I/yourpath - $DISPLAY
+```
+
+You can inspect the predefined XKB files for examples:
+
+```ShellSession
+$ echo "$(nix-build --no-out-link '<nixpkgs>' -A xorg.xkeyboardconfig)/etc/X11/xkb/"
+```
+
+Once the configuration is applied, and you did a logout/login cycle, the
+layout should be ready to use. You can try it by e.g. running
+`setxkbmap us-greek` and then type `<alt>+a` (it may not get applied in
+your terminal straight away). To change the default, the usual
+`services.xserver.layout` option can still be used.
+
+A layout can have several other components besides `xkb_symbols`, for
+example we will define new keycodes for some multimedia key and bind
+these to some symbol.
+
+Use the *xev* utility from `pkgs.xorg.xev` to find the codes of the keys
+of interest, then create a `media-key` file to hold the keycodes
+definitions
+
+```nix
+xkb_keycodes "media"
+{
+ <volUp>   = 123;
+ <volDown> = 456;
+}
+```
+
+Now use the newly define keycodes in `media-sym`:
+
+```nix
+xkb_symbols "media"
+{
+ key.type = "ONE_LEVEL";
+ key <volUp>   { [ XF86AudioLowerVolume ] };
+ key <volDown> { [ XF86AudioRaiseVolume ] };
+}
+```
+
+As before, to install the layout do
+
+```nix
+services.xserver.extraLayouts.media = {
+  description  = "Multimedia keys remapping";
+  languages    = [ "eng" ];
+  symbolsFile  = /path/to/media-key;
+  keycodesFile = /path/to/media-sym;
+};
+```
+
+::: {.note}
+The function `pkgs.writeText <filename> <content>` can be useful if you
+prefer to keep the layout definitions inside the NixOS configuration.
+:::
+
+Unfortunately, the Xorg server does not (currently) support setting a
+keymap directly but relies instead on XKB rules to select the matching
+components (keycodes, types, \...) of a layout. This means that
+components other than symbols won\'t be loaded by default. As a
+workaround, you can set the keymap using `setxkbmap` at the start of the
+session with:
+
+```nix
+services.xserver.displayManager.sessionCommands = "setxkbmap -keycodes media";
+```
+
+If you are manually starting the X server, you should set the argument
+`-xkbdir /etc/X11/xkb`, otherwise X won\'t find your layout files. For
+example with `xinit` run
+
+```ShellSession
+$ xinit -- -xkbdir /etc/X11/xkb
+```
+
+To learn how to write layouts take a look at the XKB [documentation
+](https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Enhancing.html#Defining_New_Layouts).
+More example layouts can also be found [here
+](https://wiki.archlinux.org/index.php/X_KeyBoard_extension#Basic_examples).
diff --git a/nixpkgs/nixos/doc/manual/configuration/x-windows.xml b/nixpkgs/nixos/doc/manual/configuration/x-windows.xml
deleted file mode 100644
index f9121508d7d4..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/x-windows.xml
+++ /dev/null
@@ -1,355 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-x11">
- <title>X Window System</title>
- <para>
-  The X Window System (X11) provides the basis of NixOS’ graphical user
-  interface. It can be enabled as follows:
-<programlisting>
-<xref linkend="opt-services.xserver.enable"/> = true;
-</programlisting>
-  The X server will automatically detect and use the appropriate video driver
-  from a set of X.org drivers (such as <literal>vesa</literal> and
-  <literal>intel</literal>). You can also specify a driver manually, e.g.
-<programlisting>
-<xref linkend="opt-services.xserver.videoDrivers"/> = [ "r128" ];
-</programlisting>
-  to enable X.org’s <literal>xf86-video-r128</literal> driver.
- </para>
- <para>
-  You also need to enable at least one desktop or window manager. Otherwise,
-  you can only log into a plain undecorated <command>xterm</command> window.
-  Thus you should pick one or more of the following lines:
-<programlisting>
-<xref linkend="opt-services.xserver.desktopManager.plasma5.enable"/> = true;
-<xref linkend="opt-services.xserver.desktopManager.xfce.enable"/> = true;
-<xref linkend="opt-services.xserver.desktopManager.gnome.enable"/> = true;
-<xref linkend="opt-services.xserver.desktopManager.mate.enable"/> = true;
-<xref linkend="opt-services.xserver.windowManager.xmonad.enable"/> = true;
-<xref linkend="opt-services.xserver.windowManager.twm.enable"/> = true;
-<xref linkend="opt-services.xserver.windowManager.icewm.enable"/> = true;
-<xref linkend="opt-services.xserver.windowManager.i3.enable"/> = true;
-<xref linkend="opt-services.xserver.windowManager.herbstluftwm.enable"/> = true;
-</programlisting>
- </para>
- <para>
-  NixOS’s default <emphasis>display manager</emphasis> (the program that
-  provides a graphical login prompt and manages the X server) is LightDM. You
-  can select an alternative one by picking one of the following lines:
-<programlisting>
-<xref linkend="opt-services.xserver.displayManager.sddm.enable"/> = true;
-<xref linkend="opt-services.xserver.displayManager.gdm.enable"/> = true;
-</programlisting>
- </para>
- <para>
-  You can set the keyboard layout (and optionally the layout variant):
-<programlisting>
-<xref linkend="opt-services.xserver.layout"/> = "de";
-<xref linkend="opt-services.xserver.xkbVariant"/> = "neo";
-</programlisting>
- </para>
- <para>
-  The X server is started automatically at boot time. If you don’t want this
-  to happen, you can set:
-<programlisting>
-<xref linkend="opt-services.xserver.autorun"/> = false;
-</programlisting>
-  The X server can then be started manually:
-<screen>
-<prompt># </prompt>systemctl start display-manager.service
-</screen>
- </para>
- <para>
-  On 64-bit systems, if you want OpenGL for 32-bit programs such as in Wine,
-  you should also set the following:
-<programlisting>
-<xref linkend="opt-hardware.opengl.driSupport32Bit"/> = true;
-</programlisting>
- </para>
- <simplesect xml:id="sec-x11-auto-login">
-  <title>Auto-login</title>
-  <para>
-  The x11 login screen can be skipped entirely, automatically logging you into
-  your window manager and desktop environment when you boot your computer.
-  </para>
-  <para>
-  This is especially helpful if you have disk encryption enabled. Since you
-  already have to provide a password to decrypt your disk, entering a second
-  password to login can be redundant.
-  </para>
-  <para>
-  To enable auto-login, you need to define your default window manager and
-  desktop environment. If you wanted no desktop environment and i3 as your your
-  window manager, you'd define:
-<programlisting>
-<xref linkend="opt-services.xserver.displayManager.defaultSession"/> = "none+i3";
-</programlisting>
-  Every display manager in NixOS supports auto-login, here is an example
-  using lightdm for a user <literal>alice</literal>:
-<programlisting>
-<xref linkend="opt-services.xserver.displayManager.lightdm.enable"/> = true;
-<xref linkend="opt-services.xserver.displayManager.autoLogin.enable"/> = true;
-<xref linkend="opt-services.xserver.displayManager.autoLogin.user"/> = "alice";
-</programlisting>
-  </para>
- </simplesect>
- <simplesect xml:id="sec-x11--graphics-cards-intel">
-  <title>Intel Graphics drivers</title>
-  <para>
-   There are two choices for Intel Graphics drivers in X.org:
-   <literal>modesetting</literal> (included in the <package>xorg-server</package> itself)
-   and <literal>intel</literal> (provided by the package <package>xf86-video-intel</package>).
-  </para>
-  <para>
-   The default and recommended is <literal>modesetting</literal>.
-   It is a generic driver which uses the kernel
-   <link xlink:href="https://en.wikipedia.org/wiki/Mode_setting">mode setting</link>
-   (KMS) mechanism. It supports Glamor (2D graphics acceleration via OpenGL)
-   and is actively maintained but may perform worse in some cases (like in old chipsets).
-  </para>
-  <para>
-   The second driver, <literal>intel</literal>, is specific to Intel GPUs,
-   but not recommended by most distributions: it lacks several modern features
-   (for example, it doesn't support Glamor) and the package hasn't been officially
-   updated since 2015.
-  </para>
-  <para>
-   The results vary depending on the hardware, so you may have to try both drivers.
-   Use the option <xref linkend="opt-services.xserver.videoDrivers"/> to set one.
-   The recommended configuration for modern systems is:
-<programlisting>
-  <xref linkend="opt-services.xserver.videoDrivers"/> = [ "modesetting" ];
-  <xref linkend="opt-services.xserver.useGlamor"/> = true;
-</programlisting>
-   If you experience screen tearing no matter what, this configuration was
-   reported to resolve the issue:
-<programlisting>
-  <xref linkend="opt-services.xserver.videoDrivers"/> = [ "intel" ];
-  <xref linkend="opt-services.xserver.deviceSection"/> = ''
-    Option "DRI" "2"
-    Option "TearFree" "true"
-  '';
-</programlisting>
-   Note that this will likely downgrade the performance compared to
-  <literal>modesetting</literal> or <literal>intel</literal> with DRI 3 (default).
-  </para>
- </simplesect>
- <simplesect xml:id="sec-x11-graphics-cards-nvidia">
-  <title>Proprietary NVIDIA drivers</title>
-  <para>
-   NVIDIA provides a proprietary driver for its graphics cards that has better
-   3D performance than the X.org drivers. It is not enabled by default because
-   it’s not free software. You can enable it as follows:
-<programlisting>
-<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidia" ];
-</programlisting>
-   Or if you have an older card, you may have to use one of the legacy drivers:
-<programlisting>
-<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidiaLegacy390" ];
-<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidiaLegacy340" ];
-<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidiaLegacy304" ];
-</programlisting>
-   You may need to reboot after enabling this driver to prevent a clash with
-   other kernel modules.
-  </para>
- </simplesect>
- <simplesect xml:id="sec-x11--graphics-cards-amd">
-  <title>Proprietary AMD drivers</title>
-  <para>
-   AMD provides a proprietary driver for its graphics cards that is not
-   enabled by default because it’s not Free Software, is often broken
-   in nixpkgs and as of this writing doesn't offer more features or
-   performance. If you still want to use it anyway, you need to explicitly set:
-<programlisting>
-<xref linkend="opt-services.xserver.videoDrivers"/> = [ "amdgpu-pro" ];
-</programlisting>
-   You will need to reboot after enabling this driver to prevent a clash with
-   other kernel modules.
-  </para>
- </simplesect>
- <simplesect xml:id="sec-x11-touchpads">
-  <title>Touchpads</title>
-  <para>
-   Support for Synaptics touchpads (found in many laptops such as the Dell
-   Latitude series) can be enabled as follows:
-<programlisting>
-<xref linkend="opt-services.xserver.libinput.enable"/> = true;
-</programlisting>
-   The driver has many options (see <xref linkend="ch-options"/>). For
-   instance, the following disables tap-to-click behavior:
-<programlisting>
-<xref linkend="opt-services.xserver.libinput.touchpad.tapping"/> = false;
-</programlisting>
-   Note: the use of <literal>services.xserver.synaptics</literal> is deprecated
-   since NixOS 17.09.
-  </para>
- </simplesect>
- <simplesect xml:id="sec-x11-gtk-and-qt-themes">
-  <title>GTK/Qt themes</title>
-  <para>
-   GTK themes can be installed either to user profile or system-wide (via
-   <literal>environment.systemPackages</literal>). To make Qt 5 applications
-   look similar to GTK ones, you can use the following configuration:
-<programlisting>
-<xref linkend="opt-qt5.enable"/> = true;
-<xref linkend="opt-qt5.platformTheme"/> = "gtk2";
-<xref linkend="opt-qt5.style"/> = "gtk2";
-</programlisting>
-  </para>
- </simplesect>
- <simplesect xml:id="custom-xkb-layouts">
-  <title>Custom XKB layouts</title>
-  <para>
-   It is possible to install custom
-   <link xlink:href="https://en.wikipedia.org/wiki/X_keyboard_extension">
-    XKB
-   </link>
-   keyboard layouts using the option
-   <option><link linkend="opt-services.xserver.extraLayouts">
-     services.xserver.extraLayouts</link></option>.
-  </para>
-  <para>
-   As a first example, we are going to create a layout based on the basic US
-   layout, with an additional layer to type some greek symbols by pressing the
-   right-alt key.
-  </para>
-  <para>
-   Create a file called <literal>us-greek</literal> with the following
-   content (under a directory called <literal>symbols</literal>; it's
-   an XKB peculiarity that will help with testing):
-  </para>
-<programlisting>
-xkb_symbols &quot;us-greek&quot;
-{
-  include &quot;us(basic)&quot;            // includes the base US keys
-  include &quot;level3(ralt_switch)&quot;  // configures right alt as a third level switch
-
-  key &lt;LatA&gt; { [ a, A, Greek_alpha ] };
-  key &lt;LatB&gt; { [ b, B, Greek_beta  ] };
-  key &lt;LatG&gt; { [ g, G, Greek_gamma ] };
-  key &lt;LatD&gt; { [ d, D, Greek_delta ] };
-  key &lt;LatZ&gt; { [ z, Z, Greek_zeta  ] };
-};
-</programlisting>
-  <para>
-   A minimal layout specification must include the following:
-  </para>
-<programlisting>
-<xref linkend="opt-services.xserver.extraLayouts"/>.us-greek = {
-  description = "US layout with alt-gr greek";
-  languages   = [ "eng" ];
-  symbolsFile = /yourpath/symbols/us-greek;
-};
-</programlisting>
-  <note>
-  <para>
-   The name (after <literal>extraLayouts.</literal>) should match the one given to the
-   <literal>xkb_symbols</literal> block.
-  </para>
-  </note>
-  <para>
-   Applying this customization requires rebuilding several packages,
-   and a broken XKB file can lead to the X session crashing at login.
-   Therefore, you're strongly advised to <emphasis role="strong">test
-   your layout before applying it</emphasis>:
-<screen>
-<prompt>$ </prompt>nix-shell -p xorg.xkbcomp
-<prompt>$ </prompt>setxkbmap -I/yourpath us-greek -print | xkbcomp -I/yourpath - $DISPLAY
-</screen>
-  </para>
-  <para>
-   You can inspect the predefined XKB files for examples:
-<screen>
-<prompt>$ </prompt>echo "$(nix-build --no-out-link '&lt;nixpkgs&gt;' -A xorg.xkeyboardconfig)/etc/X11/xkb/"
-</screen>
-  </para>
-  <para>
-   Once the configuration is applied, and you did a logout/login
-   cycle, the layout should be ready to use. You can try it by e.g.
-   running <literal>setxkbmap us-greek</literal> and then type
-   <literal>&lt;alt&gt;+a</literal> (it may not get applied in your
-   terminal straight away). To change the default, the usual
-   <option>
-    <link linkend="opt-services.xserver.layout">
-     services.xserver.layout
-    </link>
-   </option>
-   option can still be used.
-  </para>
-  <para>
-   A layout can have several other components besides
-   <literal>xkb_symbols</literal>, for example we will define new
-   keycodes for some multimedia key and bind these to some symbol.
-  </para>
-  <para>
-   Use the <emphasis>xev</emphasis> utility from
-   <literal>pkgs.xorg.xev</literal> to find the codes of the keys of
-   interest, then create a <literal>media-key</literal> file to hold
-   the keycodes definitions
-  </para>
-<programlisting>
-xkb_keycodes &quot;media&quot;
-{
- &lt;volUp&gt;   = 123;
- &lt;volDown&gt; = 456;
-}
-</programlisting>
-  <para>
-    Now use the newly define keycodes in <literal>media-sym</literal>:
-  </para>
-<programlisting>
-xkb_symbols &quot;media&quot;
-{
- key.type = &quot;ONE_LEVEL&quot;;
- key &lt;volUp&gt;   { [ XF86AudioLowerVolume ] };
- key &lt;volDown&gt; { [ XF86AudioRaiseVolume ] };
-}
-</programlisting>
-  <para>
-    As before, to install the layout do
-  </para>
-<programlisting>
-<xref linkend="opt-services.xserver.extraLayouts"/>.media = {
-  description  = "Multimedia keys remapping";
-  languages    = [ "eng" ];
-  symbolsFile  = /path/to/media-key;
-  keycodesFile = /path/to/media-sym;
-};
-</programlisting>
-  <note>
-  <para>
-   The function <literal>pkgs.writeText &lt;filename&gt; &lt;content&gt;
-   </literal> can be useful if you prefer to keep the layout definitions
-   inside the NixOS configuration.
-  </para>
-  </note>
-  <para>
-    Unfortunately, the Xorg server does not (currently) support setting a
-    keymap directly but relies instead on XKB rules to select the matching
-    components (keycodes, types, ...) of a layout. This means that components
-    other than symbols won't be loaded by default. As a workaround, you
-    can set the keymap using <literal>setxkbmap</literal> at the start of the
-    session with:
-  </para>
-<programlisting>
-<xref linkend="opt-services.xserver.displayManager.sessionCommands"/> = "setxkbmap -keycodes media";
-</programlisting>
-  <para>
-    If you are manually starting the X server, you should set the argument
-    <literal>-xkbdir /etc/X11/xkb</literal>, otherwise X won't find your layout files.
-    For example with <command>xinit</command> run
-    <screen><prompt>$ </prompt>xinit -- -xkbdir /etc/X11/xkb</screen>
-  </para>
-  <para>
-   To learn how to write layouts take a look at the XKB
-  <link xlink:href="https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Enhancing.html#Defining_New_Layouts">
-   documentation
-  </link>. More example layouts can also be found
-  <link xlink:href="https://wiki.archlinux.org/index.php/X_KeyBoard_extension#Basic_examples">
-   here
-  </link>.
-  </para>
-</simplesect>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/configuration/xfce.chapter.md b/nixpkgs/nixos/doc/manual/configuration/xfce.chapter.md
new file mode 100644
index 000000000000..b0ef6682aae8
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/configuration/xfce.chapter.md
@@ -0,0 +1,52 @@
+# Xfce Desktop Environment {#sec-xfce}
+
+To enable the Xfce Desktop Environment, set
+
+```nix
+services.xserver.desktopManager.xfce.enable = true;
+services.xserver.displayManager.defaultSession = "xfce";
+```
+
+Optionally, *picom* can be enabled for nice graphical effects, some
+example settings:
+
+```nix
+services.picom = {
+  enable = true;
+  fade = true;
+  inactiveOpacity = 0.9;
+  shadow = true;
+  fadeDelta = 4;
+};
+```
+
+Some Xfce programs are not installed automatically. To install them
+manually (system wide), put them into your
+[](#opt-environment.systemPackages) from `pkgs.xfce`.
+
+## Thunar Plugins {#sec-xfce-thunar-plugins .unnumbered}
+
+If you\'d like to add extra plugins to Thunar, add them to
+[](#opt-services.xserver.desktopManager.xfce.thunarPlugins).
+You shouldn\'t just add them to [](#opt-environment.systemPackages).
+
+## Troubleshooting {#sec-xfce-troubleshooting .unnumbered}
+
+Even after enabling udisks2, volume management might not work. Thunar
+and/or the desktop takes time to show up. Thunar will spit out this kind
+of message on start (look at `journalctl --user -b`).
+
+```plain
+Thunar:2410): GVFS-RemoteVolumeMonitor-WARNING **: remote volume monitor with dbus name org.gtk.Private.UDisks2VolumeMonitor is not supported
+```
+
+This is caused by some needed GNOME services not running. This is all
+fixed by enabling \"Launch GNOME services on startup\" in the Advanced
+tab of the Session and Startup settings panel. Alternatively, you can
+run this command to do the same thing.
+
+```ShellSession
+$ xfconf-query -c xfce4-session -p /compat/LaunchGNOME -s true
+```
+
+A log-out and re-log will be needed for this to take effect.
diff --git a/nixpkgs/nixos/doc/manual/configuration/xfce.xml b/nixpkgs/nixos/doc/manual/configuration/xfce.xml
deleted file mode 100644
index abcf5f648a48..000000000000
--- a/nixpkgs/nixos/doc/manual/configuration/xfce.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-xfce">
- <title>Xfce Desktop Environment</title>
- <para>
-  To enable the Xfce Desktop Environment, set
-<programlisting>
-<xref linkend="opt-services.xserver.desktopManager.xfce.enable" /> = true;
-<xref linkend="opt-services.xserver.displayManager.defaultSession" /> = "xfce";
-</programlisting>
- </para>
- <para>
-  Optionally, <emphasis>picom</emphasis> can be enabled for nice graphical
-  effects, some example settings:
-<programlisting>
-<link linkend="opt-services.picom.enable">services.picom</link> = {
-  <link linkend="opt-services.picom.enable">enable</link> = true;
-  <link linkend="opt-services.picom.fade">fade</link> = true;
-  <link linkend="opt-services.picom.inactiveOpacity">inactiveOpacity</link> = 0.9;
-  <link linkend="opt-services.picom.shadow">shadow</link> = true;
-  <link linkend="opt-services.picom.fadeDelta">fadeDelta</link> = 4;
-};
-</programlisting>
- </para>
- <para>
-  Some Xfce programs are not installed automatically. To install them manually
-  (system wide), put them into your
-  <xref linkend="opt-environment.systemPackages"/> from <literal>pkgs.xfce</literal>.
- </para>
- <simplesect xml:id="sec-xfce-thunar-plugins">
-  <title>Thunar Plugins</title>
-  <para>
-    If you'd like to add extra plugins to Thunar, add them to
-    <xref linkend="opt-services.xserver.desktopManager.xfce.thunarPlugins"/>.
-    You shouldn't just add them to <xref linkend="opt-environment.systemPackages"/>.
-  </para>
- </simplesect>
- <simplesect xml:id="sec-xfce-troubleshooting">
-  <title>Troubleshooting</title>
-  <para>
-   Even after enabling udisks2, volume management might not work. Thunar and/or
-   the desktop takes time to show up. Thunar will spit out this kind of message
-   on start (look at <command>journalctl --user -b</command>).
-<programlisting>
-Thunar:2410): GVFS-RemoteVolumeMonitor-WARNING **: remote volume monitor with dbus name org.gtk.Private.UDisks2VolumeMonitor is not supported
-</programlisting>
-   This is caused by some needed GNOME services not running. This is all fixed
-   by enabling "Launch GNOME services on startup" in the Advanced tab of the
-   Session and Startup settings panel. Alternatively, you can run this command
-   to do the same thing.
-<programlisting>
-<prompt>$ </prompt>xfconf-query -c xfce4-session -p /compat/LaunchGNOME -s true
-</programlisting>
-   A log-out and re-log will be needed for this to take effect.
-  </para>
- </simplesect>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/development/building-parts.chapter.md b/nixpkgs/nixos/doc/manual/development/building-parts.chapter.md
new file mode 100644
index 000000000000..79ddaa37140b
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/building-parts.chapter.md
@@ -0,0 +1,74 @@
+# Building Specific Parts of NixOS {#sec-building-parts}
+
+With the command `nix-build`, you can build specific parts of your NixOS
+configuration. This is done as follows:
+
+```ShellSession
+$ cd /path/to/nixpkgs/nixos
+$ nix-build -A config.option
+```
+
+where `option` is a NixOS option with type "derivation" (i.e. something
+that can be built). Attributes of interest include:
+
+`system.build.toplevel`
+
+:   The top-level option that builds the entire NixOS system. Everything
+    else in your configuration is indirectly pulled in by this option.
+    This is what `nixos-rebuild` builds and what `/run/current-system`
+    points to afterwards.
+
+    A shortcut to build this is:
+
+    ```ShellSession
+    $ nix-build -A system
+    ```
+
+`system.build.manual.manualHTML`
+
+:   The NixOS manual.
+
+`system.build.etc`
+
+:   A tree of symlinks that form the static parts of `/etc`.
+
+`system.build.initialRamdisk` , `system.build.kernel`
+
+:   The initial ramdisk and kernel of the system. This allows a quick
+    way to test whether the kernel and the initial ramdisk boot
+    correctly, by using QEMU's `-kernel` and `-initrd` options:
+
+    ```ShellSession
+    $ nix-build -A config.system.build.initialRamdisk -o initrd
+    $ nix-build -A config.system.build.kernel -o kernel
+    $ qemu-system-x86_64 -kernel ./kernel/bzImage -initrd ./initrd/initrd -hda /dev/null
+    ```
+
+`system.build.nixos-rebuild` , `system.build.nixos-install` , `system.build.nixos-generate-config`
+
+:   These build the corresponding NixOS commands.
+
+`systemd.units.unit-name.unit`
+
+:   This builds the unit with the specified name. Note that since unit
+    names contain dots (e.g. `httpd.service`), you need to put them
+    between quotes, like this:
+
+    ```ShellSession
+    $ nix-build -A 'config.systemd.units."httpd.service".unit'
+    ```
+
+    You can also test individual units, without rebuilding the whole
+    system, by putting them in `/run/systemd/system`:
+
+    ```ShellSession
+    $ cp $(nix-build -A 'config.systemd.units."httpd.service".unit')/httpd.service \
+        /run/systemd/system/tmp-httpd.service
+    # systemctl daemon-reload
+    # systemctl start tmp-httpd.service
+    ```
+
+    Note that the unit must not have the same name as any unit in
+    `/etc/systemd/system` since those take precedence over
+    `/run/systemd/system`. That's why the unit is installed as
+    `tmp-httpd.service` here.
diff --git a/nixpkgs/nixos/doc/manual/development/building-parts.xml b/nixpkgs/nixos/doc/manual/development/building-parts.xml
deleted file mode 100644
index 88369fb891b3..000000000000
--- a/nixpkgs/nixos/doc/manual/development/building-parts.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-building-parts">
- <title>Building Specific Parts of NixOS</title>
- <para>
-  With the command <command>nix-build</command>, you can build specific parts
-  of your NixOS configuration. This is done as follows:
-<screen>
-<prompt>$ </prompt>cd <replaceable>/path/to/nixpkgs/nixos</replaceable>
-<prompt>$ </prompt>nix-build -A config.<replaceable>option</replaceable></screen>
-  where <replaceable>option</replaceable> is a NixOS option with type
-  “derivation” (i.e. something that can be built). Attributes of interest
-  include:
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>system.build.toplevel</varname>
-    </term>
-    <listitem>
-     <para>
-      The top-level option that builds the entire NixOS system. Everything else
-      in your configuration is indirectly pulled in by this option. This is
-      what <command>nixos-rebuild</command> builds and what
-      <filename>/run/current-system</filename> points to afterwards.
-     </para>
-     <para>
-      A shortcut to build this is:
-<screen>
-<prompt>$ </prompt>nix-build -A system</screen>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>system.build.manual.manualHTML</varname>
-    </term>
-    <listitem>
-     <para>
-      The NixOS manual.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>system.build.etc</varname>
-    </term>
-    <listitem>
-     <para>
-      A tree of symlinks that form the static parts of
-      <filename>/etc</filename>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>system.build.initialRamdisk</varname>
-    </term>
-    <term>
-     <varname>system.build.kernel</varname>
-    </term>
-    <listitem>
-     <para>
-      The initial ramdisk and kernel of the system. This allows a quick way to
-      test whether the kernel and the initial ramdisk boot correctly, by using
-      QEMU’s <option>-kernel</option> and <option>-initrd</option> options:
-<screen>
-<prompt>$ </prompt>nix-build -A config.system.build.initialRamdisk -o initrd
-<prompt>$ </prompt>nix-build -A config.system.build.kernel -o kernel
-<prompt>$ </prompt>qemu-system-x86_64 -kernel ./kernel/bzImage -initrd ./initrd/initrd -hda /dev/null
-</screen>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>system.build.nixos-rebuild</varname>
-    </term>
-    <term>
-     <varname>system.build.nixos-install</varname>
-    </term>
-    <term>
-     <varname>system.build.nixos-generate-config</varname>
-    </term>
-    <listitem>
-     <para>
-      These build the corresponding NixOS commands.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>systemd.units.<replaceable>unit-name</replaceable>.unit</varname>
-    </term>
-    <listitem>
-     <para>
-      This builds the unit with the specified name. Note that since unit names
-      contain dots (e.g. <literal>httpd.service</literal>), you need to put
-      them between quotes, like this:
-<screen>
-<prompt>$ </prompt>nix-build -A 'config.systemd.units."httpd.service".unit'
-</screen>
-      You can also test individual units, without rebuilding the whole system,
-      by putting them in <filename>/run/systemd/system</filename>:
-<screen>
-<prompt>$ </prompt>cp $(nix-build -A 'config.systemd.units."httpd.service".unit')/httpd.service \
-    /run/systemd/system/tmp-httpd.service
-<prompt># </prompt>systemctl daemon-reload
-<prompt># </prompt>systemctl start tmp-httpd.service
-</screen>
-      Note that the unit must not have the same name as any unit in
-      <filename>/etc/systemd/system</filename> since those take precedence over
-      <filename>/run/systemd/system</filename>. That’s why the unit is
-      installed as <filename>tmp-httpd.service</filename> here.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/development/development.xml b/nixpkgs/nixos/doc/manual/development/development.xml
index eb505567962c..0b2ad60a878b 100644
--- a/nixpkgs/nixos/doc/manual/development/development.xml
+++ b/nixpkgs/nixos/doc/manual/development/development.xml
@@ -9,11 +9,11 @@
    This chapter describes how you can modify and extend NixOS.
   </para>
  </partintro>
- <xi:include href="sources.xml" />
- <xi:include href="writing-modules.xml" />
- <xi:include href="building-parts.xml" />
- <xi:include href="writing-documentation.xml" />
+ <xi:include href="../from_md/development/sources.chapter.xml" />
+ <xi:include href="../from_md/development/writing-modules.chapter.xml" />
+ <xi:include href="../from_md/development/building-parts.chapter.xml" />
+ <xi:include href="../from_md/development/writing-documentation.chapter.xml" />
  <xi:include href="../from_md/development/building-nixos.chapter.xml" />
- <xi:include href="nixos-tests.xml" />
- <xi:include href="testing-installer.xml" />
+ <xi:include href="../from_md/development/nixos-tests.chapter.xml" />
+ <xi:include href="../from_md/development/testing-installer.chapter.xml" />
 </part>
diff --git a/nixpkgs/nixos/doc/manual/development/freeform-modules.section.md b/nixpkgs/nixos/doc/manual/development/freeform-modules.section.md
new file mode 100644
index 000000000000..10e876b96d59
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/freeform-modules.section.md
@@ -0,0 +1,79 @@
+# Freeform modules {#sec-freeform-modules}
+
+Freeform modules allow you to define values for option paths that have
+not been declared explicitly. This can be used to add attribute-specific
+types to what would otherwise have to be `attrsOf` options in order to
+accept all attribute names.
+
+This feature can be enabled by using the attribute `freeformType` to
+define a freeform type. By doing this, all assignments without an
+associated option will be merged using the freeform type and combined
+into the resulting `config` set. Since this feature nullifies name
+checking for entire option trees, it is only recommended for use in
+submodules.
+
+::: {#ex-freeform-module .example}
+::: {.title}
+**Example: Freeform submodule**
+:::
+The following shows a submodule assigning a freeform type that allows
+arbitrary attributes with `str` values below `settings`, but also
+declares an option for the `settings.port` attribute to have it
+type-checked and assign a default value. See
+[Example: Declaring a type-checked `settings` attribute](#ex-settings-typed-attrs)
+for a more complete example.
+
+```nix
+{ lib, config, ... }: {
+
+  options.settings = lib.mkOption {
+    type = lib.types.submodule {
+
+      freeformType = with lib.types; attrsOf str;
+
+      # We want this attribute to be checked for the correct type
+      options.port = lib.mkOption {
+        type = lib.types.port;
+        # Declaring the option also allows defining a default value
+        default = 8080;
+      };
+
+    };
+  };
+}
+```
+
+And the following shows what such a module then allows
+
+```nix
+{
+  # Not a declared option, but the freeform type allows this
+  settings.logLevel = "debug";
+
+  # Not allowed because the the freeform type only allows strings
+  # settings.enable = true;
+
+  # Allowed because there is a port option declared
+  settings.port = 80;
+
+  # Not allowed because the port option doesn't allow strings
+  # settings.port = "443";
+}
+```
+:::
+
+::: {.note}
+Freeform attributes cannot depend on other attributes of the same set
+without infinite recursion:
+
+```nix
+{
+  # This throws infinite recursion encountered
+  settings.logLevel = lib.mkIf (config.settings.port == 80) "debug";
+}
+```
+
+To prevent this, declare options for all attributes that need to depend
+on others. For above example this means to declare `logLevel` to be an
+option.
+:::
diff --git a/nixpkgs/nixos/doc/manual/development/freeform-modules.xml b/nixpkgs/nixos/doc/manual/development/freeform-modules.xml
deleted file mode 100644
index 257e6b11bf01..000000000000
--- a/nixpkgs/nixos/doc/manual/development/freeform-modules.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-freeform-modules">
- <title>Freeform modules</title>
- <para>
-  Freeform modules allow you to define values for option paths that have not been declared explicitly. This can be used to add attribute-specific types to what would otherwise have to be <literal>attrsOf</literal> options in order to accept all attribute names.
- </para>
- <para>
-  This feature can be enabled by using the attribute <literal>freeformType</literal> to define a freeform type. By doing this, all assignments without an associated option will be merged using the freeform type and combined into the resulting <literal>config</literal> set. Since this feature nullifies name checking for entire option trees, it is only recommended for use in submodules.
- </para>
- <example xml:id="ex-freeform-module">
-  <title>Freeform submodule</title>
-  <para>
-   The following shows a submodule assigning a freeform type that allows arbitrary attributes with <literal>str</literal> values below <literal>settings</literal>, but also declares an option for the <literal>settings.port</literal> attribute to have it type-checked and assign a default value. See <xref linkend="ex-settings-typed-attrs"/> for a more complete example.
-  </para>
- <programlisting>
-{ lib, config, ... }: {
-
-  options.settings = lib.mkOption {
-    type = lib.types.submodule {
-
-      freeformType = with lib.types; attrsOf str;
-
-      # We want this attribute to be checked for the correct type
-      options.port = lib.mkOption {
-        type = lib.types.port;
-        # Declaring the option also allows defining a default value
-        default = 8080;
-      };
-
-    };
-  };
-}
- </programlisting>
- <para>
-  And the following shows what such a module then allows
- </para>
- <programlisting>
-{
-  # Not a declared option, but the freeform type allows this
-  settings.logLevel = "debug";
-
-  # Not allowed because the the freeform type only allows strings
-  # settings.enable = true;
-
-  # Allowed because there is a port option declared
-  settings.port = 80;
-
-  # Not allowed because the port option doesn't allow strings
-  # settings.port = "443";
-}
- </programlisting>
- </example>
- <note>
-  <para>
-   Freeform attributes cannot depend on other attributes of the same set without infinite recursion:
-<programlisting>
-{
-  # This throws infinite recursion encountered
-  settings.logLevel = lib.mkIf (config.settings.port == 80) "debug";
-}
-</programlisting>
-   To prevent this, declare options for all attributes that need to depend on others. For above example this means to declare <literal>logLevel</literal> to be an option.
-  </para>
- </note>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/importing-modules.section.md b/nixpkgs/nixos/doc/manual/development/importing-modules.section.md
new file mode 100644
index 000000000000..65d78959b8e0
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/importing-modules.section.md
@@ -0,0 +1,46 @@
+# Importing Modules {#sec-importing-modules}
+
+Sometimes NixOS modules need to be used in configuration but exist
+outside of Nixpkgs. These modules can be imported:
+
+```nix
+{ config, lib, pkgs, ... }:
+
+{
+  imports =
+    [ # Use a locally-available module definition in
+      # ./example-module/default.nix
+        ./example-module
+    ];
+
+  services.exampleModule.enable = true;
+}
+```
+
+The environment variable `NIXOS_EXTRA_MODULE_PATH` is an absolute path
+to a NixOS module that is included alongside the Nixpkgs NixOS modules.
+Like any NixOS module, this module can import additional modules:
+
+```nix
+# ./module-list/default.nix
+[
+  ./example-module1
+  ./example-module2
+]
+```
+
+```nix
+# ./extra-module/default.nix
+{ imports = import ./module-list.nix; }
+```
+
+```nix
+# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module
+{ config, lib, pkgs, ... }:
+
+{
+  # No `imports` needed
+
+  services.exampleModule1.enable = true;
+}
+```
diff --git a/nixpkgs/nixos/doc/manual/development/importing-modules.xml b/nixpkgs/nixos/doc/manual/development/importing-modules.xml
deleted file mode 100644
index 1c6a5671eda8..000000000000
--- a/nixpkgs/nixos/doc/manual/development/importing-modules.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-importing-modules">
- <title>Importing Modules</title>
-
- <para>
-  Sometimes NixOS modules need to be used in configuration but exist outside of
-  Nixpkgs. These modules can be imported:
- </para>
-
-<programlisting>
-{ config, lib, pkgs, ... }:
-
-{
-  imports =
-    [ # Use a locally-available module definition in
-      # ./example-module/default.nix
-        ./example-module
-    ];
-
-  services.exampleModule.enable = true;
-}
-</programlisting>
-
- <para>
-  The environment variable <literal>NIXOS_EXTRA_MODULE_PATH</literal> is an
-  absolute path to a NixOS module that is included alongside the Nixpkgs NixOS
-  modules. Like any NixOS module, this module can import additional modules:
- </para>
-
-<programlisting>
-# ./module-list/default.nix
-[
-  ./example-module1
-  ./example-module2
-]
-</programlisting>
-
-<programlisting>
-# ./extra-module/default.nix
-{ imports = import ./module-list.nix; }
-</programlisting>
-
-<programlisting>
-# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module
-{ config, lib, pkgs, ... }:
-
-{
-  # No `imports` needed
-
-  services.exampleModule1.enable = true;
-}
-</programlisting>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/meta-attributes.section.md b/nixpkgs/nixos/doc/manual/development/meta-attributes.section.md
new file mode 100644
index 000000000000..ca4ba007f7dc
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/meta-attributes.section.md
@@ -0,0 +1,40 @@
+# Meta Attributes {#sec-meta-attributes}
+
+Like Nix packages, NixOS modules can declare meta-attributes to provide
+extra information. Module meta attributes are defined in the `meta.nix`
+special module.
+
+`meta` is a top level attribute like `options` and `config`. Available
+meta-attributes are `maintainers` and `doc`.
+
+Each of the meta-attributes must be defined at most once per module
+file.
+
+```nix
+{ config, lib, pkgs, ... }:
+{
+  options = {
+    ...
+  };
+
+  config = {
+    ...
+  };
+
+  meta = {
+    maintainers = with lib.maintainers; [ ericsagnes ];
+    doc = ./default.xml;
+  };
+}
+```
+
+-   `maintainers` contains a list of the module maintainers.
+
+-   `doc` points to a valid DocBook file containing the module
+    documentation. Its contents is automatically added to
+    [](#ch-configuration). Changes to a module documentation have to
+    be checked to not break building the NixOS manual:
+
+    ```ShellSession
+    $ nix-build nixos/release.nix -A manual.x86_64-linux
+    ```
diff --git a/nixpkgs/nixos/doc/manual/development/meta-attributes.xml b/nixpkgs/nixos/doc/manual/development/meta-attributes.xml
deleted file mode 100644
index c40be0a50c36..000000000000
--- a/nixpkgs/nixos/doc/manual/development/meta-attributes.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-meta-attributes">
- <title>Meta Attributes</title>
-
- <para>
-  Like Nix packages, NixOS modules can declare meta-attributes to provide extra
-  information. Module meta attributes are defined in the
-  <filename
-    xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/meta.nix">meta.nix</filename>
-  special module.
- </para>
-
- <para>
-  <literal>meta</literal> is a top level attribute like
-  <literal>options</literal> and <literal>config</literal>. Available
-  meta-attributes are <literal>maintainers</literal> and
-  <literal>doc</literal>.
- </para>
-
- <para>
-  Each of the meta-attributes must be defined at most once per module file.
- </para>
-
-<programlisting>
-{ config, lib, pkgs, ... }:
-{
-  options = {
-    ...
-  };
-
-  config = {
-    ...
-  };
-
-  meta = {
-    maintainers = with lib.maintainers; [ ericsagnes ]; <co
-      xml:id='modules-meta-1' />
-    doc = ./default.xml; <co xml:id='modules-meta-2' />
-  };
-}
-</programlisting>
-
- <calloutlist>
-  <callout arearefs='modules-meta-1'>
-   <para>
-    <varname>maintainers</varname> contains a list of the module maintainers.
-   </para>
-  </callout>
-  <callout arearefs='modules-meta-2'>
-   <para>
-    <varname>doc</varname> points to a valid DocBook file containing the module
-    documentation. Its contents is automatically added to
-    <xref
-      linkend="ch-configuration"/>. Changes to a module documentation
-    have to be checked to not break building the NixOS manual:
-   </para>
-<screen><prompt>$ </prompt>nix-build nixos/release.nix -A manual.x86_64-linux</screen>
-  </callout>
- </calloutlist>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/nixos-tests.chapter.md b/nixpkgs/nixos/doc/manual/development/nixos-tests.chapter.md
new file mode 100644
index 000000000000..2a4fdddeaa66
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/nixos-tests.chapter.md
@@ -0,0 +1,13 @@
+# NixOS Tests {#sec-nixos-tests}
+
+When you add some feature to NixOS, you should write a test for it.
+NixOS tests are kept in the directory `nixos/tests`, and are executed
+(using Nix) by a testing framework that automatically starts one or more
+virtual machines containing the NixOS system(s) required for the test.
+
+```{=docbook}
+<xi:include href="writing-nixos-tests.section.xml" />
+<xi:include href="running-nixos-tests.section.xml" />
+<xi:include href="running-nixos-tests-interactively.section.xml" />
+<xi:include href="linking-nixos-tests-to-packages.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/development/nixos-tests.xml b/nixpkgs/nixos/doc/manual/development/nixos-tests.xml
deleted file mode 100644
index 67dc09fc715f..000000000000
--- a/nixpkgs/nixos/doc/manual/development/nixos-tests.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-nixos-tests">
- <title>NixOS Tests</title>
- <para>
-  When you add some feature to NixOS, you should write a test for it. NixOS
-  tests are kept in the directory
-  <filename
-xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/tests">nixos/tests</filename>,
-  and are executed (using Nix) by a testing framework that automatically starts
-  one or more virtual machines containing the NixOS system(s) required for the
-  test.
- </para>
- <xi:include href="../from_md/development/writing-nixos-tests.section.xml" />
- <xi:include href="../from_md/development/running-nixos-tests.section.xml" />
- <xi:include href="../from_md/development/running-nixos-tests-interactively.section.xml" />
- <xi:include href="../from_md/development/linking-nixos-tests-to-packages.section.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/development/option-declarations.section.md b/nixpkgs/nixos/doc/manual/development/option-declarations.section.md
new file mode 100644
index 000000000000..819c23684cdf
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/option-declarations.section.md
@@ -0,0 +1,136 @@
+# Option Declarations {#sec-option-declarations}
+
+An option declaration specifies the name, type and description of a
+NixOS configuration option. It is invalid to define an option that
+hasn't been declared in any module. An option declaration generally
+looks like this:
+
+```nix
+options = {
+  name = mkOption {
+    type = type specification;
+    default = default value;
+    example = example value;
+    description = "Description for use in the NixOS manual.";
+  };
+};
+```
+
+The attribute names within the `name` attribute path must be camel
+cased in general but should, as an exception, match the [ package
+attribute name](https://nixos.org/nixpkgs/manual/#sec-package-naming)
+when referencing a Nixpkgs package. For example, the option
+`services.nix-serve.bindAddress` references the `nix-serve` Nixpkgs
+package.
+
+The function `mkOption` accepts the following arguments.
+
+`type`
+
+:   The type of the option (see [](#sec-option-types)). It may be
+    omitted, but that's not advisable since it may lead to errors that
+    are hard to diagnose.
+
+`default`
+
+:   The default value used if no value is defined by any module. A
+    default is not required; but if a default is not given, then users
+    of the module will have to define the value of the option, otherwise
+    an error will be thrown.
+
+`example`
+
+:   An example value that will be shown in the NixOS manual.
+
+`description`
+
+:   A textual description of the option, in DocBook format, that will be
+    included in the NixOS manual.
+
+## Extensible Option Types {#sec-option-declarations-eot}
+
+Extensible option types is a feature that allow to extend certain types
+declaration through multiple module files. This feature only work with a
+restricted set of types, namely `enum` and `submodules` and any composed
+forms of them.
+
+Extensible option types can be used for `enum` options that affects
+multiple modules, or as an alternative to related `enable` options.
+
+As an example, we will take the case of display managers. There is a
+central display manager module for generic display manager options and a
+module file per display manager backend (sddm, gdm \...).
+
+There are two approach to this module structure:
+
+-   Managing the display managers independently by adding an enable
+    option to every display manager module backend. (NixOS)
+
+-   Managing the display managers in the central module by adding an
+    option to select which display manager backend to use.
+
+Both approaches have problems.
+
+Making backends independent can quickly become hard to manage. For
+display managers, there can be only one enabled at a time, but the type
+system can not enforce this restriction as there is no relation between
+each backend `enable` option. As a result, this restriction has to be
+done explicitely by adding assertions in each display manager backend
+module.
+
+On the other hand, managing the display managers backends in the central
+module will require to change the central module option every time a new
+backend is added or removed.
+
+By using extensible option types, it is possible to create a placeholder
+option in the central module
+([Example: Extensible type placeholder in the service module](#ex-option-declaration-eot-service)),
+and to extend it in each backend module
+([Example: Extending `services.xserver.displayManager.enable` in the `gdm` module](#ex-option-declaration-eot-backend-gdm),
+[Example: Extending `services.xserver.displayManager.enable` in the `sddm` module](#ex-option-declaration-eot-backend-sddm)).
+
+As a result, `displayManager.enable` option values can be added without
+changing the main service module file and the type system automatically
+enforce that there can only be a single display manager enabled.
+
+::: {#ex-option-declaration-eot-service .example}
+::: {.title}
+**Example: Extensible type placeholder in the service module**
+:::
+```nix
+services.xserver.displayManager.enable = mkOption {
+  description = "Display manager to use";
+  type = with types; nullOr (enum [ ]);
+};
+```
+:::
+
+::: {#ex-option-declaration-eot-backend-gdm .example}
+::: {.title}
+**Example: Extending `services.xserver.displayManager.enable` in the `gdm` module**
+:::
+```nix
+services.xserver.displayManager.enable = mkOption {
+  type = with types; nullOr (enum [ "gdm" ]);
+};
+```
+:::
+
+::: {#ex-option-declaration-eot-backend-sddm .example}
+::: {.title}
+**Example: Extending `services.xserver.displayManager.enable` in the `sddm` module**
+:::
+```nix
+services.xserver.displayManager.enable = mkOption {
+  type = with types; nullOr (enum [ "sddm" ]);
+};
+```
+:::
+
+The placeholder declaration is a standard `mkOption` declaration, but it
+is important that extensible option declarations only use the `type`
+argument.
+
+Extensible option types work with any of the composed variants of `enum`
+such as `with types; nullOr (enum [ "foo" "bar" ])` or `with types;
+listOf (enum [ "foo" "bar" ])`.
diff --git a/nixpkgs/nixos/doc/manual/development/option-declarations.xml b/nixpkgs/nixos/doc/manual/development/option-declarations.xml
deleted file mode 100644
index 56ebf4816306..000000000000
--- a/nixpkgs/nixos/doc/manual/development/option-declarations.xml
+++ /dev/null
@@ -1,199 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-option-declarations">
- <title>Option Declarations</title>
-
- <para>
-  An option declaration specifies the name, type and description of a NixOS
-  configuration option. It is invalid to define an option that hasn’t been
-  declared in any module. An option declaration generally looks like this:
-<programlisting>
-options = {
-  <replaceable>name</replaceable> = mkOption {
-    type = <replaceable>type specification</replaceable>;
-    default = <replaceable>default value</replaceable>;
-    example = <replaceable>example value</replaceable>;
-    description = "<replaceable>Description for use in the NixOS manual.</replaceable>";
-  };
-};
-</programlisting>
-  The attribute names within the <replaceable>name</replaceable> attribute path
-  must be camel cased in general but should, as an exception, match the
-  <link
-xlink:href="https://nixos.org/nixpkgs/manual/#sec-package-naming">
-  package attribute name</link> when referencing a Nixpkgs package. For
-  example, the option <varname>services.nix-serve.bindAddress</varname>
-  references the <varname>nix-serve</varname> Nixpkgs package.
- </para>
-
- <para>
-  The function <varname>mkOption</varname> accepts the following arguments.
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>type</varname>
-    </term>
-    <listitem>
-     <para>
-      The type of the option (see <xref linkend='sec-option-types' />). It may
-      be omitted, but that’s not advisable since it may lead to errors that
-      are hard to diagnose.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>default</varname>
-    </term>
-    <listitem>
-     <para>
-      The default value used if no value is defined by any module. A default is
-      not required; but if a default is not given, then users of the module
-      will have to define the value of the option, otherwise an error will be
-      thrown.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>example</varname>
-    </term>
-    <listitem>
-     <para>
-      An example value that will be shown in the NixOS manual.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>description</varname>
-    </term>
-    <listitem>
-     <para>
-      A textual description of the option, in DocBook format, that will be
-      included in the NixOS manual.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </para>
-
- <section xml:id="sec-option-declarations-eot">
-  <title>Extensible Option Types</title>
-
-  <para>
-   Extensible option types is a feature that allow to extend certain types
-   declaration through multiple module files. This feature only work with a
-   restricted set of types, namely <literal>enum</literal> and
-   <literal>submodules</literal> and any composed forms of them.
-  </para>
-
-  <para>
-   Extensible option types can be used for <literal>enum</literal> options that
-   affects multiple modules, or as an alternative to related
-   <literal>enable</literal> options.
-  </para>
-
-  <para>
-   As an example, we will take the case of display managers. There is a central
-   display manager module for generic display manager options and a module file
-   per display manager backend (sddm, gdm ...).
-  </para>
-
-  <para>
-   There are two approach to this module structure:
-   <itemizedlist>
-    <listitem>
-     <para>
-      Managing the display managers independently by adding an enable option to
-      every display manager module backend. (NixOS)
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Managing the display managers in the central module by adding an option
-      to select which display manager backend to use.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
-
-  <para>
-   Both approaches have problems.
-  </para>
-
-  <para>
-   Making backends independent can quickly become hard to manage. For display
-   managers, there can be only one enabled at a time, but the type system can
-   not enforce this restriction as there is no relation between each backend
-   <literal>enable</literal> option. As a result, this restriction has to be
-   done explicitely by adding assertions in each display manager backend
-   module.
-  </para>
-
-  <para>
-   On the other hand, managing the display managers backends in the central
-   module will require to change the central module option every time a new
-   backend is added or removed.
-  </para>
-
-  <para>
-   By using extensible option types, it is possible to create a placeholder
-   option in the central module
-   (<xref linkend='ex-option-declaration-eot-service'
-      />), and to extend
-   it in each backend module
-   (<xref
-      linkend='ex-option-declaration-eot-backend-gdm' />,
-   <xref
-      linkend='ex-option-declaration-eot-backend-sddm' />).
-  </para>
-
-  <para>
-   As a result, <literal>displayManager.enable</literal> option values can be
-   added without changing the main service module file and the type system
-   automatically enforce that there can only be a single display manager
-   enabled.
-  </para>
-
-  <example xml:id='ex-option-declaration-eot-service'>
-   <title>Extensible type placeholder in the service module</title>
-<screen>
-services.xserver.displayManager.enable = mkOption {
-  description = "Display manager to use";
-  type = with types; nullOr (enum [ ]);
-};</screen>
-  </example>
-
-  <example xml:id='ex-option-declaration-eot-backend-gdm'>
-   <title>Extending <literal>services.xserver.displayManager.enable</literal> in the <literal>gdm</literal> module</title>
-<screen>
-services.xserver.displayManager.enable = mkOption {
-  type = with types; nullOr (enum [ "gdm" ]);
-};</screen>
-  </example>
-
-  <example xml:id='ex-option-declaration-eot-backend-sddm'>
-   <title>Extending <literal>services.xserver.displayManager.enable</literal> in the <literal>sddm</literal> module</title>
-<screen>
-services.xserver.displayManager.enable = mkOption {
-  type = with types; nullOr (enum [ "sddm" ]);
-};</screen>
-  </example>
-
-  <para>
-   The placeholder declaration is a standard <literal>mkOption</literal>
-   declaration, but it is important that extensible option declarations only
-   use the <literal>type</literal> argument.
-  </para>
-
-  <para>
-   Extensible option types work with any of the composed variants of
-   <literal>enum</literal> such as <literal>with types; nullOr (enum [ "foo"
-   "bar" ])</literal> or <literal>with types; listOf (enum [ "foo" "bar"
-   ])</literal>.
-  </para>
- </section>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/option-def.section.md b/nixpkgs/nixos/doc/manual/development/option-def.section.md
new file mode 100644
index 000000000000..91b24cd4a3a1
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/option-def.section.md
@@ -0,0 +1,91 @@
+# Option Definitions {#sec-option-definitions}
+
+Option definitions are generally straight-forward bindings of values to
+option names, like
+
+```nix
+config = {
+  services.httpd.enable = true;
+};
+```
+
+However, sometimes you need to wrap an option definition or set of
+option definitions in a *property* to achieve certain effects:
+
+## Delaying Conditionals {#sec-option-definitions-delaying-conditionals .unnumbered}
+
+If a set of option definitions is conditional on the value of another
+option, you may need to use `mkIf`. Consider, for instance:
+
+```nix
+config = if config.services.httpd.enable then {
+  environment.systemPackages = [ ... ];
+  ...
+} else {};
+```
+
+This definition will cause Nix to fail with an "infinite recursion"
+error. Why? Because the value of `config.services.httpd.enable` depends
+on the value being constructed here. After all, you could also write the
+clearly circular and contradictory:
+
+```nix
+config = if config.services.httpd.enable then {
+  services.httpd.enable = false;
+} else {
+  services.httpd.enable = true;
+};
+```
+
+The solution is to write:
+
+```nix
+config = mkIf config.services.httpd.enable {
+  environment.systemPackages = [ ... ];
+  ...
+};
+```
+
+The special function `mkIf` causes the evaluation of the conditional to
+be "pushed down" into the individual definitions, as if you had written:
+
+```nix
+config = {
+  environment.systemPackages = if config.services.httpd.enable then [ ... ] else [];
+  ...
+};
+```
+
+## Setting Priorities {#sec-option-definitions-setting-priorities .unnumbered}
+
+A module can override the definitions of an option in other modules by
+setting a *priority*. All option definitions that do not have the lowest
+priority value are discarded. By default, option definitions have
+priority 1000. You can specify an explicit priority by using
+`mkOverride`, e.g.
+
+```nix
+services.openssh.enable = mkOverride 10 false;
+```
+
+This definition causes all other definitions with priorities above 10 to
+be discarded. The function `mkForce` is equal to `mkOverride 50`.
+
+## Merging Configurations {#sec-option-definitions-merging .unnumbered}
+
+In conjunction with `mkIf`, it is sometimes useful for a module to
+return multiple sets of option definitions, to be merged together as if
+they were declared in separate modules. This can be done using
+`mkMerge`:
+
+```nix
+config = mkMerge
+  [ # Unconditional stuff.
+    { environment.systemPackages = [ ... ];
+    }
+    # Conditional stuff.
+    (mkIf config.services.bla.enable {
+      environment.systemPackages = [ ... ];
+    })
+  ];
+```
diff --git a/nixpkgs/nixos/doc/manual/development/option-def.xml b/nixpkgs/nixos/doc/manual/development/option-def.xml
deleted file mode 100644
index 50a705d0cb8e..000000000000
--- a/nixpkgs/nixos/doc/manual/development/option-def.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-option-definitions">
- <title>Option Definitions</title>
-
- <para>
-  Option definitions are generally straight-forward bindings of values to
-  option names, like
-<programlisting>
-config = {
-  services.httpd.enable = true;
-};
-</programlisting>
-  However, sometimes you need to wrap an option definition or set of option
-  definitions in a <emphasis>property</emphasis> to achieve certain effects:
- </para>
-
- <simplesect xml:id="sec-option-definitions-delaying-conditionals">
-  <title>Delaying Conditionals</title>
-  <para>
-   If a set of option definitions is conditional on the value of another
-   option, you may need to use <varname>mkIf</varname>. Consider, for instance:
-<programlisting>
-config = if config.services.httpd.enable then {
-  environment.systemPackages = [ <replaceable>...</replaceable> ];
-  <replaceable>...</replaceable>
-} else {};
-</programlisting>
-   This definition will cause Nix to fail with an “infinite recursion”
-   error. Why? Because the value of
-   <option>config.services.httpd.enable</option> depends on the value being
-   constructed here. After all, you could also write the clearly circular and
-   contradictory:
-<programlisting>
-config = if config.services.httpd.enable then {
-  services.httpd.enable = false;
-} else {
-  services.httpd.enable = true;
-};
-</programlisting>
-   The solution is to write:
-<programlisting>
-config = mkIf config.services.httpd.enable {
-  environment.systemPackages = [ <replaceable>...</replaceable> ];
-  <replaceable>...</replaceable>
-};
-</programlisting>
-   The special function <varname>mkIf</varname> causes the evaluation of the
-   conditional to be “pushed down” into the individual definitions, as if
-   you had written:
-<programlisting>
-config = {
-  environment.systemPackages = if config.services.httpd.enable then [ <replaceable>...</replaceable> ] else [];
-  <replaceable>...</replaceable>
-};
-</programlisting>
-  </para>
- </simplesect>
-
- <simplesect xml:id="sec-option-definitions-setting-priorities">
-  <title>Setting Priorities</title>
-  <para>
-   A module can override the definitions of an option in other modules by
-   setting a <emphasis>priority</emphasis>. All option definitions that do not
-   have the lowest priority value are discarded. By default, option definitions
-   have priority 1000. You can specify an explicit priority by using
-   <varname>mkOverride</varname>, e.g.
-<programlisting>
-services.openssh.enable = mkOverride 10 false;
-</programlisting>
-   This definition causes all other definitions with priorities above 10 to be
-   discarded. The function <varname>mkForce</varname> is equal to
-   <varname>mkOverride 50</varname>.
-  </para>
- </simplesect>
-
- <simplesect xml:id="sec-option-definitions-merging">
-  <title>Merging Configurations</title>
-  <para>
-   In conjunction with <literal>mkIf</literal>, it is sometimes useful for a
-   module to return multiple sets of option definitions, to be merged together
-   as if they were declared in separate modules. This can be done using
-   <varname>mkMerge</varname>:
-<programlisting>
-config = mkMerge
-  [ # Unconditional stuff.
-    { environment.systemPackages = [ <replaceable>...</replaceable> ];
-    }
-    # Conditional stuff.
-    (mkIf config.services.bla.enable {
-      environment.systemPackages = [ <replaceable>...</replaceable> ];
-    })
-  ];
-</programlisting>
-  </para>
- </simplesect>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/option-types.section.md b/nixpkgs/nixos/doc/manual/development/option-types.section.md
new file mode 100644
index 000000000000..ed557206659f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/option-types.section.md
@@ -0,0 +1,558 @@
+# Options Types {#sec-option-types}
+
+Option types are a way to put constraints on the values a module option
+can take. Types are also responsible of how values are merged in case of
+multiple value definitions.
+
+## Basic Types {#sec-option-types-basic}
+
+Basic types are the simplest available types in the module system. Basic
+types include multiple string types that mainly differ in how definition
+merging is handled.
+
+`types.bool`
+
+:   A boolean, its values can be `true` or `false`.
+
+`types.path`
+
+:   A filesystem path, defined as anything that when coerced to a string
+    starts with a slash. Even if derivations can be considered as path,
+    the more specific `types.package` should be preferred.
+
+`types.package`
+
+:   A derivation or a store path.
+
+`types.anything`
+
+:   A type that accepts any value and recursively merges attribute sets
+    together. This type is recommended when the option type is unknown.
+
+    ::: {#ex-types-anything .example}
+    ::: {.title}
+    **Example: `types.anything` Example**
+    :::
+    Two definitions of this type like
+
+    ```nix
+    {
+      str = lib.mkDefault "foo";
+      pkg.hello = pkgs.hello;
+      fun.fun = x: x + 1;
+    }
+    ```
+
+    ```nix
+    {
+      str = lib.mkIf true "bar";
+      pkg.gcc = pkgs.gcc;
+      fun.fun = lib.mkForce (x: x + 2);
+    }
+    ```
+
+    will get merged to
+
+    ```nix
+    {
+      str = "bar";
+      pkg.gcc = pkgs.gcc;
+      pkg.hello = pkgs.hello;
+      fun.fun = x: x + 2;
+    }
+    ```
+    :::
+
+`types.attrs`
+
+:   A free-form attribute set.
+
+    ::: {.warning}
+    This type will be deprecated in the future because it doesn\'t
+    recurse into attribute sets, silently drops earlier attribute
+    definitions, and doesn\'t discharge `lib.mkDefault`, `lib.mkIf`
+    and co. For allowing arbitrary attribute sets, prefer
+    `types.attrsOf types.anything` instead which doesn\'t have these
+    problems.
+    :::
+
+Integer-related types:
+
+`types.int`
+
+:   A signed integer.
+
+`types.ints.{s8, s16, s32}`
+
+:   Signed integers with a fixed length (8, 16 or 32 bits). They go from
+    −2^n/2 to
+    2^n/2−1 respectively (e.g. `−128` to
+    `127` for 8 bits).
+
+`types.ints.unsigned`
+
+:   An unsigned integer (that is >= 0).
+
+`types.ints.{u8, u16, u32}`
+
+:   Unsigned integers with a fixed length (8, 16 or 32 bits). They go
+    from 0 to 2^n−1 respectively (e.g. `0`
+    to `255` for 8 bits).
+
+`types.ints.positive`
+
+:   A positive integer (that is > 0).
+
+`types.port`
+
+:   A port number. This type is an alias to
+    `types.ints.u16`.
+
+String-related types:
+
+`types.str`
+
+:   A string. Multiple definitions cannot be merged.
+
+`types.lines`
+
+:   A string. Multiple definitions are concatenated with a new line
+    `"\n"`.
+
+`types.commas`
+
+:   A string. Multiple definitions are concatenated with a comma `","`.
+
+`types.envVar`
+
+:   A string. Multiple definitions are concatenated with a collon `":"`.
+
+`types.strMatching`
+
+:   A string matching a specific regular expression. Multiple
+    definitions cannot be merged. The regular expression is processed
+    using `builtins.match`.
+
+## Value Types {#sec-option-types-value}
+
+Value types are types that take a value parameter.
+
+`types.enum` *`l`*
+
+:   One element of the list *`l`*, e.g. `types.enum [ "left" "right" ]`.
+    Multiple definitions cannot be merged.
+
+`types.separatedString` *`sep`*
+
+:   A string with a custom separator *`sep`*, e.g.
+    `types.separatedString "|"`.
+
+`types.ints.between` *`lowest highest`*
+
+:   An integer between *`lowest`* and *`highest`* (both inclusive). Useful
+    for creating types like `types.port`.
+
+`types.submodule` *`o`*
+
+:   A set of sub options *`o`*. *`o`* can be an attribute set, a function
+    returning an attribute set, or a path to a file containing such a
+    value. Submodules are used in composed types to create modular
+    options. This is equivalent to
+    `types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }`.
+    Submodules are detailed in [Submodule](#section-option-types-submodule).
+
+`types.submoduleWith` { *`modules`*, *`specialArgs`* ? {}, *`shorthandOnlyDefinesConfig`* ? false }
+
+:   Like `types.submodule`, but more flexible and with better defaults.
+    It has parameters
+
+    -   *`modules`* A list of modules to use by default for this
+        submodule type. This gets combined with all option definitions
+        to build the final list of modules that will be included.
+
+        ::: {.note}
+        Only options defined with this argument are included in rendered
+        documentation.
+        :::
+
+    -   *`specialArgs`* An attribute set of extra arguments to be passed
+        to the module functions. The option `_module.args` should be
+        used instead for most arguments since it allows overriding.
+        *`specialArgs`* should only be used for arguments that can\'t go
+        through the module fixed-point, because of infinite recursion or
+        other problems. An example is overriding the `lib` argument,
+        because `lib` itself is used to define `_module.args`, which
+        makes using `_module.args` to define it impossible.
+
+    -   *`shorthandOnlyDefinesConfig`* Whether definitions of this type
+        should default to the `config` section of a module (see
+        [Example: Structure of NixOS Modules](#ex-module-syntax))
+        if it is an attribute set. Enabling this only has a benefit
+        when the submodule defines an option named `config` or `options`.
+        In such a case it would allow the option to be set with
+        `the-submodule.config = "value"` instead of requiring
+        `the-submodule.config.config = "value"`. This is because
+        only when modules *don\'t* set the `config` or `options`
+        keys, all keys are interpreted as option definitions in the
+        `config` section. Enabling this option implicitly puts all
+        attributes in the `config` section.
+
+        With this option enabled, defining a non-`config` section
+        requires using a function:
+        `the-submodule = { ... }: { options = { ... }; }`.
+
+## Composed Types {#sec-option-types-composed}
+
+Composed types are types that take a type as parameter. `listOf
+   int` and `either int str` are examples of composed types.
+
+`types.listOf` *`t`*
+
+:   A list of *`t`* type, e.g. `types.listOf
+          int`. Multiple definitions are merged with list concatenation.
+
+`types.attrsOf` *`t`*
+
+:   An attribute set of where all the values are of *`t`* type. Multiple
+    definitions result in the joined attribute set.
+
+    ::: {.note}
+    This type is *strict* in its values, which in turn means attributes
+    cannot depend on other attributes. See `
+           types.lazyAttrsOf` for a lazy version.
+    :::
+
+`types.lazyAttrsOf` *`t`*
+
+:   An attribute set of where all the values are of *`t`* type. Multiple
+    definitions result in the joined attribute set. This is the lazy
+    version of `types.attrsOf
+          `, allowing attributes to depend on each other.
+
+    ::: {.warning}
+    This version does not fully support conditional definitions! With an
+    option `foo` of this type and a definition
+    `foo.attr = lib.mkIf false 10`, evaluating `foo ? attr` will return
+    `true` even though it should be false. Accessing the value will then
+    throw an error. For types *`t`* that have an `emptyValue` defined,
+    that value will be returned instead of throwing an error. So if the
+    type of `foo.attr` was `lazyAttrsOf (nullOr int)`, `null` would be
+    returned instead for the same `mkIf false` definition.
+    :::
+
+`types.nullOr` *`t`*
+
+:   `null` or type *`t`*. Multiple definitions are merged according to
+    type *`t`*.
+
+`types.uniq` *`t`*
+
+:   Ensures that type *`t`* cannot be merged. It is used to ensure option
+    definitions are declared only once.
+
+`types.either` *`t1 t2`*
+
+:   Type *`t1`* or type *`t2`*, e.g. `with types; either int str`.
+    Multiple definitions cannot be merged.
+
+`types.oneOf` \[ *`t1 t2`* \... \]
+
+:   Type *`t1`* or type *`t2`* and so forth, e.g.
+    `with types; oneOf [ int str bool ]`. Multiple definitions cannot be
+    merged.
+
+`types.coercedTo` *`from f to`*
+
+:   Type *`to`* or type *`from`* which will be coerced to type *`to`* using
+    function *`f`* which takes an argument of type *`from`* and return a
+    value of type *`to`*. Can be used to preserve backwards compatibility
+    of an option if its type was changed.
+
+## Submodule {#section-option-types-submodule}
+
+`submodule` is a very powerful type that defines a set of sub-options
+that are handled like a separate module.
+
+It takes a parameter *`o`*, that should be a set, or a function returning
+a set with an `options` key defining the sub-options. Submodule option
+definitions are type-checked accordingly to the `options` declarations.
+Of course, you can nest submodule option definitons for even higher
+modularity.
+
+The option set can be defined directly
+([Example: Directly defined submodule](#ex-submodule-direct)) or as reference
+([Example: Submodule defined as a reference](#ex-submodule-reference)).
+
+::: {#ex-submodule-direct .example}
+::: {.title}
+**Example: Directly defined submodule**
+:::
+```nix
+options.mod = mkOption {
+  description = "submodule example";
+  type = with types; submodule {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = str;
+      };
+    };
+  };
+};
+```
+:::
+
+::: {#ex-submodule-reference .example}
+::: {.title}
+**Example: Submodule defined as a reference**
+:::
+```nix
+let
+  modOptions = {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = int;
+      };
+    };
+  };
+in
+options.mod = mkOption {
+  description = "submodule example";
+  type = with types; submodule modOptions;
+};
+```
+:::
+
+The `submodule` type is especially interesting when used with composed
+types like `attrsOf` or `listOf`. When composed with `listOf`
+([Example: Declaration of a list of submodules](#ex-submodule-listof-declaration)), `submodule` allows
+multiple definitions of the submodule option set
+([Example: Definition of a list of submodules](#ex-submodule-listof-definition)).
+
+::: {#ex-submodule-listof-declaration .example}
+::: {.title}
+**Example: Declaration of a list of submodules**
+:::
+```nix
+options.mod = mkOption {
+  description = "submodule example";
+  type = with types; listOf (submodule {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = str;
+      };
+    };
+  });
+};
+```
+:::
+
+::: {#ex-submodule-listof-definition .example}
+::: {.title}
+**Example: Definition of a list of submodules**
+:::
+```nix
+config.mod = [
+  { foo = 1; bar = "one"; }
+  { foo = 2; bar = "two"; }
+];
+```
+:::
+
+When composed with `attrsOf`
+([Example: Declaration of attribute sets of submodules](#ex-submodule-attrsof-declaration)), `submodule` allows
+multiple named definitions of the submodule option set
+([Example: Definition of attribute sets of submodules](#ex-submodule-attrsof-definition)).
+
+::: {#ex-submodule-attrsof-declaration .example}
+::: {.title}
+**Example: Declaration of attribute sets of submodules**
+:::
+```nix
+options.mod = mkOption {
+  description = "submodule example";
+  type = with types; attrsOf (submodule {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = str;
+      };
+    };
+  });
+};
+```
+:::
+
+::: {#ex-submodule-attrsof-definition .example}
+::: {.title}
+**Example: Definition of attribute sets of submodules**
+:::
+```nix
+config.mod.one = { foo = 1; bar = "one"; };
+config.mod.two = { foo = 2; bar = "two"; };
+```
+:::
+
+## Extending types {#sec-option-types-extending}
+
+Types are mainly characterized by their `check` and `merge` functions.
+
+`check`
+
+:   The function to type check the value. Takes a value as parameter and
+    return a boolean. It is possible to extend a type check with the
+    `addCheck` function ([Example: Adding a type check](#ex-extending-type-check-1)),
+    or to fully override the check function
+    ([Example: Overriding a type check](#ex-extending-type-check-2)).
+
+    ::: {#ex-extending-type-check-1 .example}
+    ::: {.title}
+    **Example: Adding a type check**
+    :::
+    ```nix
+    byte = mkOption {
+      description = "An integer between 0 and 255.";
+      type = types.addCheck types.int (x: x >= 0 && x <= 255);
+    };
+    ```
+    :::
+
+    ::: {#ex-extending-type-check-2 .example}
+    ::: {.title}
+    **Example: Overriding a type check**
+    :::
+    ```nix
+    nixThings = mkOption {
+      description = "words that start with 'nix'";
+      type = types.str // {
+        check = (x: lib.hasPrefix "nix" x)
+      };
+    };
+    ```
+    :::
+
+`merge`
+
+:   Function to merge the options values when multiple values are set.
+    The function takes two parameters, `loc` the option path as a list
+    of strings, and `defs` the list of defined values as a list. It is
+    possible to override a type merge function for custom needs.
+
+## Custom Types {#sec-option-types-custom}
+
+Custom types can be created with the `mkOptionType` function. As type
+creation includes some more complex topics such as submodule handling,
+it is recommended to get familiar with `types.nix` code before creating
+a new type.
+
+The only required parameter is `name`.
+
+`name`
+
+:   A string representation of the type function name.
+
+`definition`
+
+:   Description of the type used in documentation. Give information of
+    the type and any of its arguments.
+
+`check`
+
+:   A function to type check the definition value. Takes the definition
+    value as a parameter and returns a boolean indicating the type check
+    result, `true` for success and `false` for failure.
+
+`merge`
+
+:   A function to merge multiple definitions values. Takes two
+    parameters:
+
+    *`loc`*
+
+    :   The option path as a list of strings, e.g. `["boot" "loader
+                 "grub" "enable"]`.
+
+    *`defs`*
+
+    :   The list of sets of defined `value` and `file` where the value
+        was defined, e.g. `[ {
+                 file = "/foo.nix"; value = 1; } { file = "/bar.nix"; value = 2 }
+                 ]`. The `merge` function should return the merged value
+        or throw an error in case the values are impossible or not meant
+        to be merged.
+
+`getSubOptions`
+
+:   For composed types that can take a submodule as type parameter, this
+    function generate sub-options documentation. It takes the current
+    option prefix as a list and return the set of sub-options. Usually
+    defined in a recursive manner by adding a term to the prefix, e.g.
+    `prefix:
+          elemType.getSubOptions (prefix ++
+          ["prefix"])` where *`"prefix"`* is the newly added prefix.
+
+`getSubModules`
+
+:   For composed types that can take a submodule as type parameter, this
+    function should return the type parameters submodules. If the type
+    parameter is called `elemType`, the function should just recursively
+    look into submodules by returning `elemType.getSubModules;`.
+
+`substSubModules`
+
+:   For composed types that can take a submodule as type parameter, this
+    function can be used to substitute the parameter of a submodule
+    type. It takes a module as parameter and return the type with the
+    submodule options substituted. It is usually defined as a type
+    function call with a recursive call to `substSubModules`, e.g for a
+    type `composedType` that take an `elemtype` type parameter, this
+    function should be defined as `m:
+          composedType (elemType.substSubModules m)`.
+
+`typeMerge`
+
+:   A function to merge multiple type declarations. Takes the type to
+    merge `functor` as parameter. A `null` return value means that type
+    cannot be merged.
+
+    *`f`*
+
+    :   The type to merge `functor`.
+
+    Note: There is a generic `defaultTypeMerge` that work with most of
+    value and composed types.
+
+`functor`
+
+:   An attribute set representing the type. It is used for type
+    operations and has the following keys:
+
+    `type`
+
+    :   The type function.
+
+    `wrapped`
+
+    :   Holds the type parameter for composed types.
+
+    `payload`
+
+    :   Holds the value parameter for value types. The types that have a
+        `payload` are the `enum`, `separatedString` and `submodule`
+        types.
+
+    `binOp`
+
+    :   A binary operation that can merge the payloads of two same
+        types. Defined as a function that take two payloads as
+        parameters and return the payloads merged.
diff --git a/nixpkgs/nixos/doc/manual/development/option-types.xml b/nixpkgs/nixos/doc/manual/development/option-types.xml
deleted file mode 100644
index 3d2191e2f3f3..000000000000
--- a/nixpkgs/nixos/doc/manual/development/option-types.xml
+++ /dev/null
@@ -1,914 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-option-types">
- <title>Options Types</title>
-
- <para>
-  Option types are a way to put constraints on the values a module option can
-  take. Types are also responsible of how values are merged in case of multiple
-  value definitions.
- </para>
-
- <section xml:id="sec-option-types-basic">
-  <title>Basic Types</title>
-
-  <para>
-   Basic types are the simplest available types in the module system. Basic
-   types include multiple string types that mainly differ in how definition
-   merging is handled.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>types.bool</varname>
-    </term>
-    <listitem>
-     <para>
-      A boolean, its values can be <literal>true</literal> or
-      <literal>false</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.path</varname>
-    </term>
-    <listitem>
-     <para>
-      A filesystem path, defined as anything that when coerced to a string
-      starts with a slash. Even if derivations can be considered as path, the
-      more specific <literal>types.package</literal> should be preferred.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.package</varname>
-    </term>
-    <listitem>
-     <para>
-      A derivation or a store path.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.anything</varname>
-    </term>
-    <listitem>
-     <para>
-      A type that accepts any value and recursively merges attribute sets together.
-      This type is recommended when the option type is unknown.
-      <example xml:id="ex-types-anything">
-       <title><literal>types.anything</literal> Example</title>
-       <para>
-        Two definitions of this type like
-<programlisting>
-{
-  str = lib.mkDefault "foo";
-  pkg.hello = pkgs.hello;
-  fun.fun = x: x + 1;
-}
-</programlisting>
-<programlisting>
-{
-  str = lib.mkIf true "bar";
-  pkg.gcc = pkgs.gcc;
-  fun.fun = lib.mkForce (x: x + 2);
-}
-</programlisting>
-        will get merged to
-<programlisting>
-{
-  str = "bar";
-  pkg.gcc = pkgs.gcc;
-  pkg.hello = pkgs.hello;
-  fun.fun = x: x + 2;
-}
-</programlisting>
-       </para>
-      </example>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.attrs</varname>
-    </term>
-    <listitem>
-     <para>
-      A free-form attribute set.
-      <warning><para>
-       This type will be deprecated in the future because it doesn't recurse
-       into attribute sets, silently drops earlier attribute definitions, and
-       doesn't discharge <literal>lib.mkDefault</literal>, <literal>lib.mkIf
-       </literal> and co. For allowing arbitrary attribute sets, prefer
-       <literal>types.attrsOf types.anything</literal> instead which doesn't
-       have these problems.
-      </para></warning>
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
-
-  <para>
-   Integer-related types:
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>types.int</varname>
-    </term>
-    <listitem>
-     <para>
-      A signed integer.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.ints.{s8, s16, s32}</varname>
-    </term>
-    <listitem>
-     <para>
-      Signed integers with a fixed length (8, 16 or 32 bits). They go from
-      <inlineequation><mathphrase>−2<superscript>n</superscript>/2</mathphrase>
-      </inlineequation> to <inlineequation>
-      <mathphrase>2<superscript>n</superscript>/2−1</mathphrase>
-      </inlineequation> respectively (e.g. <literal>−128</literal> to
-      <literal>127</literal> for 8 bits).
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.ints.unsigned</varname>
-    </term>
-    <listitem>
-     <para>
-      An unsigned integer (that is >= 0).
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id='types.ints.ux'>
-    <term>
-     <varname>types.ints.{u8, u16, u32}</varname>
-    </term>
-    <listitem>
-     <para>
-      Unsigned integers with a fixed length (8, 16 or 32 bits). They go from
-      <inlineequation><mathphrase>0</mathphrase></inlineequation> to
-      <inlineequation>
-      <mathphrase>2<superscript>n</superscript>−1</mathphrase>
-      </inlineequation> respectively (e.g. <literal>0</literal> to
-      <literal>255</literal> for 8 bits).
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.ints.positive</varname>
-    </term>
-    <listitem>
-     <para>
-      A positive integer (that is > 0).
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.port</varname>
-    </term>
-    <listitem>
-     <para>
-      A port number. This type is an alias to
-      <link linkend='types.ints.ux'><varname>types.ints.u16</varname></link>.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
-
-  <para>
-   String-related types:
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>types.str</varname>
-    </term>
-    <listitem>
-     <para>
-      A string. Multiple definitions cannot be merged.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.lines</varname>
-    </term>
-    <listitem>
-     <para>
-      A string. Multiple definitions are concatenated with a new line
-      <literal>"\n"</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.commas</varname>
-    </term>
-    <listitem>
-     <para>
-      A string. Multiple definitions are concatenated with a comma
-      <literal>","</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.envVar</varname>
-    </term>
-    <listitem>
-     <para>
-      A string. Multiple definitions are concatenated with a collon
-      <literal>":"</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.strMatching</varname>
-    </term>
-    <listitem>
-     <para>
-      A string matching a specific regular expression. Multiple definitions
-      cannot be merged. The regular expression is processed using
-      <literal>builtins.match</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
-
- <section xml:id="sec-option-types-value">
-  <title>Value Types</title>
-
-  <para>
-   Value types are types that take a value parameter.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>types.enum</varname> <replaceable>l</replaceable>
-    </term>
-    <listitem>
-     <para>
-      One element of the list <replaceable>l</replaceable>, e.g.
-      <literal>types.enum [ "left" "right" ]</literal>. Multiple definitions
-      cannot be merged.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.separatedString</varname> <replaceable>sep</replaceable>
-    </term>
-    <listitem>
-     <para>
-      A string with a custom separator <replaceable>sep</replaceable>, e.g.
-      <literal>types.separatedString "|"</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.ints.between</varname> <replaceable>lowest</replaceable> <replaceable>highest</replaceable>
-    </term>
-    <listitem>
-     <para>
-      An integer between <replaceable>lowest</replaceable> and
-      <replaceable>highest</replaceable> (both inclusive). Useful for creating
-      types like <literal>types.port</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.submodule</varname> <replaceable>o</replaceable>
-    </term>
-    <listitem>
-     <para>
-      A set of sub options <replaceable>o</replaceable>.
-      <replaceable>o</replaceable> can be an attribute set, a function
-      returning an attribute set, or a path to a file containing such a value. Submodules are used in
-      composed types to create modular options. This is equivalent to
-      <literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
-      Submodules are detailed in
-      <xref
-          linkend='section-option-types-submodule' />.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-     <term>
-       <varname>types.submoduleWith</varname> {
-        <replaceable>modules</replaceable>,
-        <replaceable>specialArgs</replaceable> ? {},
-        <replaceable>shorthandOnlyDefinesConfig</replaceable> ? false }
-     </term>
-     <listitem>
-       <para>
-         Like <varname>types.submodule</varname>, but more flexible and with better defaults.
-         It has parameters
-         <itemizedlist>
-           <listitem><para>
-             <replaceable>modules</replaceable>
-             A list of modules to use by default for this submodule type. This gets combined
-             with all option definitions to build the final list of modules that will be included.
-             <note><para>
-               Only options defined with this argument are included in rendered documentation.
-             </para></note>
-           </para></listitem>
-           <listitem><para>
-             <replaceable>specialArgs</replaceable>
-             An attribute set of extra arguments to be passed to the module functions.
-             The option <literal>_module.args</literal> should be used instead
-             for most arguments since it allows overriding. <replaceable>specialArgs</replaceable> should only be
-             used for arguments that can&apos;t go through the module fixed-point, because of
-             infinite recursion or other problems. An example is overriding the
-             <varname>lib</varname> argument, because <varname>lib</varname> itself is used
-             to define <literal>_module.args</literal>, which makes using
-             <literal>_module.args</literal> to define it impossible.
-           </para></listitem>
-           <listitem><para>
-             <replaceable>shorthandOnlyDefinesConfig</replaceable>
-             Whether definitions of this type should default to the <literal>config</literal>
-             section of a module (see <xref linkend='ex-module-syntax'/>) if it is an attribute
-             set. Enabling this only has a benefit when the submodule defines an option named
-             <literal>config</literal> or <literal>options</literal>. In such a case it would
-             allow the option to be set with <literal>the-submodule.config = "value"</literal>
-             instead of requiring <literal>the-submodule.config.config = "value"</literal>.
-             This is because only when modules <emphasis>don&apos;t</emphasis> set the
-             <literal>config</literal> or <literal>options</literal> keys, all keys are interpreted
-             as option definitions in the <literal>config</literal> section. Enabling this option
-             implicitly puts all attributes in the <literal>config</literal> section.
-           </para>
-           <para>
-             With this option enabled, defining a non-<literal>config</literal> section requires
-             using a function: <literal>the-submodule = { ... }: { options = { ... }; }</literal>.
-           </para></listitem>
-         </itemizedlist>
-       </para>
-     </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
-
- <section xml:id="sec-option-types-composed">
-  <title>Composed Types</title>
-
-  <para>
-   Composed types are types that take a type as parameter. <literal>listOf
-   int</literal> and <literal>either int str</literal> are examples of composed
-   types.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>types.listOf</varname> <replaceable>t</replaceable>
-    </term>
-    <listitem>
-     <para>
-      A list of <replaceable>t</replaceable> type, e.g. <literal>types.listOf
-      int</literal>. Multiple definitions are merged with list concatenation.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.attrsOf</varname> <replaceable>t</replaceable>
-    </term>
-    <listitem>
-     <para>
-      An attribute set of where all the values are of
-      <replaceable>t</replaceable> type. Multiple definitions result in the
-      joined attribute set.
-      <note><para>
-       This type is <emphasis>strict</emphasis> in its values, which in turn
-       means attributes cannot depend on other attributes. See <varname>
-       types.lazyAttrsOf</varname> for a lazy version.
-      </para></note>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.lazyAttrsOf</varname> <replaceable>t</replaceable>
-    </term>
-    <listitem>
-     <para>
-      An attribute set of where all the values are of
-      <replaceable>t</replaceable> type. Multiple definitions result in the
-      joined attribute set. This is the lazy version of <varname>types.attrsOf
-      </varname>, allowing attributes to depend on each other.
-      <warning><para>
-       This version does not fully support conditional definitions! With an
-       option <varname>foo</varname> of this type and a definition
-       <literal>foo.attr = lib.mkIf false 10</literal>, evaluating
-       <literal>foo ? attr</literal> will return <literal>true</literal>
-       even though it should be false. Accessing the value will then throw
-       an error. For types <replaceable>t</replaceable> that have an
-       <literal>emptyValue</literal> defined, that value will be returned
-       instead of throwing an error. So if the type of <literal>foo.attr</literal>
-       was <literal>lazyAttrsOf (nullOr int)</literal>, <literal>null</literal>
-       would be returned instead for the same <literal>mkIf false</literal> definition.
-      </para></warning>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.nullOr</varname> <replaceable>t</replaceable>
-    </term>
-    <listitem>
-     <para>
-      <literal>null</literal> or type <replaceable>t</replaceable>. Multiple
-      definitions are merged according to type <replaceable>t</replaceable>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.uniq</varname> <replaceable>t</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Ensures that type <replaceable>t</replaceable> cannot be merged. It is
-      used to ensure option definitions are declared only once.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.either</varname> <replaceable>t1</replaceable> <replaceable>t2</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Type <replaceable>t1</replaceable> or type <replaceable>t2</replaceable>,
-      e.g. <literal>with types; either int str</literal>. Multiple definitions
-      cannot be merged.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.oneOf</varname> [ <replaceable>t1</replaceable> <replaceable>t2</replaceable> ... ]
-    </term>
-    <listitem>
-     <para>
-      Type <replaceable>t1</replaceable> or type <replaceable>t2</replaceable> and so forth,
-      e.g. <literal>with types; oneOf [ int str bool ]</literal>. Multiple definitions
-      cannot be merged.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>types.coercedTo</varname> <replaceable>from</replaceable> <replaceable>f</replaceable> <replaceable>to</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Type <replaceable>to</replaceable> or type
-      <replaceable>from</replaceable> which will be coerced to type
-      <replaceable>to</replaceable> using function <replaceable>f</replaceable>
-      which takes an argument of type <replaceable>from</replaceable> and
-      return a value of type <replaceable>to</replaceable>. Can be used to
-      preserve backwards compatibility of an option if its type was changed.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
-
- <section xml:id='section-option-types-submodule'>
-  <title>Submodule</title>
-
-  <para>
-   <literal>submodule</literal> is a very powerful type that defines a set of
-   sub-options that are handled like a separate module.
-  </para>
-
-  <para>
-   It takes a parameter <replaceable>o</replaceable>, that should be a set, or
-   a function returning a set with an <literal>options</literal> key defining
-   the sub-options. Submodule option definitions are type-checked accordingly
-   to the <literal>options</literal> declarations. Of course, you can nest
-   submodule option definitons for even higher modularity.
-  </para>
-
-  <para>
-   The option set can be defined directly
-   (<xref linkend='ex-submodule-direct' />) or as reference
-   (<xref linkend='ex-submodule-reference' />).
-  </para>
-
-  <example xml:id='ex-submodule-direct'>
-   <title>Directly defined submodule</title>
-<screen>
-options.mod = mkOption {
-  description = "submodule example";
-  type = with types; submodule {
-    options = {
-      foo = mkOption {
-        type = int;
-      };
-      bar = mkOption {
-        type = str;
-      };
-    };
-  };
-};</screen>
-  </example>
-
-  <example xml:id='ex-submodule-reference'>
-   <title>Submodule defined as a reference</title>
-<screen>
-let
-  modOptions = {
-    options = {
-      foo = mkOption {
-        type = int;
-      };
-      bar = mkOption {
-        type = int;
-      };
-    };
-  };
-in
-options.mod = mkOption {
-  description = "submodule example";
-  type = with types; submodule modOptions;
-};</screen>
-  </example>
-
-  <para>
-   The <literal>submodule</literal> type is especially interesting when used
-   with composed types like <literal>attrsOf</literal> or
-   <literal>listOf</literal>. When composed with <literal>listOf</literal>
-   (<xref linkend='ex-submodule-listof-declaration' />),
-   <literal>submodule</literal> allows multiple definitions of the submodule
-   option set (<xref linkend='ex-submodule-listof-definition' />).
-  </para>
-
-  <example xml:id='ex-submodule-listof-declaration'>
-   <title>Declaration of a list of submodules</title>
-<screen>
-options.mod = mkOption {
-  description = "submodule example";
-  type = with types; listOf (submodule {
-    options = {
-      foo = mkOption {
-        type = int;
-      };
-      bar = mkOption {
-        type = str;
-      };
-    };
-  });
-};</screen>
-  </example>
-
-  <example xml:id='ex-submodule-listof-definition'>
-   <title>Definition of a list of submodules</title>
-<screen>
-config.mod = [
-  { foo = 1; bar = "one"; }
-  { foo = 2; bar = "two"; }
-];</screen>
-  </example>
-
-  <para>
-   When composed with <literal>attrsOf</literal>
-   (<xref linkend='ex-submodule-attrsof-declaration' />),
-   <literal>submodule</literal> allows multiple named definitions of the
-   submodule option set (<xref linkend='ex-submodule-attrsof-definition' />).
-  </para>
-
-  <example xml:id='ex-submodule-attrsof-declaration'>
-   <title>Declaration of attribute sets of submodules</title>
-<screen>
-options.mod = mkOption {
-  description = "submodule example";
-  type = with types; attrsOf (submodule {
-    options = {
-      foo = mkOption {
-        type = int;
-      };
-      bar = mkOption {
-        type = str;
-      };
-    };
-  });
-};</screen>
-  </example>
-
-  <example xml:id='ex-submodule-attrsof-definition'>
-   <title>Declaration of attribute sets of submodules</title>
-<screen>
-config.mod.one = { foo = 1; bar = "one"; };
-config.mod.two = { foo = 2; bar = "two"; };</screen>
-  </example>
- </section>
-
- <section xml:id="sec-option-types-extending">
-  <title>Extending types</title>
-
-  <para>
-   Types are mainly characterized by their <literal>check</literal> and
-   <literal>merge</literal> functions.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>check</varname>
-    </term>
-    <listitem>
-     <para>
-      The function to type check the value. Takes a value as parameter and
-      return a boolean. It is possible to extend a type check with the
-      <literal>addCheck</literal> function
-      (<xref
-          linkend='ex-extending-type-check-1' />), or to fully
-      override the check function
-      (<xref linkend='ex-extending-type-check-2' />).
-     </para>
-     <example xml:id='ex-extending-type-check-1'>
-      <title>Adding a type check</title>
-<screen>
-byte = mkOption {
-  description = "An integer between 0 and 255.";
-  type = types.addCheck types.int (x: x &gt;= 0 &amp;&amp; x &lt;= 255);
-};</screen>
-     </example>
-     <example xml:id='ex-extending-type-check-2'>
-      <title>Overriding a type check</title>
-<screen>
-nixThings = mkOption {
-  description = "words that start with 'nix'";
-  type = types.str // {
-    check = (x: lib.hasPrefix "nix" x)
-  };
-};</screen>
-     </example>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>merge</varname>
-    </term>
-    <listitem>
-     <para>
-      Function to merge the options values when multiple values are set. The
-      function takes two parameters, <literal>loc</literal> the option path as
-      a list of strings, and <literal>defs</literal> the list of defined values
-      as a list. It is possible to override a type merge function for custom
-      needs.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
-
- <section xml:id="sec-option-types-custom">
-  <title>Custom Types</title>
-
-  <para>
-   Custom types can be created with the <literal>mkOptionType</literal>
-   function. As type creation includes some more complex topics such as
-   submodule handling, it is recommended to get familiar with
-   <filename
-  xlink:href="https://github.com/NixOS/nixpkgs/blob/master/lib/types.nix">types.nix</filename>
-   code before creating a new type.
-  </para>
-
-  <para>
-   The only required parameter is <literal>name</literal>.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>name</varname>
-    </term>
-    <listitem>
-     <para>
-      A string representation of the type function name.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>definition</varname>
-    </term>
-    <listitem>
-     <para>
-      Description of the type used in documentation. Give information of the
-      type and any of its arguments.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>check</varname>
-    </term>
-    <listitem>
-     <para>
-      A function to type check the definition value. Takes the definition value
-      as a parameter and returns a boolean indicating the type check result,
-      <literal>true</literal> for success and <literal>false</literal> for
-      failure.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>merge</varname>
-    </term>
-    <listitem>
-     <para>
-      A function to merge multiple definitions values. Takes two parameters:
-     </para>
-     <variablelist>
-      <varlistentry>
-       <term>
-        <replaceable>loc</replaceable>
-       </term>
-       <listitem>
-        <para>
-         The option path as a list of strings, e.g. <literal>["boot" "loader
-         "grub" "enable"]</literal>.
-        </para>
-       </listitem>
-      </varlistentry>
-      <varlistentry>
-       <term>
-        <replaceable>defs</replaceable>
-       </term>
-       <listitem>
-        <para>
-         The list of sets of defined <literal>value</literal> and
-         <literal>file</literal> where the value was defined, e.g. <literal>[ {
-         file = "/foo.nix"; value = 1; } { file = "/bar.nix"; value = 2 }
-         ]</literal>. The <literal>merge</literal> function should return the
-         merged value or throw an error in case the values are impossible or
-         not meant to be merged.
-        </para>
-       </listitem>
-      </varlistentry>
-     </variablelist>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>getSubOptions</varname>
-    </term>
-    <listitem>
-     <para>
-      For composed types that can take a submodule as type parameter, this
-      function generate sub-options documentation. It takes the current option
-      prefix as a list and return the set of sub-options. Usually defined in a
-      recursive manner by adding a term to the prefix, e.g. <literal>prefix:
-      elemType.getSubOptions (prefix ++
-      [<replaceable>"prefix"</replaceable>])</literal> where
-      <replaceable>"prefix"</replaceable> is the newly added prefix.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>getSubModules</varname>
-    </term>
-    <listitem>
-     <para>
-      For composed types that can take a submodule as type parameter, this
-      function should return the type parameters submodules. If the type
-      parameter is called <literal>elemType</literal>, the function should just
-      recursively look into submodules by returning
-      <literal>elemType.getSubModules;</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>substSubModules</varname>
-    </term>
-    <listitem>
-     <para>
-      For composed types that can take a submodule as type parameter, this
-      function can be used to substitute the parameter of a submodule type. It
-      takes a module as parameter and return the type with the submodule
-      options substituted. It is usually defined as a type function call with a
-      recursive call to <literal>substSubModules</literal>, e.g for a type
-      <literal>composedType</literal> that take an <literal>elemtype</literal>
-      type parameter, this function should be defined as <literal>m:
-      composedType (elemType.substSubModules m)</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>typeMerge</varname>
-    </term>
-    <listitem>
-     <para>
-      A function to merge multiple type declarations. Takes the type to merge
-      <literal>functor</literal> as parameter. A <literal>null</literal> return
-      value means that type cannot be merged.
-     </para>
-     <variablelist>
-      <varlistentry>
-       <term>
-        <replaceable>f</replaceable>
-       </term>
-       <listitem>
-        <para>
-         The type to merge <literal>functor</literal>.
-        </para>
-       </listitem>
-      </varlistentry>
-     </variablelist>
-     <para>
-      Note: There is a generic <literal>defaultTypeMerge</literal> that work
-      with most of value and composed types.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>functor</varname>
-    </term>
-    <listitem>
-     <para>
-      An attribute set representing the type. It is used for type operations
-      and has the following keys:
-     </para>
-     <variablelist>
-      <varlistentry>
-       <term>
-        <varname>type</varname>
-       </term>
-       <listitem>
-        <para>
-         The type function.
-        </para>
-       </listitem>
-      </varlistentry>
-      <varlistentry>
-       <term>
-        <varname>wrapped</varname>
-       </term>
-       <listitem>
-        <para>
-         Holds the type parameter for composed types.
-        </para>
-       </listitem>
-      </varlistentry>
-      <varlistentry>
-       <term>
-        <varname>payload</varname>
-       </term>
-       <listitem>
-        <para>
-         Holds the value parameter for value types. The types that have a
-         <literal>payload</literal> are the <literal>enum</literal>,
-         <literal>separatedString</literal> and <literal>submodule</literal>
-         types.
-        </para>
-       </listitem>
-      </varlistentry>
-      <varlistentry>
-       <term>
-        <varname>binOp</varname>
-       </term>
-       <listitem>
-        <para>
-         A binary operation that can merge the payloads of two same types.
-         Defined as a function that take two payloads as parameters and return
-         the payloads merged.
-        </para>
-       </listitem>
-      </varlistentry>
-     </variablelist>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/replace-modules.section.md b/nixpkgs/nixos/doc/manual/development/replace-modules.section.md
new file mode 100644
index 000000000000..0700a82004c1
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/replace-modules.section.md
@@ -0,0 +1,64 @@
+# Replace Modules {#sec-replace-modules}
+
+Modules that are imported can also be disabled. The option declarations,
+config implementation and the imports of a disabled module will be
+ignored, allowing another to take it\'s place. This can be used to
+import a set of modules from another channel while keeping the rest of
+the system on a stable release.
+
+`disabledModules` is a top level attribute like `imports`, `options` and
+`config`. It contains a list of modules that will be disabled. This can
+either be the full path to the module or a string with the filename
+relative to the modules path (eg. \<nixpkgs/nixos/modules> for nixos).
+
+This example will replace the existing postgresql module with the
+version defined in the nixos-unstable channel while keeping the rest of
+the modules and packages from the original nixos channel. This only
+overrides the module definition, this won\'t use postgresql from
+nixos-unstable unless explicitly configured to do so.
+
+```nix
+{ config, lib, pkgs, ... }:
+
+{
+  disabledModules = [ "services/databases/postgresql.nix" ];
+
+  imports =
+    [ # Use postgresql service from nixos-unstable channel.
+      # sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
+      <nixos-unstable/nixos/modules/services/databases/postgresql.nix>
+    ];
+
+  services.postgresql.enable = true;
+}
+```
+
+This example shows how to define a custom module as a replacement for an
+existing module. Importing this module will disable the original module
+without having to know it\'s implementation details.
+
+```nix
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.programs.man;
+in
+
+{
+  disabledModules = [ "services/programs/man.nix" ];
+
+  options = {
+    programs.man.enable = mkOption {
+      type = types.bool;
+      default = true;
+      description = "Whether to enable manual pages.";
+    };
+  };
+
+  config = mkIf cfg.enabled {
+    warnings = [ "disabled manpages for production deployments." ];
+  };
+}
+```
diff --git a/nixpkgs/nixos/doc/manual/development/replace-modules.xml b/nixpkgs/nixos/doc/manual/development/replace-modules.xml
deleted file mode 100644
index 9fc5678ca1b3..000000000000
--- a/nixpkgs/nixos/doc/manual/development/replace-modules.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-replace-modules">
- <title>Replace Modules</title>
-
- <para>
-  Modules that are imported can also be disabled. The option declarations,
-  config implementation and the imports of a disabled module will be ignored, allowing another
-  to take it's place. This can be used to import a set of modules from another
-  channel while keeping the rest of the system on a stable release.
- </para>
-
- <para>
-  <literal>disabledModules</literal> is a top level attribute like
-  <literal>imports</literal>, <literal>options</literal> and
-  <literal>config</literal>. It contains a list of modules that will be
-  disabled. This can either be the full path to the module or a string with the
-  filename relative to the modules path (eg. &lt;nixpkgs/nixos/modules&gt; for
-  nixos).
- </para>
-
- <para>
-  This example will replace the existing postgresql module with the version
-  defined in the nixos-unstable channel while keeping the rest of the modules
-  and packages from the original nixos channel. This only overrides the module
-  definition, this won't use postgresql from nixos-unstable unless explicitly
-  configured to do so.
- </para>
-
-<programlisting>
-{ config, lib, pkgs, ... }:
-
-{
-  disabledModules = [ "services/databases/postgresql.nix" ];
-
-  imports =
-    [ # Use postgresql service from nixos-unstable channel.
-      # sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
-      &lt;nixos-unstable/nixos/modules/services/databases/postgresql.nix&gt;
-    ];
-
-  services.postgresql.enable = true;
-}
-</programlisting>
-
- <para>
-  This example shows how to define a custom module as a replacement for an
-  existing module. Importing this module will disable the original module
-  without having to know it's implementation details.
- </para>
-
-<programlisting>
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-let
-  cfg = config.programs.man;
-in
-
-{
-  disabledModules = [ "services/programs/man.nix" ];
-
-  options = {
-    programs.man.enable = mkOption {
-      type = types.bool;
-      default = true;
-      description = "Whether to enable manual pages.";
-    };
-  };
-
-  config = mkIf cfg.enabled {
-    warnings = [ "disabled manpages for production deployments." ];
-  };
-}
-</programlisting>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/settings-options.section.md b/nixpkgs/nixos/doc/manual/development/settings-options.section.md
new file mode 100644
index 000000000000..58a3d8448af5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/settings-options.section.md
@@ -0,0 +1,192 @@
+# Options for Program Settings {#sec-settings-options}
+
+Many programs have configuration files where program-specific settings
+can be declared. File formats can be separated into two categories:
+
+-   Nix-representable ones: These can trivially be mapped to a subset of
+    Nix syntax. E.g. JSON is an example, since its values like
+    `{"foo":{"bar":10}}` can be mapped directly to Nix:
+    `{ foo = { bar = 10; }; }`. Other examples are INI, YAML and TOML.
+    The following section explains the convention for these settings.
+
+-   Non-nix-representable ones: These can\'t be trivially mapped to a
+    subset of Nix syntax. Most generic programming languages are in this
+    group, e.g. bash, since the statement `if true; then echo hi; fi`
+    doesn\'t have a trivial representation in Nix.
+
+    Currently there are no fixed conventions for these, but it is common
+    to have a `configFile` option for setting the configuration file
+    path directly. The default value of `configFile` can be an
+    auto-generated file, with convenient options for controlling the
+    contents. For example an option of type `attrsOf str` can be used
+    for representing environment variables which generates a section
+    like `export FOO="foo"`. Often it can also be useful to also include
+    an `extraConfig` option of type `lines` to allow arbitrary text
+    after the autogenerated part of the file.
+
+## Nix-representable Formats (JSON, YAML, TOML, INI, \...) {#sec-settings-nix-representable}
+
+By convention, formats like this are handled with a generic `settings`
+option, representing the full program configuration as a Nix value. The
+type of this option should represent the format. The most common formats
+have a predefined type and string generator already declared under
+`pkgs.formats`:
+
+`pkgs.formats.json` { }
+
+:   A function taking an empty attribute set (for future extensibility)
+    and returning a set with JSON-specific attributes `type` and
+    `generate` as specified [below](#pkgs-formats-result).
+
+`pkgs.formats.yaml` { }
+
+:   A function taking an empty attribute set (for future extensibility)
+    and returning a set with YAML-specific attributes `type` and
+    `generate` as specified [below](#pkgs-formats-result).
+
+`pkgs.formats.ini` { *`listsAsDuplicateKeys`* ? false, *`listToValue`* ? null, \... }
+
+:   A function taking an attribute set with values
+
+    `listsAsDuplicateKeys`
+
+    :   A boolean for controlling whether list values can be used to
+        represent duplicate INI keys
+
+    `listToValue`
+
+    :   A function for turning a list of values into a single value.
+
+    It returns a set with INI-specific attributes `type` and `generate`
+    as specified [below](#pkgs-formats-result).
+
+`pkgs.formats.toml` { }
+
+:   A function taking an empty attribute set (for future extensibility)
+    and returning a set with TOML-specific attributes `type` and
+    `generate` as specified [below](#pkgs-formats-result).
+
+::: {#pkgs-formats-result}
+These functions all return an attribute set with these values:
+:::
+
+`type`
+
+:   A module system type representing a value of the format
+
+`generate` *`filename jsonValue`*
+
+:   A function that can render a value of the format to a file. Returns
+    a file path.
+
+    ::: {.note}
+    This function puts the value contents in the Nix store. So this
+    should be avoided for secrets.
+    :::
+
+::: {#ex-settings-nix-representable .example}
+::: {.title}
+**Example: Module with conventional `settings` option**
+:::
+The following shows a module for an example program that uses a JSON
+configuration file. It demonstrates how above values can be used, along
+with some other related best practices. See the comments for
+explanations.
+
+```nix
+{ options, config, lib, pkgs, ... }:
+let
+  cfg = config.services.foo;
+  # Define the settings format used for this program
+  settingsFormat = pkgs.formats.json {};
+in {
+
+  options.services.foo = {
+    enable = lib.mkEnableOption "foo service";
+
+    settings = lib.mkOption {
+      # Setting this type allows for correct merging behavior
+      type = settingsFormat.type;
+      default = {};
+      description = ''
+        Configuration for foo, see
+        <link xlink:href="https://example.com/docs/foo"/>
+        for supported settings.
+      '';
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    # We can assign some default settings here to make the service work by just
+    # enabling it. We use `mkDefault` for values that can be changed without
+    # problems
+    services.foo.settings = {
+      # Fails at runtime without any value set
+      log_level = lib.mkDefault "WARN";
+
+      # We assume systemd's `StateDirectory` is used, so we require this value,
+      # therefore no mkDefault
+      data_path = "/var/lib/foo";
+
+      # Since we use this to create a user we need to know the default value at
+      # eval time
+      user = lib.mkDefault "foo";
+    };
+
+    environment.etc."foo.json".source =
+      # The formats generator function takes a filename and the Nix value
+      # representing the format value and produces a filepath with that value
+      # rendered in the format
+      settingsFormat.generate "foo-config.json" cfg.settings;
+
+    # We know that the `user` attribute exists because we set a default value
+    # for it above, allowing us to use it without worries here
+    users.users.${cfg.settings.user} = { isSystemUser = true; };
+
+    # ...
+  };
+}
+```
+:::
+
+### Option declarations for attributes {#sec-settings-attrs-options}
+
+Some `settings` attributes may deserve some extra care. They may need a
+different type, default or merging behavior, or they are essential
+options that should show their documentation in the manual. This can be
+done using [](#sec-freeform-modules).
+
+We extend above example using freeform modules to declare an option for
+the port, which will enforce it to be a valid integer and make it show
+up in the manual.
+
+::: {#ex-settings-typed-attrs .example}
+::: {.title}
+**Example: Declaring a type-checked `settings` attribute**
+:::
+```nix
+settings = lib.mkOption {
+  type = lib.types.submodule {
+
+    freeformType = settingsFormat.type;
+
+    # Declare an option for the port such that the type is checked and this option
+    # is shown in the manual.
+    options.port = lib.mkOption {
+      type = lib.types.port;
+      default = 8080;
+      description = ''
+        Which port this service should listen on.
+      '';
+    };
+
+  };
+  default = {};
+  description = ''
+    Configuration for Foo, see
+    <link xlink:href="https://example.com/docs/foo"/>
+    for supported values.
+  '';
+};
+```
+:::
diff --git a/nixpkgs/nixos/doc/manual/development/settings-options.xml b/nixpkgs/nixos/doc/manual/development/settings-options.xml
deleted file mode 100644
index 7292cac62b70..000000000000
--- a/nixpkgs/nixos/doc/manual/development/settings-options.xml
+++ /dev/null
@@ -1,226 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-settings-options">
- <title>Options for Program Settings</title>
-
- <para>
-   Many programs have configuration files where program-specific settings can be declared. File formats can be separated into two categories:
-   <itemizedlist>
-     <listitem>
-       <para>
-         Nix-representable ones: These can trivially be mapped to a subset of Nix syntax. E.g. JSON is an example, since its values like <literal>{"foo":{"bar":10}}</literal> can be mapped directly to Nix: <literal>{ foo = { bar = 10; }; }</literal>. Other examples are INI, YAML and TOML. The following section explains the convention for these settings.
-       </para>
-     </listitem>
-     <listitem>
-       <para>
-         Non-nix-representable ones: These can't be trivially mapped to a subset of Nix syntax. Most generic programming languages are in this group, e.g. bash, since the statement <literal>if true; then echo hi; fi</literal> doesn't have a trivial representation in Nix.
-       </para>
-       <para>
-         Currently there are no fixed conventions for these, but it is common to have a <literal>configFile</literal> option for setting the configuration file path directly. The default value of <literal>configFile</literal> can be an auto-generated file, with convenient options for controlling the contents. For example an option of type <literal>attrsOf str</literal> can be used for representing environment variables which generates a section like <literal>export FOO="foo"</literal>. Often it can also be useful to also include an <literal>extraConfig</literal> option of type <literal>lines</literal> to allow arbitrary text after the autogenerated part of the file.
-       </para>
-     </listitem>
-   </itemizedlist>
- </para>
- <section xml:id="sec-settings-nix-representable">
-   <title>Nix-representable Formats (JSON, YAML, TOML, INI, ...)</title>
-   <para>
-     By convention, formats like this are handled with a generic <literal>settings</literal> option, representing the full program configuration as a Nix value. The type of this option should represent the format. The most common formats have a predefined type and string generator already declared under <literal>pkgs.formats</literal>:
-     <variablelist>
-       <varlistentry>
-         <term>
-           <varname>pkgs.formats.json</varname> { }
-         </term>
-         <listitem>
-           <para>
-             A function taking an empty attribute set (for future extensibility) and returning a set with JSON-specific attributes <varname>type</varname> and <varname>generate</varname> as specified <link linkend='pkgs-formats-result'>below</link>.
-           </para>
-         </listitem>
-       </varlistentry>
-       <varlistentry>
-         <term>
-           <varname>pkgs.formats.yaml</varname> { }
-         </term>
-         <listitem>
-           <para>
-             A function taking an empty attribute set (for future extensibility) and returning a set with YAML-specific attributes <varname>type</varname> and <varname>generate</varname> as specified <link linkend='pkgs-formats-result'>below</link>.
-           </para>
-         </listitem>
-       </varlistentry>
-       <varlistentry>
-         <term>
-           <varname>pkgs.formats.ini</varname> { <replaceable>listsAsDuplicateKeys</replaceable> ? false, <replaceable>listToValue</replaceable> ? null, ... }
-         </term>
-         <listitem>
-           <para>
-             A function taking an attribute set with values
-             <variablelist>
-               <varlistentry>
-                 <term>
-                   <varname>listsAsDuplicateKeys</varname>
-                 </term>
-                 <listitem>
-                   <para>
-                     A boolean for controlling whether list values can be used to represent duplicate INI keys
-                   </para>
-                 </listitem>
-               </varlistentry>
-               <varlistentry>
-                 <term>
-                   <varname>listToValue</varname>
-                 </term>
-                 <listitem>
-                   <para>
-                     A function for turning a list of values into a single value.
-                   </para>
-                 </listitem>
-               </varlistentry>
-             </variablelist>
-            It returns a set with INI-specific attributes <varname>type</varname> and <varname>generate</varname> as specified <link linkend='pkgs-formats-result'>below</link>.
-           </para>
-         </listitem>
-       </varlistentry>
-       <varlistentry>
-         <term>
-           <varname>pkgs.formats.toml</varname> { }
-         </term>
-         <listitem>
-           <para>
-             A function taking an empty attribute set (for future extensibility) and returning a set with TOML-specific attributes <varname>type</varname> and <varname>generate</varname> as specified <link linkend='pkgs-formats-result'>below</link>.
-           </para>
-         </listitem>
-       </varlistentry>
-     </variablelist>
-
-   </para>
-   <para xml:id="pkgs-formats-result">
-     These functions all return an attribute set with these values:
-    <variablelist>
-      <varlistentry>
-        <term>
-          <varname>type</varname>
-        </term>
-        <listitem>
-          <para>
-            A module system type representing a value of the format
-          </para>
-        </listitem>
-      </varlistentry>
-      <varlistentry>
-        <term>
-          <varname>generate</varname> <replaceable>filename</replaceable> <replaceable>jsonValue</replaceable>
-        </term>
-        <listitem>
-          <para>
-           A function that can render a value of the format to a file. Returns a file path.
-           <note>
-            <para>
-             This function puts the value contents in the Nix store. So this should be avoided for secrets.
-            </para>
-           </note>
-          </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-   </para>
-   <example xml:id="ex-settings-nix-representable">
-     <title>Module with conventional <literal>settings</literal> option</title>
-     <para>
-       The following shows a module for an example program that uses a JSON configuration file. It demonstrates how above values can be used, along with some other related best practices. See the comments for explanations.
-     </para>
-<programlisting>
-{ options, config, lib, pkgs, ... }:
-let
-  cfg = config.services.foo;
-  # Define the settings format used for this program
-  settingsFormat = pkgs.formats.json {};
-in {
-
-  options.services.foo = {
-    enable = lib.mkEnableOption "foo service";
-
-    settings = lib.mkOption {
-      # Setting this type allows for correct merging behavior
-      type = settingsFormat.type;
-      default = {};
-      description = ''
-        Configuration for foo, see
-        &lt;link xlink:href="https://example.com/docs/foo"/&gt;
-        for supported settings.
-      '';
-    };
-  };
-
-  config = lib.mkIf cfg.enable {
-    # We can assign some default settings here to make the service work by just
-    # enabling it. We use `mkDefault` for values that can be changed without
-    # problems
-    services.foo.settings = {
-      # Fails at runtime without any value set
-      log_level = lib.mkDefault "WARN";
-
-      # We assume systemd's `StateDirectory` is used, so we require this value,
-      # therefore no mkDefault
-      data_path = "/var/lib/foo";
-
-      # Since we use this to create a user we need to know the default value at
-      # eval time
-      user = lib.mkDefault "foo";
-    };
-
-    environment.etc."foo.json".source =
-      # The formats generator function takes a filename and the Nix value
-      # representing the format value and produces a filepath with that value
-      # rendered in the format
-      settingsFormat.generate "foo-config.json" cfg.settings;
-
-    # We know that the `user` attribute exists because we set a default value
-    # for it above, allowing us to use it without worries here
-    users.users.${cfg.settings.user} = { isSystemUser = true; };
-
-    # ...
-  };
-}
-</programlisting>
-   </example>
-   <section xml:id="sec-settings-attrs-options">
-    <title>Option declarations for attributes</title>
-    <para>
-     Some <literal>settings</literal> attributes may deserve some extra care. They may need a different type, default or merging behavior, or they are essential options that should show their documentation in the manual. This can be done using <xref linkend='sec-freeform-modules'/>.
-     <example xml:id="ex-settings-typed-attrs">
-      <title>Declaring a type-checked <literal>settings</literal> attribute</title>
-      <para>
-       We extend above example using freeform modules to declare an option for the port, which will enforce it to be a valid integer and make it show up in the manual.
-      </para>
-<programlisting>
-settings = lib.mkOption {
-  type = lib.types.submodule {
-
-    freeformType = settingsFormat.type;
-
-    # Declare an option for the port such that the type is checked and this option
-    # is shown in the manual.
-    options.port = lib.mkOption {
-      type = lib.types.port;
-      default = 8080;
-      description = ''
-        Which port this service should listen on.
-      '';
-    };
-
-  };
-  default = {};
-  description = ''
-    Configuration for Foo, see
-    &lt;link xlink:href="https://example.com/docs/foo"/&gt;
-    for supported values.
-  '';
-};
-</programlisting>
-     </example>
-    </para>
-   </section>
- </section>
-
-</section>
diff --git a/nixpkgs/nixos/doc/manual/development/sources.chapter.md b/nixpkgs/nixos/doc/manual/development/sources.chapter.md
new file mode 100644
index 000000000000..88173f7135bd
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/sources.chapter.md
@@ -0,0 +1,77 @@
+# Getting the Sources {#sec-getting-sources}
+
+By default, NixOS's `nixos-rebuild` command uses the NixOS and Nixpkgs
+sources provided by the `nixos` channel (kept in
+`/nix/var/nix/profiles/per-user/root/channels/nixos`). To modify NixOS,
+however, you should check out the latest sources from Git. This is as
+follows:
+
+```ShellSession
+$ git clone https://github.com/NixOS/nixpkgs
+$ cd nixpkgs
+$ git remote update origin
+```
+
+This will check out the latest Nixpkgs sources to `./nixpkgs` the NixOS
+sources to `./nixpkgs/nixos`. (The NixOS source tree lives in a
+subdirectory of the Nixpkgs repository.) The `nixpkgs` repository has
+branches that correspond to each Nixpkgs/NixOS channel (see
+[](#sec-upgrading) for more information about channels). Thus, the
+Git branch `origin/nixos-17.03` will contain the latest built and tested
+version available in the `nixos-17.03` channel.
+
+It's often inconvenient to develop directly on the master branch, since
+if somebody has just committed (say) a change to GCC, then the binary
+cache may not have caught up yet and you'll have to rebuild everything
+from source. So you may want to create a local branch based on your
+current NixOS version:
+
+```ShellSession
+$ nixos-version
+17.09pre104379.6e0b727 (Hummingbird)
+
+$ git checkout -b local 6e0b727
+```
+
+Or, to base your local branch on the latest version available in a NixOS
+channel:
+
+```ShellSession
+$ git remote update origin
+$ git checkout -b local origin/nixos-17.03
+```
+
+(Replace `nixos-17.03` with the name of the channel you want to use.)
+You can use `git merge` or `git
+  rebase` to keep your local branch in sync with the channel, e.g.
+
+```ShellSession
+$ git remote update origin
+$ git merge origin/nixos-17.03
+```
+
+You can use `git cherry-pick` to copy commits from your local branch to
+the upstream branch.
+
+If you want to rebuild your system using your (modified) sources, you
+need to tell `nixos-rebuild` about them using the `-I` flag:
+
+```ShellSession
+# nixos-rebuild switch -I nixpkgs=/my/sources/nixpkgs
+```
+
+If you want `nix-env` to use the expressions in `/my/sources`, use
+`nix-env -f
+  /my/sources/nixpkgs`, or change the default by adding a symlink in
+`~/.nix-defexpr`:
+
+```ShellSession
+$ ln -s /my/sources/nixpkgs ~/.nix-defexpr/nixpkgs
+```
+
+You may want to delete the symlink `~/.nix-defexpr/channels_root` to
+prevent root's NixOS channel from clashing with your own tree (this may
+break the command-not-found utility though). If you want to go back to
+the default state, you may just remove the `~/.nix-defexpr` directory
+completely, log out and log in again and it should have been recreated
+with a link to the root channels.
diff --git a/nixpkgs/nixos/doc/manual/development/sources.xml b/nixpkgs/nixos/doc/manual/development/sources.xml
deleted file mode 100644
index b333ccabb420..000000000000
--- a/nixpkgs/nixos/doc/manual/development/sources.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-getting-sources">
- <title>Getting the Sources</title>
- <para>
-  By default, NixOS’s <command>nixos-rebuild</command> command uses the NixOS
-  and Nixpkgs sources provided by the <literal>nixos</literal> channel (kept in
-  <filename>/nix/var/nix/profiles/per-user/root/channels/nixos</filename>). To
-  modify NixOS, however, you should check out the latest sources from Git. This
-  is as follows:
-<screen>
-<prompt>$ </prompt>git clone https://github.com/NixOS/nixpkgs
-<prompt>$ </prompt>cd nixpkgs
-<prompt>$ </prompt>git remote update origin
-</screen>
-  This will check out the latest Nixpkgs sources to
-  <filename>./nixpkgs</filename> the NixOS sources to
-  <filename>./nixpkgs/nixos</filename>. (The NixOS source tree lives in a
-  subdirectory of the Nixpkgs repository.) The
-  <literal>nixpkgs</literal> repository has branches that correspond
-  to each Nixpkgs/NixOS channel (see <xref linkend="sec-upgrading"/> for more
-  information about channels). Thus, the Git branch
-  <literal>origin/nixos-17.03</literal> will contain the latest built and
-  tested version available in the <literal>nixos-17.03</literal> channel.
- </para>
- <para>
-  It’s often inconvenient to develop directly on the master branch, since if
-  somebody has just committed (say) a change to GCC, then the binary cache may
-  not have caught up yet and you’ll have to rebuild everything from source.
-  So you may want to create a local branch based on your current NixOS version:
-<screen>
-<prompt>$ </prompt>nixos-version
-17.09pre104379.6e0b727 (Hummingbird)
-
-<prompt>$ </prompt>git checkout -b local 6e0b727
-</screen>
-  Or, to base your local branch on the latest version available in a NixOS
-  channel:
-<screen>
-<prompt>$ </prompt>git remote update origin
-<prompt>$ </prompt>git checkout -b local origin/nixos-17.03
-</screen>
-  (Replace <literal>nixos-17.03</literal> with the name of the channel you want
-  to use.) You can use <command>git merge</command> or <command>git
-  rebase</command> to keep your local branch in sync with the channel, e.g.
-<screen>
-<prompt>$ </prompt>git remote update origin
-<prompt>$ </prompt>git merge origin/nixos-17.03
-</screen>
-  You can use <command>git cherry-pick</command> to copy commits from your
-  local branch to the upstream branch.
- </para>
- <para>
-  If you want to rebuild your system using your (modified) sources, you need to
-  tell <command>nixos-rebuild</command> about them using the
-  <option>-I</option> flag:
-<screen>
-<prompt># </prompt>nixos-rebuild switch -I nixpkgs=<replaceable>/my/sources</replaceable>/nixpkgs
-</screen>
- </para>
- <para>
-  If you want <command>nix-env</command> to use the expressions in
-  <replaceable>/my/sources</replaceable>, use <command>nix-env -f
-  <replaceable>/my/sources</replaceable>/nixpkgs</command>, or change the
-  default by adding a symlink in <filename>~/.nix-defexpr</filename>:
-<screen>
-<prompt>$ </prompt>ln -s <replaceable>/my/sources</replaceable>/nixpkgs ~/.nix-defexpr/nixpkgs
-</screen>
-  You may want to delete the symlink
-  <filename>~/.nix-defexpr/channels_root</filename> to prevent root’s NixOS
-  channel from clashing with your own tree (this may break the
-  command-not-found utility though). If you want to go back to the default
-  state, you may just remove the <filename>~/.nix-defexpr</filename> directory
-  completely, log out and log in again and it should have been recreated with a
-  link to the root channels.
- </para>
-<!-- FIXME: not sure what this means.
-<para>You should not pass the base directory
-<filename><replaceable>/my/sources</replaceable></filename>
-to <command>nix-env</command>, as it will break after interpreting expressions
-in <filename>nixos/</filename> as packages.</para>
--->
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/development/testing-installer.chapter.md b/nixpkgs/nixos/doc/manual/development/testing-installer.chapter.md
new file mode 100644
index 000000000000..2eaa01614920
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/testing-installer.chapter.md
@@ -0,0 +1,18 @@
+# Testing the Installer {#ch-testing-installer}
+
+Building, burning, and booting from an installation CD is rather
+tedious, so here is a quick way to see if the installer works properly:
+
+```ShellSession
+# mount -t tmpfs none /mnt
+# nixos-generate-config --root /mnt
+$ nix-build '<nixpkgs/nixos>' -A config.system.build.nixos-install
+# ./result/bin/nixos-install
+```
+
+To start a login shell in the new NixOS installation in `/mnt`:
+
+```ShellSession
+$ nix-build '<nixpkgs/nixos>' -A config.system.build.nixos-enter
+# ./result/bin/nixos-enter
+```
diff --git a/nixpkgs/nixos/doc/manual/development/testing-installer.xml b/nixpkgs/nixos/doc/manual/development/testing-installer.xml
deleted file mode 100644
index 902f995fbc1b..000000000000
--- a/nixpkgs/nixos/doc/manual/development/testing-installer.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="ch-testing-installer">
- <title>Testing the Installer</title>
- <para>
-  Building, burning, and booting from an installation CD is rather tedious, so
-  here is a quick way to see if the installer works properly:
-<screen>
-<prompt># </prompt>mount -t tmpfs none /mnt
-<prompt># </prompt>nixos-generate-config --root /mnt
-<prompt>$ </prompt>nix-build '&lt;nixpkgs/nixos>' -A config.system.build.nixos-install
-<prompt># </prompt>./result/bin/nixos-install</screen>
-  To start a login shell in the new NixOS installation in
-  <filename>/mnt</filename>:
-<screen>
-<prompt>$ </prompt>nix-build '&lt;nixpkgs/nixos>' -A config.system.build.nixos-enter
-<prompt># </prompt>./result/bin/nixos-enter
-</screen>
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/development/writing-documentation.chapter.md b/nixpkgs/nixos/doc/manual/development/writing-documentation.chapter.md
new file mode 100644
index 000000000000..7c29f600d701
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/writing-documentation.chapter.md
@@ -0,0 +1,93 @@
+# Writing NixOS Documentation {#sec-writing-documentation}
+
+As NixOS grows, so too does the need for a catalogue and explanation of
+its extensive functionality. Collecting pertinent information from
+disparate sources and presenting it in an accessible style would be a
+worthy contribution to the project.
+
+## Building the Manual {#sec-writing-docs-building-the-manual}
+
+The DocBook sources of the [](#book-nixos-manual) are in the
+[`nixos/doc/manual`](https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual)
+subdirectory of the Nixpkgs repository.
+
+You can quickly validate your edits with `make`:
+
+```ShellSession
+$ cd /path/to/nixpkgs/nixos/doc/manual
+$ nix-shell
+nix-shell$ make
+```
+
+Once you are done making modifications to the manual, it\'s important to
+build it before committing. You can do that as follows:
+
+```ShellSession
+nix-build nixos/release.nix -A manual.x86_64-linux
+```
+
+When this command successfully finishes, it will tell you where the
+manual got generated. The HTML will be accessible through the `result`
+symlink at `./result/share/doc/nixos/index.html`.
+
+## Editing DocBook XML {#sec-writing-docs-editing-docbook-xml}
+
+For general information on how to write in DocBook, see [DocBook 5: The
+Definitive Guide](http://www.docbook.org/tdg5/en/html/docbook.html).
+
+Emacs nXML Mode is very helpful for editing DocBook XML because it
+validates the document as you write, and precisely locates errors. To
+use it, see [](#sec-emacs-docbook-xml).
+
+[Pandoc](http://pandoc.org) can generate DocBook XML from a multitude of
+formats, which makes a good starting point. Here is an example of Pandoc
+invocation to convert GitHub-Flavoured MarkDown to DocBook 5 XML:
+
+```ShellSession
+pandoc -f markdown_github -t docbook5 docs.md -o my-section.md
+```
+
+Pandoc can also quickly convert a single `section.xml` to HTML, which is
+helpful when drafting.
+
+Sometimes writing valid DocBook is simply too difficult. In this case,
+submit your documentation updates in a [GitHub
+Issue](https://github.com/NixOS/nixpkgs/issues/new) and someone will
+handle the conversion to XML for you.
+
+## Creating a Topic {#sec-writing-docs-creating-a-topic}
+
+You can use an existing topic as a basis for the new topic or create a
+topic from scratch.
+
+Keep the following guidelines in mind when you create and add a topic:
+
+-   The NixOS [`book`](http://www.docbook.org/tdg5/en/html/book.html)
+    element is in `nixos/doc/manual/manual.xml`. It includes several
+    [`parts`](http://www.docbook.org/tdg5/en/html/book.html) which are in
+    subdirectories.
+
+-   Store the topic file in the same directory as the `part` to which it
+    belongs. If your topic is about configuring a NixOS module, then the
+    XML file can be stored alongside the module definition `nix` file.
+
+-   If you include multiple words in the file name, separate the words
+    with a dash. For example: `ipv6-config.xml`.
+
+-   Make sure that the `xml:id` value is unique. You can use abbreviations
+    if the ID is too long. For example: `nixos-config`.
+
+-   Determine whether your topic is a chapter or a section. If you are
+    unsure, open an existing topic file and check whether the main
+    element is chapter or section.
+
+## Adding a Topic to the Book {#sec-writing-docs-adding-a-topic}
+
+Open the parent XML file and add an `xi:include` element to the list of
+chapters with the file name of the topic that you created. If you
+created a `section`, you add the file to the `chapter` file. If you created
+a `chapter`, you add the file to the `part` file.
+
+If the topic is about configuring a NixOS module, it can be
+automatically included in the manual by using the `meta.doc` attribute.
+See [](#sec-meta-attributes) for an explanation.
diff --git a/nixpkgs/nixos/doc/manual/development/writing-documentation.xml b/nixpkgs/nixos/doc/manual/development/writing-documentation.xml
deleted file mode 100644
index 89fab6665616..000000000000
--- a/nixpkgs/nixos/doc/manual/development/writing-documentation.xml
+++ /dev/null
@@ -1,150 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-writing-documentation">
- <title>Writing NixOS Documentation</title>
- <para>
-  As NixOS grows, so too does the need for a catalogue and explanation of its
-  extensive functionality. Collecting pertinent information from disparate
-  sources and presenting it in an accessible style would be a worthy
-  contribution to the project.
- </para>
- <section xml:id="sec-writing-docs-building-the-manual">
-  <title>Building the Manual</title>
-
-  <para>
-   The DocBook sources of the <xref linkend="book-nixos-manual"/> are in the
-   <link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual"><filename>nixos/doc/manual</filename></link>
-   subdirectory of the Nixpkgs repository.
-  </para>
-
-  <para>
-   You can quickly validate your edits with <command>make</command>:
-  </para>
-
-<screen>
-<prompt>$ </prompt>cd /path/to/nixpkgs/nixos/doc/manual
-<prompt>$ </prompt>nix-shell
-<prompt>nix-shell$ </prompt>make
-</screen>
-
-  <para>
-   Once you are done making modifications to the manual, it's important to
-   build it before committing. You can do that as follows:
-  </para>
-
-<screen>nix-build nixos/release.nix -A manual.x86_64-linux</screen>
-
-  <para>
-   When this command successfully finishes, it will tell you where the manual
-   got generated. The HTML will be accessible through the
-   <filename>result</filename> symlink at
-   <filename>./result/share/doc/nixos/index.html</filename>.
-  </para>
- </section>
- <section xml:id="sec-writing-docs-editing-docbook-xml">
-  <title>Editing DocBook XML</title>
-
-  <para>
-   For general information on how to write in DocBook, see
-   <link xlink:href="http://www.docbook.org/tdg5/en/html/docbook.html"> DocBook
-   5: The Definitive Guide</link>.
-  </para>
-
-  <para>
-   Emacs nXML Mode is very helpful for editing DocBook XML because it validates
-   the document as you write, and precisely locates errors. To use it, see
-   <xref linkend="sec-emacs-docbook-xml"/>.
-  </para>
-
-  <para>
-   <link xlink:href="http://pandoc.org">Pandoc</link> can generate DocBook XML
-   from a multitude of formats, which makes a good starting point.
-   <example xml:id="ex-pandoc-xml-conv">
-    <title>Pandoc invocation to convert GitHub-Flavoured MarkDown to DocBook 5 XML</title>
-<screen>pandoc -f markdown_github -t docbook5 docs.md -o my-section.md</screen>
-   </example>
-   Pandoc can also quickly convert a single <filename>section.xml</filename> to
-   HTML, which is helpful when drafting.
-  </para>
-
-  <para>
-   Sometimes writing valid DocBook is simply too difficult. In this case,
-   submit your documentation updates in a
-   <link
-  xlink:href="https://github.com/NixOS/nixpkgs/issues/new">GitHub
-   Issue</link> and someone will handle the conversion to XML for you.
-  </para>
- </section>
- <section xml:id="sec-writing-docs-creating-a-topic">
-  <title>Creating a Topic</title>
-
-  <para>
-   You can use an existing topic as a basis for the new topic or create a topic
-   from scratch.
-  </para>
-
-  <para>
-   Keep the following guidelines in mind when you create and add a topic:
-   <itemizedlist>
-    <listitem>
-     <para>
-      The NixOS
-      <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><tag>book</tag></link>
-      element is in <filename>nixos/doc/manual/manual.xml</filename>. It
-      includes several
-      <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><tag>part</tag>s</link>
-      which are in subdirectories.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Store the topic file in the same directory as the <tag>part</tag> to
-      which it belongs. If your topic is about configuring a NixOS module, then
-      the XML file can be stored alongside the module definition
-      <filename>nix</filename> file.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      If you include multiple words in the file name, separate the words with a
-      dash. For example: <filename>ipv6-config.xml</filename>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Make sure that the <tag>xml:id</tag> value is unique. You can use
-      abbreviations if the ID is too long. For example:
-      <varname>nixos-config</varname>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Determine whether your topic is a chapter or a section. If you are
-      unsure, open an existing topic file and check whether the main element is
-      chapter or section.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
- </section>
- <section xml:id="sec-writing-docs-adding-a-topic">
-  <title>Adding a Topic to the Book</title>
-
-  <para>
-   Open the parent XML file and add an <varname>xi:include</varname> element to
-   the list of chapters with the file name of the topic that you created. If
-   you created a <tag>section</tag>, you add the file to the <tag>chapter</tag>
-   file. If you created a <tag>chapter</tag>, you add the file to the
-   <tag>part</tag> file.
-  </para>
-
-  <para>
-   If the topic is about configuring a NixOS module, it can be automatically
-   included in the manual by using the <varname>meta.doc</varname> attribute.
-   See <xref
-  linkend="sec-meta-attributes"/> for an explanation.
-  </para>
- </section>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/development/writing-modules.chapter.md b/nixpkgs/nixos/doc/manual/development/writing-modules.chapter.md
new file mode 100644
index 000000000000..2e3c6b34f1f5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/development/writing-modules.chapter.md
@@ -0,0 +1,166 @@
+# Writing NixOS Modules {#sec-writing-modules}
+
+NixOS has a modular system for declarative configuration. This system
+combines multiple *modules* to produce the full system configuration.
+One of the modules that constitute the configuration is
+`/etc/nixos/configuration.nix`. Most of the others live in the
+[`nixos/modules`](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules)
+subdirectory of the Nixpkgs tree.
+
+Each NixOS module is a file that handles one logical aspect of the
+configuration, such as a specific kind of hardware, a service, or
+network settings. A module configuration does not have to handle
+everything from scratch; it can use the functionality provided by other
+modules for its implementation. Thus a module can *declare* options that
+can be used by other modules, and conversely can *define* options
+provided by other modules in its own implementation. For example, the
+module
+[`pam.nix`](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/security/pam.nix)
+declares the option `security.pam.services` that allows other modules (e.g.
+[`sshd.nix`](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/ssh/sshd.nix))
+to define PAM services; and it defines the option `environment.etc` (declared by
+[`etc.nix`](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/etc/etc.nix))
+to cause files to be created in `/etc/pam.d`.
+
+In [](#sec-configuration-syntax), we saw the following structure of
+NixOS modules:
+
+```nix
+{ config, pkgs, ... }:
+
+{ option definitions
+}
+```
+
+This is actually an *abbreviated* form of module that only defines
+options, but does not declare any. The structure of full NixOS modules
+is shown in [Example: Structure of NixOS Modules](#ex-module-syntax).
+
+::: {#ex-module-syntax .example}
+::: {.title}
+**Example: Structure of NixOS Modules**
+:::
+```nix
+{ config, pkgs, ... }:
+
+{
+  imports =
+    [ paths of other modules
+    ];
+
+  options = {
+    option declarations
+  };
+
+  config = {
+    option definitions
+  };
+}
+```
+:::
+
+The meaning of each part is as follows.
+
+-   The first line makes the current Nix expression a function. The variable
+    `pkgs` contains Nixpkgs (by default, it takes the `nixpkgs` entry of
+    `NIX_PATH`, see the [Nix manual](https://nixos.org/manual/nix/stable/#sec-common-env)
+    for further details), while `config` contains the full system
+    configuration. This line can be omitted if there is no reference to
+    `pkgs` and `config` inside the module.
+
+-   This `imports` list enumerates the paths to other NixOS modules that
+    should be included in the evaluation of the system configuration. A
+    default set of modules is defined in the file `modules/module-list.nix`.
+    These don\'t need to be added in the import list.
+
+-   The attribute `options` is a nested set of *option declarations*
+    (described below).
+
+-   The attribute `config` is a nested set of *option definitions* (also
+    described below).
+
+[Example: NixOS Module for the "locate" Service](#locate-example)
+shows a module that handles the regular update of the "locate" database,
+an index of all files in the file system. This module declares two
+options that can be defined by other modules (typically the user's
+`configuration.nix`): `services.locate.enable` (whether the database should
+be updated) and `services.locate.interval` (when the update should be done).
+It implements its functionality by defining two options declared by other
+modules: `systemd.services` (the set of all systemd services) and
+`systemd.timers` (the list of commands to be executed periodically by
+`systemd`).
+
+::: {#locate-example .example}
+::: {.title}
+**Example: NixOS Module for the "locate" Service**
+:::
+```nix
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.locate;
+in {
+  options.services.locate = {
+    enable = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        If enabled, NixOS will periodically update the database of
+        files used by the locate command.
+      '';
+    };
+
+    interval = mkOption {
+      type = types.str;
+      default = "02:15";
+      example = "hourly";
+      description = ''
+        Update the locate database at this interval. Updates by
+        default at 2:15 AM every day.
+
+        The format is described in
+        systemd.time(7).
+      '';
+    };
+
+    # Other options omitted for documentation
+  };
+
+  config = {
+    systemd.services.update-locatedb =
+      { description = "Update Locate Database";
+        path  = [ pkgs.su ];
+        script =
+          ''
+            mkdir -m 0755 -p $(dirname ${toString cfg.output})
+            exec updatedb \
+              --localuser=${cfg.localuser} \
+              ${optionalString (!cfg.includeStore) "--prunepaths='/nix/store'"} \
+              --output=${toString cfg.output} ${concatStringsSep " " cfg.extraFlags}
+          '';
+      };
+
+    systemd.timers.update-locatedb = mkIf cfg.enable
+      { description = "Update timer for locate database";
+        partOf      = [ "update-locatedb.service" ];
+        wantedBy    = [ "timers.target" ];
+        timerConfig.OnCalendar = cfg.interval;
+      };
+  };
+}
+```
+:::
+
+```{=docbook}
+<xi:include href="option-declarations.section.xml" />
+<xi:include href="option-types.section.xml" />
+<xi:include href="option-def.section.xml" />
+<xi:include href="assertions.section.xml" />
+<xi:include href="meta-attributes.section.xml" />
+<xi:include href="importing-modules.section.xml" />
+<xi:include href="replace-modules.section.xml" />
+<xi:include href="freeform-modules.section.xml" />
+<xi:include href="settings-options.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/development/writing-modules.xml b/nixpkgs/nixos/doc/manual/development/writing-modules.xml
deleted file mode 100644
index 04497db77b89..000000000000
--- a/nixpkgs/nixos/doc/manual/development/writing-modules.xml
+++ /dev/null
@@ -1,191 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-writing-modules">
- <title>Writing NixOS Modules</title>
- <para>
-  NixOS has a modular system for declarative configuration. This system
-  combines multiple <emphasis>modules</emphasis> to produce the full system
-  configuration. One of the modules that constitute the configuration is
-  <filename>/etc/nixos/configuration.nix</filename>. Most of the others live in
-  the
-  <link
-xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/modules"><filename>nixos/modules</filename></link>
-  subdirectory of the Nixpkgs tree.
- </para>
- <para>
-  Each NixOS module is a file that handles one logical aspect of the
-  configuration, such as a specific kind of hardware, a service, or network
-  settings. A module configuration does not have to handle everything from
-  scratch; it can use the functionality provided by other modules for its
-  implementation. Thus a module can <emphasis>declare</emphasis> options that
-  can be used by other modules, and conversely can <emphasis>define</emphasis>
-  options provided by other modules in its own implementation. For example, the
-  module
-  <link
-xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/security/pam.nix"><filename>pam.nix</filename></link>
-  declares the option <option>security.pam.services</option> that allows other
-  modules (e.g.
-  <link
-xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/ssh/sshd.nix"><filename>sshd.nix</filename></link>)
-  to define PAM services; and it defines the option
-  <option>environment.etc</option> (declared by
-  <link
-xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/etc/etc.nix"><filename>etc.nix</filename></link>)
-  to cause files to be created in <filename>/etc/pam.d</filename>.
- </para>
- <para xml:id="para-module-syn">
-  In <xref
-linkend="sec-configuration-syntax"/>, we saw the following structure
-  of NixOS modules:
-<programlisting>
-{ config, pkgs, ... }:
-
-{ <replaceable>option definitions</replaceable>
-}
-</programlisting>
-  This is actually an <emphasis>abbreviated</emphasis> form of module that only
-  defines options, but does not declare any. The structure of full NixOS
-  modules is shown in <xref linkend='ex-module-syntax' />.
- </para>
- <example xml:id='ex-module-syntax'>
-  <title>Structure of NixOS Modules</title>
-<programlisting>
-{ config, pkgs, ... }: <co xml:id='module-syntax-1' />
-
-{
-  imports =
-    [ <replaceable>paths of other modules</replaceable> <co xml:id='module-syntax-2' />
-    ];
-
-  options = {
-    <replaceable>option declarations</replaceable> <co xml:id='module-syntax-3' />
-  };
-
-  config = {
-    <replaceable>option definitions</replaceable> <co xml:id='module-syntax-4' />
-  };
-}</programlisting>
- </example>
- <para>
-  The meaning of each part is as follows.
-  <calloutlist>
-   <callout arearefs='module-syntax-1'>
-    <para>
-     This line makes the current Nix expression a function. The variable
-     <varname>pkgs</varname> contains Nixpkgs (by default, it takes the
-     <varname>nixpkgs</varname> entry of <envar>NIX_PATH</envar>, see the <link
-     xlink:href="https://nixos.org/manual/nix/stable/#sec-common-env">Nix
-     manual</link> for further details), while <varname>config</varname>
-     contains the full system configuration. This line can be omitted if there
-     is no reference to <varname>pkgs</varname> and <varname>config</varname>
-     inside the module.
-    </para>
-   </callout>
-   <callout arearefs='module-syntax-2'>
-    <para>
-     This list enumerates the paths to other NixOS modules that should be
-     included in the evaluation of the system configuration. A default set of
-     modules is defined in the file
-     <filename>modules/module-list.nix</filename>. These don't need to be added
-     in the import list.
-    </para>
-   </callout>
-   <callout arearefs='module-syntax-3'>
-    <para>
-     The attribute <varname>options</varname> is a nested set of
-     <emphasis>option declarations</emphasis> (described below).
-    </para>
-   </callout>
-   <callout arearefs='module-syntax-4'>
-    <para>
-     The attribute <varname>config</varname> is a nested set of
-     <emphasis>option definitions</emphasis> (also described below).
-    </para>
-   </callout>
-  </calloutlist>
- </para>
- <para>
-  <xref linkend='locate-example' /> shows a module that handles the regular
-  update of the “locate” database, an index of all files in the file
-  system. This module declares two options that can be defined by other modules
-  (typically the user’s <filename>configuration.nix</filename>):
-  <option>services.locate.enable</option> (whether the database should be
-  updated) and <option>services.locate.interval</option> (when the update
-  should be done). It implements its functionality by defining two options
-  declared by other modules: <option>systemd.services</option> (the set of all
-  systemd services) and <option>systemd.timers</option> (the list of commands
-  to be executed periodically by <command>systemd</command>).
- </para>
- <example xml:id='locate-example'>
-  <title>NixOS Module for the “locate” Service</title>
-<programlisting>
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-let
-  cfg = config.services.locate;
-in {
-  options.services.locate = {
-    enable = mkOption {
-      type = types.bool;
-      default = false;
-      description = ''
-        If enabled, NixOS will periodically update the database of
-        files used by the <command>locate</command> command.
-      '';
-    };
-
-    interval = mkOption {
-      type = types.str;
-      default = "02:15";
-      example = "hourly";
-      description = ''
-        Update the locate database at this interval. Updates by
-        default at 2:15 AM every day.
-
-        The format is described in
-        <citerefentry><refentrytitle>systemd.time</refentrytitle>
-        <manvolnum>7</manvolnum></citerefentry>.
-      '';
-    };
-
-    # Other options omitted for documentation
-  };
-
-  config = {
-    systemd.services.update-locatedb =
-      { description = "Update Locate Database";
-        path  = [ pkgs.su ];
-        script =
-          ''
-            mkdir -m 0755 -p $(dirname ${toString cfg.output})
-            exec updatedb \
-              --localuser=${cfg.localuser} \
-              ${optionalString (!cfg.includeStore) "--prunepaths='/nix/store'"} \
-              --output=${toString cfg.output} ${concatStringsSep " " cfg.extraFlags}
-          '';
-      };
-
-    systemd.timers.update-locatedb = mkIf cfg.enable
-      { description = "Update timer for locate database";
-        partOf      = [ "update-locatedb.service" ];
-        wantedBy    = [ "timers.target" ];
-        timerConfig.OnCalendar = cfg.interval;
-      };
-  };
-}
-</programlisting>
- </example>
- <xi:include href="option-declarations.xml" />
- <xi:include href="option-types.xml" />
- <xi:include href="option-def.xml" />
- <xi:include href="../from_md/development/assertions.section.xml" />
- <xi:include href="meta-attributes.xml" />
- <xi:include href="importing-modules.xml" />
- <xi:include href="replace-modules.xml" />
- <xi:include href="freeform-modules.xml" />
- <xi:include href="settings-options.xml" />
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/boot-problems.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/boot-problems.section.xml
index 4ea01e78f32f..144661c86eba 100644
--- a/nixpkgs/nixos/doc/manual/from_md/administration/boot-problems.section.xml
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/boot-problems.section.xml
@@ -61,7 +61,7 @@
           <link linkend="opt-fileSystems._name_.neededForBoot">neededForBoot</link>).
           As a motivating example, this could be useful if you’ve
           forgotten to set
-          <link xlink:href="options.html#opt-fileSystems._name_.neededForBoot">neededForBoot</link>
+          <link linkend="opt-fileSystems._name_.neededForBoot">neededForBoot</link>
           on a file system.
         </para>
       </listitem>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/cleaning-store.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/cleaning-store.chapter.xml
new file mode 100644
index 000000000000..0ca98dd6e510
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/cleaning-store.chapter.xml
@@ -0,0 +1,71 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-nix-gc">
+  <title>Cleaning the Nix Store</title>
+  <para>
+    Nix has a purely functional model, meaning that packages are never
+    upgraded in place. Instead new versions of packages end up in a
+    different location in the Nix store (<literal>/nix/store</literal>).
+    You should periodically run Nix’s <emphasis>garbage
+    collector</emphasis> to remove old, unreferenced packages. This is
+    easy:
+  </para>
+  <programlisting>
+$ nix-collect-garbage
+</programlisting>
+  <para>
+    Alternatively, you can use a systemd unit that does the same in the
+    background:
+  </para>
+  <programlisting>
+# systemctl start nix-gc.service
+</programlisting>
+  <para>
+    You can tell NixOS in <literal>configuration.nix</literal> to run
+    this unit automatically at certain points in time, for instance,
+    every night at 03:15:
+  </para>
+  <programlisting language="bash">
+nix.gc.automatic = true;
+nix.gc.dates = &quot;03:15&quot;;
+</programlisting>
+  <para>
+    The commands above do not remove garbage collector roots, such as
+    old system configurations. Thus they do not remove the ability to
+    roll back to previous configurations. The following command deletes
+    old roots, removing the ability to roll back to them:
+  </para>
+  <programlisting>
+$ nix-collect-garbage -d
+</programlisting>
+  <para>
+    You can also do this for specific profiles, e.g.
+  </para>
+  <programlisting>
+$ nix-env -p /nix/var/nix/profiles/per-user/eelco/profile --delete-generations old
+</programlisting>
+  <para>
+    Note that NixOS system configurations are stored in the profile
+    <literal>/nix/var/nix/profiles/system</literal>.
+  </para>
+  <para>
+    Another way to reclaim disk space (often as much as 40% of the size
+    of the Nix store) is to run Nix’s store optimiser, which seeks out
+    identical files in the store and replaces them with hard links to a
+    single copy.
+  </para>
+  <programlisting>
+$ nix-store --optimise
+</programlisting>
+  <para>
+    Since this command needs to read the entire Nix store, it can take
+    quite a while to finish.
+  </para>
+  <section xml:id="sect-nixos-gc-boot-entries">
+    <title>NixOS Boot Entries</title>
+    <para>
+      If your <literal>/boot</literal> partition runs out of space,
+      after clearing old profiles you must rebuild your system with
+      <literal>nixos-rebuild</literal> to update the
+      <literal>/boot</literal> partition and clear space.
+    </para>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/container-networking.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/container-networking.section.xml
new file mode 100644
index 000000000000..788a2b7b0acb
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/container-networking.section.xml
@@ -0,0 +1,54 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-container-networking">
+  <title>Container Networking</title>
+  <para>
+    When you create a container using
+    <literal>nixos-container create</literal>, it gets it own private
+    IPv4 address in the range <literal>10.233.0.0/16</literal>. You can
+    get the container’s IPv4 address as follows:
+  </para>
+  <programlisting>
+# nixos-container show-ip foo
+10.233.4.2
+
+$ ping -c1 10.233.4.2
+64 bytes from 10.233.4.2: icmp_seq=1 ttl=64 time=0.106 ms
+</programlisting>
+  <para>
+    Networking is implemented using a pair of virtual Ethernet devices.
+    The network interface in the container is called
+    <literal>eth0</literal>, while the matching interface in the host is
+    called <literal>ve-container-name</literal> (e.g.,
+    <literal>ve-foo</literal>). The container has its own network
+    namespace and the <literal>CAP_NET_ADMIN</literal> capability, so it
+    can perform arbitrary network configuration such as setting up
+    firewall rules, without affecting or having access to the host’s
+    network.
+  </para>
+  <para>
+    By default, containers cannot talk to the outside network. If you
+    want that, you should set up Network Address Translation (NAT) rules
+    on the host to rewrite container traffic to use your external IP
+    address. This can be accomplished using the following configuration
+    on the host:
+  </para>
+  <programlisting language="bash">
+networking.nat.enable = true;
+networking.nat.internalInterfaces = [&quot;ve-+&quot;];
+networking.nat.externalInterface = &quot;eth0&quot;;
+</programlisting>
+  <para>
+    where <literal>eth0</literal> should be replaced with the desired
+    external interface. Note that <literal>ve-+</literal> is a wildcard
+    that matches all container interfaces.
+  </para>
+  <para>
+    If you are using Network Manager, you need to explicitly prevent it
+    from managing container interfaces:
+  </para>
+  <programlisting language="bash">
+networking.networkmanager.unmanaged = [ &quot;interface-name:ve-*&quot; ];
+</programlisting>
+  <para>
+    You may need to restart your system for the changes to take effect.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/containers.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/containers.chapter.xml
new file mode 100644
index 000000000000..afbd5b35aaa5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/containers.chapter.xml
@@ -0,0 +1,31 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="ch-containers">
+  <title>Container Management</title>
+  <para>
+    NixOS allows you to easily run other NixOS instances as
+    <emphasis>containers</emphasis>. Containers are a light-weight
+    approach to virtualisation that runs software in the container at
+    the same speed as in the host system. NixOS containers share the Nix
+    store of the host, making container creation very efficient.
+  </para>
+  <warning>
+    <para>
+      Currently, NixOS containers are not perfectly isolated from the
+      host system. This means that a user with root access to the
+      container can do things that affect the host. So you should not
+      give container root access to untrusted users.
+    </para>
+  </warning>
+  <para>
+    NixOS containers can be created in two ways: imperatively, using the
+    command <literal>nixos-container</literal>, and declaratively, by
+    specifying them in your <literal>configuration.nix</literal>. The
+    declarative approach implies that containers get upgraded along with
+    your host system when you run <literal>nixos-rebuild</literal>,
+    which is often not what you want. By contrast, in the imperative
+    approach, containers are configured and updated independently from
+    the host system.
+  </para>
+  <xi:include href="imperative-containers.section.xml" />
+  <xi:include href="declarative-containers.section.xml" />
+  <xi:include href="container-networking.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/control-groups.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/control-groups.chapter.xml
new file mode 100644
index 000000000000..8dab2c9d44b4
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/control-groups.chapter.xml
@@ -0,0 +1,67 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-cgroups">
+  <title>Control Groups</title>
+  <para>
+    To keep track of the processes in a running system, systemd uses
+    <emphasis>control groups</emphasis> (cgroups). A control group is a
+    set of processes used to allocate resources such as CPU, memory or
+    I/O bandwidth. There can be multiple control group hierarchies,
+    allowing each kind of resource to be managed independently.
+  </para>
+  <para>
+    The command <literal>systemd-cgls</literal> lists all control groups
+    in the <literal>systemd</literal> hierarchy, which is what systemd
+    uses to keep track of the processes belonging to each service or
+    user session:
+  </para>
+  <programlisting>
+$ systemd-cgls
+├─user
+│ └─eelco
+│   └─c1
+│     ├─ 2567 -:0
+│     ├─ 2682 kdeinit4: kdeinit4 Running...
+│     ├─ ...
+│     └─10851 sh -c less -R
+└─system
+  ├─httpd.service
+  │ ├─2444 httpd -f /nix/store/3pyacby5cpr55a03qwbnndizpciwq161-httpd.conf -DNO_DETACH
+  │ └─...
+  ├─dhcpcd.service
+  │ └─2376 dhcpcd --config /nix/store/f8dif8dsi2yaa70n03xir8r653776ka6-dhcpcd.conf
+  └─ ...
+</programlisting>
+  <para>
+    Similarly, <literal>systemd-cgls cpu</literal> shows the cgroups in
+    the CPU hierarchy, which allows per-cgroup CPU scheduling
+    priorities. By default, every systemd service gets its own CPU
+    cgroup, while all user sessions are in the top-level CPU cgroup.
+    This ensures, for instance, that a thousand run-away processes in
+    the <literal>httpd.service</literal> cgroup cannot starve the CPU
+    for one process in the <literal>postgresql.service</literal> cgroup.
+    (By contrast, it they were in the same cgroup, then the PostgreSQL
+    process would get 1/1001 of the cgroup’s CPU time.) You can limit a
+    service’s CPU share in <literal>configuration.nix</literal>:
+  </para>
+  <programlisting language="bash">
+systemd.services.httpd.serviceConfig.CPUShares = 512;
+</programlisting>
+  <para>
+    By default, every cgroup has 1024 CPU shares, so this will halve the
+    CPU allocation of the <literal>httpd.service</literal> cgroup.
+  </para>
+  <para>
+    There also is a <literal>memory</literal> hierarchy that controls
+    memory allocation limits; by default, all processes are in the
+    top-level cgroup, so any service or session can exhaust all
+    available memory. Per-cgroup memory limits can be specified in
+    <literal>configuration.nix</literal>; for instance, to limit
+    <literal>httpd.service</literal> to 512 MiB of RAM (excluding swap):
+  </para>
+  <programlisting language="bash">
+systemd.services.httpd.serviceConfig.MemoryLimit = &quot;512M&quot;;
+</programlisting>
+  <para>
+    The command <literal>systemd-cgtop</literal> shows a continuously
+    updated list of all cgroups with their CPU and memory usage.
+  </para>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/declarative-containers.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/declarative-containers.section.xml
new file mode 100644
index 000000000000..a918314a2723
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/declarative-containers.section.xml
@@ -0,0 +1,60 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-declarative-containers">
+  <title>Declarative Container Specification</title>
+  <para>
+    You can also specify containers and their configuration in the
+    host’s <literal>configuration.nix</literal>. For example, the
+    following specifies that there shall be a container named
+    <literal>database</literal> running PostgreSQL:
+  </para>
+  <programlisting language="bash">
+containers.database =
+  { config =
+      { config, pkgs, ... }:
+      { services.postgresql.enable = true;
+      services.postgresql.package = pkgs.postgresql_9_6;
+      };
+  };
+</programlisting>
+  <para>
+    If you run <literal>nixos-rebuild switch</literal>, the container
+    will be built. If the container was already running, it will be
+    updated in place, without rebooting. The container can be configured
+    to start automatically by setting
+    <literal>containers.database.autoStart = true</literal> in its
+    configuration.
+  </para>
+  <para>
+    By default, declarative containers share the network namespace of
+    the host, meaning that they can listen on (privileged) ports.
+    However, they cannot change the network configuration. You can give
+    a container its own network as follows:
+  </para>
+  <programlisting language="bash">
+containers.database = {
+  privateNetwork = true;
+  hostAddress = &quot;192.168.100.10&quot;;
+  localAddress = &quot;192.168.100.11&quot;;
+};
+</programlisting>
+  <para>
+    This gives the container a private virtual Ethernet interface with
+    IP address <literal>192.168.100.11</literal>, which is hooked up to
+    a virtual Ethernet interface on the host with IP address
+    <literal>192.168.100.10</literal>. (See the next section for details
+    on container networking.)
+  </para>
+  <para>
+    To disable the container, just remove it from
+    <literal>configuration.nix</literal> and run
+    <literal>nixos-rebuild switch</literal>. Note that this will not
+    delete the root directory of the container in
+    <literal>/var/lib/containers</literal>. Containers can be destroyed
+    using the imperative method:
+    <literal>nixos-container destroy foo</literal>.
+  </para>
+  <para>
+    Declarative containers can be started and stopped using the
+    corresponding systemd service, e.g.
+    <literal>systemctl start container@database</literal>.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/imperative-containers.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/imperative-containers.section.xml
new file mode 100644
index 000000000000..59ecfdee5af0
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/imperative-containers.section.xml
@@ -0,0 +1,131 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-imperative-containers">
+  <title>Imperative Container Management</title>
+  <para>
+    We’ll cover imperative container management using
+    <literal>nixos-container</literal> first. Be aware that container
+    management is currently only possible as <literal>root</literal>.
+  </para>
+  <para>
+    You create a container with identifier <literal>foo</literal> as
+    follows:
+  </para>
+  <programlisting>
+# nixos-container create foo
+</programlisting>
+  <para>
+    This creates the container’s root directory in
+    <literal>/var/lib/containers/foo</literal> and a small configuration
+    file in <literal>/etc/containers/foo.conf</literal>. It also builds
+    the container’s initial system configuration and stores it in
+    <literal>/nix/var/nix/profiles/per-container/foo/system</literal>.
+    You can modify the initial configuration of the container on the
+    command line. For instance, to create a container that has
+    <literal>sshd</literal> running, with the given public key for
+    <literal>root</literal>:
+  </para>
+  <programlisting>
+# nixos-container create foo --config '
+  services.openssh.enable = true;
+  users.users.root.openssh.authorizedKeys.keys = [&quot;ssh-dss AAAAB3N…&quot;];
+'
+</programlisting>
+  <para>
+    By default the next free address in the
+    <literal>10.233.0.0/16</literal> subnet will be chosen as container
+    IP. This behavior can be altered by setting
+    <literal>--host-address</literal> and
+    <literal>--local-address</literal>:
+  </para>
+  <programlisting>
+# nixos-container create test --config-file test-container.nix \
+    --local-address 10.235.1.2 --host-address 10.235.1.1
+</programlisting>
+  <para>
+    Creating a container does not start it. To start the container, run:
+  </para>
+  <programlisting>
+# nixos-container start foo
+</programlisting>
+  <para>
+    This command will return as soon as the container has booted and has
+    reached <literal>multi-user.target</literal>. On the host, the
+    container runs within a systemd unit called
+    <literal>container@container-name.service</literal>. Thus, if
+    something went wrong, you can get status info using
+    <literal>systemctl</literal>:
+  </para>
+  <programlisting>
+# systemctl status container@foo
+</programlisting>
+  <para>
+    If the container has started successfully, you can log in as root
+    using the <literal>root-login</literal> operation:
+  </para>
+  <programlisting>
+# nixos-container root-login foo
+[root@foo:~]#
+</programlisting>
+  <para>
+    Note that only root on the host can do this (since there is no
+    authentication). You can also get a regular login prompt using the
+    <literal>login</literal> operation, which is available to all users
+    on the host:
+  </para>
+  <programlisting>
+# nixos-container login foo
+foo login: alice
+Password: ***
+</programlisting>
+  <para>
+    With <literal>nixos-container run</literal>, you can execute
+    arbitrary commands in the container:
+  </para>
+  <programlisting>
+# nixos-container run foo -- uname -a
+Linux foo 3.4.82 #1-NixOS SMP Thu Mar 20 14:44:05 UTC 2014 x86_64 GNU/Linux
+</programlisting>
+  <para>
+    There are several ways to change the configuration of the container.
+    First, on the host, you can edit
+    <literal>/var/lib/container/name/etc/nixos/configuration.nix</literal>,
+    and run
+  </para>
+  <programlisting>
+# nixos-container update foo
+</programlisting>
+  <para>
+    This will build and activate the new configuration. You can also
+    specify a new configuration on the command line:
+  </para>
+  <programlisting>
+# nixos-container update foo --config '
+  services.httpd.enable = true;
+  services.httpd.adminAddr = &quot;foo@example.org&quot;;
+  networking.firewall.allowedTCPPorts = [ 80 ];
+'
+
+# curl http://$(nixos-container show-ip foo)/
+&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 3.2 Final//EN&quot;&gt;…
+</programlisting>
+  <para>
+    However, note that this will overwrite the container’s
+    <literal>/etc/nixos/configuration.nix</literal>.
+  </para>
+  <para>
+    Alternatively, you can change the configuration from within the
+    container itself by running <literal>nixos-rebuild switch</literal>
+    inside the container. Note that the container by default does not
+    have a copy of the NixOS channel, so you should run
+    <literal>nix-channel --update</literal> first.
+  </para>
+  <para>
+    Containers can be stopped and started using
+    <literal>nixos-container stop</literal> and
+    <literal>nixos-container start</literal>, respectively, or by using
+    <literal>systemctl</literal> on the container’s service unit. To
+    destroy a container, including its file system, do
+  </para>
+  <programlisting>
+# nixos-container destroy foo
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/logging.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/logging.chapter.xml
new file mode 100644
index 000000000000..4da38c065a27
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/logging.chapter.xml
@@ -0,0 +1,45 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-logging">
+  <title>Logging</title>
+  <para>
+    System-wide logging is provided by systemd’s
+    <emphasis>journal</emphasis>, which subsumes traditional logging
+    daemons such as syslogd and klogd. Log entries are kept in binary
+    files in <literal>/var/log/journal/</literal>. The command
+    <literal>journalctl</literal> allows you to see the contents of the
+    journal. For example,
+  </para>
+  <programlisting>
+$ journalctl -b
+</programlisting>
+  <para>
+    shows all journal entries since the last reboot. (The output of
+    <literal>journalctl</literal> is piped into <literal>less</literal>
+    by default.) You can use various options and match operators to
+    restrict output to messages of interest. For instance, to get all
+    messages from PostgreSQL:
+  </para>
+  <programlisting>
+$ journalctl -u postgresql.service
+-- Logs begin at Mon, 2013-01-07 13:28:01 CET, end at Tue, 2013-01-08 01:09:57 CET. --
+...
+Jan 07 15:44:14 hagbard postgres[2681]: [2-1] LOG:  database system is shut down
+-- Reboot --
+Jan 07 15:45:10 hagbard postgres[2532]: [1-1] LOG:  database system was shut down at 2013-01-07 15:44:14 CET
+Jan 07 15:45:13 hagbard postgres[2500]: [1-1] LOG:  database system is ready to accept connections
+</programlisting>
+  <para>
+    Or to get all messages since the last reboot that have at least a
+    <quote>critical</quote> severity level:
+  </para>
+  <programlisting>
+$ journalctl -b -p crit
+Dec 17 21:08:06 mandark sudo[3673]: pam_unix(sudo:auth): auth could not identify password for [alice]
+Dec 29 01:30:22 mandark kernel[6131]: [1053513.909444] CPU6: Core temperature above threshold, cpu clock throttled (total events = 1)
+</programlisting>
+  <para>
+    The system journal is readable by root and by users in the
+    <literal>wheel</literal> and <literal>systemd-journal</literal>
+    groups. All users have a private journal that can be read using
+    <literal>journalctl</literal>.
+  </para>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/maintenance-mode.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/maintenance-mode.section.xml
new file mode 100644
index 000000000000..c86b1911c117
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/maintenance-mode.section.xml
@@ -0,0 +1,14 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-maintenance-mode">
+  <title>Maintenance Mode</title>
+  <para>
+    You can enter rescue mode by running:
+  </para>
+  <programlisting>
+# systemctl rescue
+</programlisting>
+  <para>
+    This will eventually give you a single-user root shell. Systemd will
+    stop (almost) all system services. To get out of maintenance mode,
+    just exit from the rescue shell.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/network-problems.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/network-problems.section.xml
new file mode 100644
index 000000000000..4c0598ca94e8
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/network-problems.section.xml
@@ -0,0 +1,25 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-nix-network-issues">
+  <title>Network Problems</title>
+  <para>
+    Nix uses a so-called <emphasis>binary cache</emphasis> to optimise
+    building a package from source into downloading it as a pre-built
+    binary. That is, whenever a command like
+    <literal>nixos-rebuild</literal> needs a path in the Nix store, Nix
+    will try to download that path from the Internet rather than build
+    it from source. The default binary cache is
+    <literal>https://cache.nixos.org/</literal>. If this cache is
+    unreachable, Nix operations may take a long time due to HTTP
+    connection timeouts. You can disable the use of the binary cache by
+    adding <literal>--option use-binary-caches false</literal>, e.g.
+  </para>
+  <programlisting>
+# nixos-rebuild switch --option use-binary-caches false
+</programlisting>
+  <para>
+    If you have an alternative binary cache at your disposal, you can
+    use it instead:
+  </para>
+  <programlisting>
+# nixos-rebuild switch --option binary-caches http://my-cache.example.org/
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/rebooting.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/rebooting.chapter.xml
new file mode 100644
index 000000000000..78ee75afb642
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/rebooting.chapter.xml
@@ -0,0 +1,38 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-rebooting">
+  <title>Rebooting and Shutting Down</title>
+  <para>
+    The system can be shut down (and automatically powered off) by
+    doing:
+  </para>
+  <programlisting>
+# shutdown
+</programlisting>
+  <para>
+    This is equivalent to running <literal>systemctl poweroff</literal>.
+  </para>
+  <para>
+    To reboot the system, run
+  </para>
+  <programlisting>
+# reboot
+</programlisting>
+  <para>
+    which is equivalent to <literal>systemctl reboot</literal>.
+    Alternatively, you can quickly reboot the system using
+    <literal>kexec</literal>, which bypasses the BIOS by directly
+    loading the new kernel into memory:
+  </para>
+  <programlisting>
+# systemctl kexec
+</programlisting>
+  <para>
+    The machine can be suspended to RAM (if supported) using
+    <literal>systemctl suspend</literal>, and suspended to disk using
+    <literal>systemctl hibernate</literal>.
+  </para>
+  <para>
+    These commands can be run by any user who is logged in locally, i.e.
+    on a virtual console or in X11; otherwise, the user is asked for
+    authentication.
+  </para>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/rollback.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/rollback.section.xml
new file mode 100644
index 000000000000..a8df053011c5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/rollback.section.xml
@@ -0,0 +1,42 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-rollback">
+  <title>Rolling Back Configuration Changes</title>
+  <para>
+    After running <literal>nixos-rebuild</literal> to switch to a new
+    configuration, you may find that the new configuration doesn’t work
+    very well. In that case, there are several ways to return to a
+    previous configuration.
+  </para>
+  <para>
+    First, the GRUB boot manager allows you to boot into any previous
+    configuration that hasn’t been garbage-collected. These
+    configurations can be found under the GRUB submenu <quote>NixOS -
+    All configurations</quote>. This is especially useful if the new
+    configuration fails to boot. After the system has booted, you can
+    make the selected configuration the default for subsequent boots:
+  </para>
+  <programlisting>
+# /run/current-system/bin/switch-to-configuration boot
+</programlisting>
+  <para>
+    Second, you can switch to the previous configuration in a running
+    system:
+  </para>
+  <programlisting>
+# nixos-rebuild switch --rollback
+</programlisting>
+  <para>
+    This is equivalent to running:
+  </para>
+  <programlisting>
+# /nix/var/nix/profiles/system-N-link/bin/switch-to-configuration switch
+</programlisting>
+  <para>
+    where <literal>N</literal> is the number of the NixOS system
+    configuration. To get a list of the available configurations, do:
+  </para>
+  <programlisting>
+$ ls -l /nix/var/nix/profiles/system-*-link
+...
+lrwxrwxrwx 1 root root 78 Aug 12 13:54 /nix/var/nix/profiles/system-268-link -&gt; /nix/store/202b...-nixos-13.07pre4932_5a676e4-4be1055
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/service-mgmt.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/service-mgmt.chapter.xml
new file mode 100644
index 000000000000..8b01b8f896a4
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/service-mgmt.chapter.xml
@@ -0,0 +1,141 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-systemctl">
+  <title>Service Management</title>
+  <para>
+    In NixOS, all system services are started and monitored using the
+    systemd program. systemd is the <quote>init</quote> process of the
+    system (i.e. PID 1), the parent of all other processes. It manages a
+    set of so-called <quote>units</quote>, which can be things like
+    system services (programs), but also mount points, swap files,
+    devices, targets (groups of units) and more. Units can have complex
+    dependencies; for instance, one unit can require that another unit
+    must be successfully started before the first unit can be started.
+    When the system boots, it starts a unit named
+    <literal>default.target</literal>; the dependencies of this unit
+    cause all system services to be started, file systems to be mounted,
+    swap files to be activated, and so on.
+  </para>
+  <section xml:id="sect-nixos-systemd-general">
+    <title>Interacting with a running systemd</title>
+    <para>
+      The command <literal>systemctl</literal> is the main way to
+      interact with <literal>systemd</literal>. The following paragraphs
+      demonstrate ways to interact with any OS running systemd as init
+      system. NixOS is of no exception. The
+      <link linkend="sect-nixos-systemd-nixos">next section </link>
+      explains NixOS specific things worth knowing.
+    </para>
+    <para>
+      Without any arguments, <literal>systemctl</literal> the status of
+      active units:
+    </para>
+    <programlisting>
+$ systemctl
+-.mount          loaded active mounted   /
+swapfile.swap    loaded active active    /swapfile
+sshd.service     loaded active running   SSH Daemon
+graphical.target loaded active active    Graphical Interface
+...
+</programlisting>
+    <para>
+      You can ask for detailed status information about a unit, for
+      instance, the PostgreSQL database service:
+    </para>
+    <programlisting>
+$ systemctl status postgresql.service
+postgresql.service - PostgreSQL Server
+          Loaded: loaded (/nix/store/pn3q73mvh75gsrl8w7fdlfk3fq5qm5mw-unit/postgresql.service)
+          Active: active (running) since Mon, 2013-01-07 15:55:57 CET; 9h ago
+        Main PID: 2390 (postgres)
+          CGroup: name=systemd:/system/postgresql.service
+                  ├─2390 postgres
+                  ├─2418 postgres: writer process
+                  ├─2419 postgres: wal writer process
+                  ├─2420 postgres: autovacuum launcher process
+                  ├─2421 postgres: stats collector process
+                  └─2498 postgres: zabbix zabbix [local] idle
+
+Jan 07 15:55:55 hagbard postgres[2394]: [1-1] LOG:  database system was shut down at 2013-01-07 15:55:05 CET
+Jan 07 15:55:57 hagbard postgres[2390]: [1-1] LOG:  database system is ready to accept connections
+Jan 07 15:55:57 hagbard postgres[2420]: [1-1] LOG:  autovacuum launcher started
+Jan 07 15:55:57 hagbard systemd[1]: Started PostgreSQL Server.
+</programlisting>
+    <para>
+      Note that this shows the status of the unit (active and running),
+      all the processes belonging to the service, as well as the most
+      recent log messages from the service.
+    </para>
+    <para>
+      Units can be stopped, started or restarted:
+    </para>
+    <programlisting>
+# systemctl stop postgresql.service
+# systemctl start postgresql.service
+# systemctl restart postgresql.service
+</programlisting>
+    <para>
+      These operations are synchronous: they wait until the service has
+      finished starting or stopping (or has failed). Starting a unit
+      will cause the dependencies of that unit to be started as well (if
+      necessary).
+    </para>
+  </section>
+  <section xml:id="sect-nixos-systemd-nixos">
+    <title>systemd in NixOS</title>
+    <para>
+      Packages in Nixpkgs sometimes provide systemd units with them,
+      usually in e.g <literal>#pkg-out#/lib/systemd/</literal>. Putting
+      such a package in <literal>environment.systemPackages</literal>
+      doesn't make the service available to users or the system.
+    </para>
+    <para>
+      In order to enable a systemd <emphasis>system</emphasis> service
+      with provided upstream package, use (e.g):
+    </para>
+    <programlisting language="bash">
+systemd.packages = [ pkgs.packagekit ];
+</programlisting>
+    <para>
+      Usually NixOS modules written by the community do the above, plus
+      take care of other details. If a module was written for a service
+      you are interested in, you'd probably need only to use
+      <literal>services.#name#.enable = true;</literal>. These services
+      are defined in Nixpkgs'
+      <link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/modules">
+      <literal>nixos/modules/</literal> directory </link>. In case the
+      service is simple enough, the above method should work, and start
+      the service on boot.
+    </para>
+    <para>
+      <emphasis>User</emphasis> systemd services on the other hand,
+      should be treated differently. Given a package that has a systemd
+      unit file at <literal>#pkg-out#/lib/systemd/user/</literal>, using
+      <xref linkend="opt-systemd.packages" /> will make you able to
+      start the service via <literal>systemctl --user start</literal>,
+      but it won't start automatically on login. However, You can
+      imperatively enable it by adding the package's attribute to
+      <xref linkend="opt-systemd.packages" /> and then do this (e.g):
+    </para>
+    <programlisting>
+$ mkdir -p ~/.config/systemd/user/default.target.wants
+$ ln -s /run/current-system/sw/lib/systemd/user/syncthing.service ~/.config/systemd/user/default.target.wants/
+$ systemctl --user daemon-reload
+$ systemctl --user enable syncthing.service
+</programlisting>
+    <para>
+      If you are interested in a timer file, use
+      <literal>timers.target.wants</literal> instead of
+      <literal>default.target.wants</literal> in the 1st and 2nd
+      command.
+    </para>
+    <para>
+      Using <literal>systemctl --user enable syncthing.service</literal>
+      instead of the above, will work, but it'll use the absolute path
+      of <literal>syncthing.service</literal> for the symlink, and this
+      path is in <literal>/nix/store/.../lib/systemd/user/</literal>.
+      Hence <link linkend="sec-nix-gc">garbage collection</link> will
+      remove that file and you will wind up with a broken symlink in
+      your systemd configuration, which in turn will not make the
+      service / timer start on login.
+    </para>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/store-corruption.section.xml b/nixpkgs/nixos/doc/manual/from_md/administration/store-corruption.section.xml
new file mode 100644
index 000000000000..9ed572d484dc
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/store-corruption.section.xml
@@ -0,0 +1,34 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-nix-store-corruption">
+  <title>Nix Store Corruption</title>
+  <para>
+    After a system crash, it’s possible for files in the Nix store to
+    become corrupted. (For instance, the Ext4 file system has the
+    tendency to replace un-synced files with zero bytes.) NixOS tries
+    hard to prevent this from happening: it performs a
+    <literal>sync</literal> before switching to a new configuration, and
+    Nix’s database is fully transactional. If corruption still occurs,
+    you may be able to fix it automatically.
+  </para>
+  <para>
+    If the corruption is in a path in the closure of the NixOS system
+    configuration, you can fix it by doing
+  </para>
+  <programlisting>
+# nixos-rebuild switch --repair
+</programlisting>
+  <para>
+    This will cause Nix to check every path in the closure, and if its
+    cryptographic hash differs from the hash recorded in Nix’s database,
+    the path is rebuilt or redownloaded.
+  </para>
+  <para>
+    You can also scan the entire Nix store for corrupt paths:
+  </para>
+  <programlisting>
+# nix-store --verify --check-contents --repair
+</programlisting>
+  <para>
+    Any corrupt paths will be redownloaded if they’re available in a
+    binary cache; otherwise, they cannot be repaired.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/troubleshooting.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/troubleshooting.chapter.xml
new file mode 100644
index 000000000000..8bbb8a1fe729
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/troubleshooting.chapter.xml
@@ -0,0 +1,12 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="ch-troubleshooting">
+  <title>Troubleshooting</title>
+  <para>
+    This chapter describes solutions to common problems you might
+    encounter when you manage your NixOS system.
+  </para>
+  <xi:include href="boot-problems.section.xml" />
+  <xi:include href="maintenance-mode.section.xml" />
+  <xi:include href="rollback.section.xml" />
+  <xi:include href="store-corruption.section.xml" />
+  <xi:include href="network-problems.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/administration/user-sessions.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/administration/user-sessions.chapter.xml
new file mode 100644
index 000000000000..e8c64f153fc5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/administration/user-sessions.chapter.xml
@@ -0,0 +1,46 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-user-sessions">
+  <title>User Sessions</title>
+  <para>
+    Systemd keeps track of all users who are logged into the system
+    (e.g. on a virtual console or remotely via SSH). The command
+    <literal>loginctl</literal> allows querying and manipulating user
+    sessions. For instance, to list all user sessions:
+  </para>
+  <programlisting>
+$ loginctl
+   SESSION        UID USER             SEAT
+        c1        500 eelco            seat0
+        c3          0 root             seat0
+        c4        500 alice
+</programlisting>
+  <para>
+    This shows that two users are logged in locally, while another is
+    logged in remotely. (<quote>Seats</quote> are essentially the
+    combinations of displays and input devices attached to the system;
+    usually, there is only one seat.) To get information about a
+    session:
+  </para>
+  <programlisting>
+$ loginctl session-status c3
+c3 - root (0)
+           Since: Tue, 2013-01-08 01:17:56 CET; 4min 42s ago
+          Leader: 2536 (login)
+            Seat: seat0; vc3
+             TTY: /dev/tty3
+         Service: login; type tty; class user
+           State: online
+          CGroup: name=systemd:/user/root/c3
+                  ├─ 2536 /nix/store/10mn4xip9n7y9bxqwnsx7xwx2v2g34xn-shadow-4.1.5.1/bin/login --
+                  ├─10339 -bash
+                  └─10355 w3m nixos.org
+</programlisting>
+  <para>
+    This shows that the user is logged in on virtual console 3. It also
+    lists the processes belonging to this session. Since systemd keeps
+    track of this, you can terminate a session in a way that ensures
+    that all the session’s processes are gone:
+  </para>
+  <programlisting>
+# loginctl terminate-session c3
+</programlisting>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-network-config.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-network-config.section.xml
new file mode 100644
index 000000000000..035ee3122e15
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-network-config.section.xml
@@ -0,0 +1,16 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="ad-hoc-network-config">
+  <title>Ad-Hoc Configuration</title>
+  <para>
+    You can use <xref linkend="opt-networking.localCommands" /> to
+    specify shell commands to be run at the end of
+    <literal>network-setup.service</literal>. This is useful for doing
+    network configuration not covered by the existing NixOS modules. For
+    instance, to statically configure an IPv6 address:
+  </para>
+  <programlisting language="bash">
+networking.localCommands =
+  ''
+    ip -6 addr add 2001:610:685:1::1/64 dev eth0
+  '';
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-packages.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-packages.section.xml
new file mode 100644
index 000000000000..c9a8d4f3f106
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/ad-hoc-packages.section.xml
@@ -0,0 +1,59 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-ad-hoc-packages">
+  <title>Ad-Hoc Package Management</title>
+  <para>
+    With the command <literal>nix-env</literal>, you can install and
+    uninstall packages from the command line. For instance, to install
+    Mozilla Thunderbird:
+  </para>
+  <programlisting>
+$ nix-env -iA nixos.thunderbird
+</programlisting>
+  <para>
+    If you invoke this as root, the package is installed in the Nix
+    profile <literal>/nix/var/nix/profiles/default</literal> and visible
+    to all users of the system; otherwise, the package ends up in
+    <literal>/nix/var/nix/profiles/per-user/username/profile</literal>
+    and is not visible to other users. The <literal>-A</literal> flag
+    specifies the package by its attribute name; without it, the package
+    is installed by matching against its package name (e.g.
+    <literal>thunderbird</literal>). The latter is slower because it
+    requires matching against all available Nix packages, and is
+    ambiguous if there are multiple matching packages.
+  </para>
+  <para>
+    Packages come from the NixOS channel. You typically upgrade a
+    package by updating to the latest version of the NixOS channel:
+  </para>
+  <programlisting>
+$ nix-channel --update nixos
+</programlisting>
+  <para>
+    and then running <literal>nix-env -i</literal> again. Other packages
+    in the profile are <emphasis>not</emphasis> affected; this is the
+    crucial difference with the declarative style of package management,
+    where running <literal>nixos-rebuild switch</literal> causes all
+    packages to be updated to their current versions in the NixOS
+    channel. You can however upgrade all packages for which there is a
+    newer version by doing:
+  </para>
+  <programlisting>
+$ nix-env -u '*'
+</programlisting>
+  <para>
+    A package can be uninstalled using the <literal>-e</literal> flag:
+  </para>
+  <programlisting>
+$ nix-env -e thunderbird
+</programlisting>
+  <para>
+    Finally, you can roll back an undesirable <literal>nix-env</literal>
+    action:
+  </para>
+  <programlisting>
+$ nix-env --rollback
+</programlisting>
+  <para>
+    <literal>nix-env</literal> has many more flags. For details, see the
+    nix-env(1) manpage or the Nix manual.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/adding-custom-packages.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/adding-custom-packages.section.xml
new file mode 100644
index 000000000000..4fa40d61966e
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/adding-custom-packages.section.xml
@@ -0,0 +1,80 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-custom-packages">
+  <title>Adding Custom Packages</title>
+  <para>
+    It’s possible that a package you need is not available in NixOS. In
+    that case, you can do two things. First, you can clone the Nixpkgs
+    repository, add the package to your clone, and (optionally) submit a
+    patch or pull request to have it accepted into the main Nixpkgs
+    repository. This is described in detail in the
+    <link xlink:href="https://nixos.org/nixpkgs/manual">Nixpkgs
+    manual</link>. In short, you clone Nixpkgs:
+  </para>
+  <programlisting>
+$ git clone https://github.com/NixOS/nixpkgs
+$ cd nixpkgs
+</programlisting>
+  <para>
+    Then you write and test the package as described in the Nixpkgs
+    manual. Finally, you add it to
+    <xref linkend="opt-environment.systemPackages" />, e.g.
+  </para>
+  <programlisting language="bash">
+environment.systemPackages = [ pkgs.my-package ];
+</programlisting>
+  <para>
+    and you run <literal>nixos-rebuild</literal>, specifying your own
+    Nixpkgs tree:
+  </para>
+  <programlisting>
+# nixos-rebuild switch -I nixpkgs=/path/to/my/nixpkgs
+</programlisting>
+  <para>
+    The second possibility is to add the package outside of the Nixpkgs
+    tree. For instance, here is how you specify a build of the
+    <link xlink:href="https://www.gnu.org/software/hello/">GNU
+    Hello</link> package directly in
+    <literal>configuration.nix</literal>:
+  </para>
+  <programlisting language="bash">
+environment.systemPackages =
+  let
+    my-hello = with pkgs; stdenv.mkDerivation rec {
+      name = &quot;hello-2.8&quot;;
+      src = fetchurl {
+        url = &quot;mirror://gnu/hello/${name}.tar.gz&quot;;
+        sha256 = &quot;0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6&quot;;
+      };
+    };
+  in
+  [ my-hello ];
+</programlisting>
+  <para>
+    Of course, you can also move the definition of
+    <literal>my-hello</literal> into a separate Nix expression, e.g.
+  </para>
+  <programlisting language="bash">
+environment.systemPackages = [ (import ./my-hello.nix) ];
+</programlisting>
+  <para>
+    where <literal>my-hello.nix</literal> contains:
+  </para>
+  <programlisting language="bash">
+with import &lt;nixpkgs&gt; {}; # bring all of Nixpkgs into scope
+
+stdenv.mkDerivation rec {
+  name = &quot;hello-2.8&quot;;
+  src = fetchurl {
+    url = &quot;mirror://gnu/hello/${name}.tar.gz&quot;;
+    sha256 = &quot;0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6&quot;;
+  };
+}
+</programlisting>
+  <para>
+    This allows testing the package easily:
+  </para>
+  <programlisting>
+$ nix-build my-hello.nix
+$ ./result/bin/hello
+Hello, world!
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/config-file.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/config-file.section.xml
new file mode 100644
index 000000000000..952c6e600302
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/config-file.section.xml
@@ -0,0 +1,231 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-configuration-file">
+  <title>NixOS Configuration File</title>
+  <para>
+    The NixOS configuration file generally looks like this:
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{ option definitions
+}
+</programlisting>
+  <para>
+    The first line (<literal>{ config, pkgs, ... }:</literal>) denotes
+    that this is actually a function that takes at least the two
+    arguments <literal>config</literal> and <literal>pkgs</literal>.
+    (These are explained later, in chapter
+    <xref linkend="sec-writing-modules" />) The function returns a
+    <emphasis>set</emphasis> of option definitions
+    (<literal>{ ... }</literal>). These definitions have the form
+    <literal>name = value</literal>, where <literal>name</literal> is
+    the name of an option and <literal>value</literal> is its value. For
+    example,
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{ services.httpd.enable = true;
+  services.httpd.adminAddr = &quot;alice@example.org&quot;;
+  services.httpd.virtualHosts.localhost.documentRoot = &quot;/webroot&quot;;
+}
+</programlisting>
+  <para>
+    defines a configuration with three option definitions that together
+    enable the Apache HTTP Server with <literal>/webroot</literal> as
+    the document root.
+  </para>
+  <para>
+    Sets can be nested, and in fact dots in option names are shorthand
+    for defining a set containing another set. For instance,
+    <xref linkend="opt-services.httpd.enable" /> defines a set named
+    <literal>services</literal> that contains a set named
+    <literal>httpd</literal>, which in turn contains an option
+    definition named <literal>enable</literal> with value
+    <literal>true</literal>. This means that the example above can also
+    be written as:
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{ services = {
+    httpd = {
+      enable = true;
+      adminAddr = &quot;alice@example.org&quot;;
+      virtualHosts = {
+        localhost = {
+          documentRoot = &quot;/webroot&quot;;
+        };
+      };
+    };
+  };
+}
+</programlisting>
+  <para>
+    which may be more convenient if you have lots of option definitions
+    that share the same prefix (such as
+    <literal>services.httpd</literal>).
+  </para>
+  <para>
+    NixOS checks your option definitions for correctness. For instance,
+    if you try to define an option that doesn’t exist (that is, doesn’t
+    have a corresponding <emphasis>option declaration</emphasis>),
+    <literal>nixos-rebuild</literal> will give an error like:
+  </para>
+  <programlisting>
+The option `services.httpd.enable' defined in `/etc/nixos/configuration.nix' does not exist.
+</programlisting>
+  <para>
+    Likewise, values in option definitions must have a correct type. For
+    instance, <literal>services.httpd.enable</literal> must be a Boolean
+    (<literal>true</literal> or <literal>false</literal>). Trying to
+    give it a value of another type, such as a string, will cause an
+    error:
+  </para>
+  <programlisting>
+The option value `services.httpd.enable' in `/etc/nixos/configuration.nix' is not a boolean.
+</programlisting>
+  <para>
+    Options have various types of values. The most important are:
+  </para>
+  <variablelist>
+    <varlistentry>
+      <term>
+        Strings
+      </term>
+      <listitem>
+        <para>
+          Strings are enclosed in double quotes, e.g.
+        </para>
+        <programlisting language="bash">
+networking.hostName = &quot;dexter&quot;;
+</programlisting>
+        <para>
+          Special characters can be escaped by prefixing them with a
+          backslash (e.g. <literal>\&quot;</literal>).
+        </para>
+        <para>
+          Multi-line strings can be enclosed in <emphasis>double single
+          quotes</emphasis>, e.g.
+        </para>
+        <programlisting language="bash">
+networking.extraHosts =
+  ''
+    127.0.0.2 other-localhost
+    10.0.0.1 server
+  '';
+</programlisting>
+        <para>
+          The main difference is that it strips from each line a number
+          of spaces equal to the minimal indentation of the string as a
+          whole (disregarding the indentation of empty lines), and that
+          characters like <literal>&quot;</literal> and
+          <literal>\</literal> are not special (making it more
+          convenient for including things like shell code). See more
+          info about this in the Nix manual
+          <link xlink:href="https://nixos.org/nix/manual/#ssec-values">here</link>.
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        Booleans
+      </term>
+      <listitem>
+        <para>
+          These can be <literal>true</literal> or
+          <literal>false</literal>, e.g.
+        </para>
+        <programlisting language="bash">
+networking.firewall.enable = true;
+networking.firewall.allowPing = false;
+</programlisting>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        Integers
+      </term>
+      <listitem>
+        <para>
+          For example,
+        </para>
+        <programlisting language="bash">
+boot.kernel.sysctl.&quot;net.ipv4.tcp_keepalive_time&quot; = 60;
+</programlisting>
+        <para>
+          (Note that here the attribute name
+          <literal>net.ipv4.tcp_keepalive_time</literal> is enclosed in
+          quotes to prevent it from being interpreted as a set named
+          <literal>net</literal> containing a set named
+          <literal>ipv4</literal>, and so on. This is because it’s not a
+          NixOS option but the literal name of a Linux kernel setting.)
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        Sets
+      </term>
+      <listitem>
+        <para>
+          Sets were introduced above. They are name/value pairs enclosed
+          in braces, as in the option definition
+        </para>
+        <programlisting language="bash">
+fileSystems.&quot;/boot&quot; =
+  { device = &quot;/dev/sda1&quot;;
+    fsType = &quot;ext4&quot;;
+    options = [ &quot;rw&quot; &quot;data=ordered&quot; &quot;relatime&quot; ];
+  };
+</programlisting>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        Lists
+      </term>
+      <listitem>
+        <para>
+          The important thing to note about lists is that list elements
+          are separated by whitespace, like this:
+        </para>
+        <programlisting language="bash">
+boot.kernelModules = [ &quot;fuse&quot; &quot;kvm-intel&quot; &quot;coretemp&quot; ];
+</programlisting>
+        <para>
+          List elements can be any other type, e.g. sets:
+        </para>
+        <programlisting language="bash">
+swapDevices = [ { device = &quot;/dev/disk/by-label/swap&quot;; } ];
+</programlisting>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        Packages
+      </term>
+      <listitem>
+        <para>
+          Usually, the packages you need are already part of the Nix
+          Packages collection, which is a set that can be accessed
+          through the function argument <literal>pkgs</literal>. Typical
+          uses:
+        </para>
+        <programlisting language="bash">
+environment.systemPackages =
+  [ pkgs.thunderbird
+    pkgs.emacs
+  ];
+
+services.postgresql.package = pkgs.postgresql_10;
+</programlisting>
+        <para>
+          The latter option definition changes the default PostgreSQL
+          package used by NixOS’s PostgreSQL service to 10.x. For more
+          information on packages, including how to add new ones, see
+          <xref linkend="sec-custom-packages" />.
+        </para>
+      </listitem>
+    </varlistentry>
+  </variablelist>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/config-syntax.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/config-syntax.chapter.xml
new file mode 100644
index 000000000000..01446e53e38f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/config-syntax.chapter.xml
@@ -0,0 +1,21 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-configuration-syntax">
+  <title>Configuration Syntax</title>
+  <para>
+    The NixOS configuration file
+    <literal>/etc/nixos/configuration.nix</literal> is actually a
+    <emphasis>Nix expression</emphasis>, which is the Nix package
+    manager’s purely functional language for describing how to build
+    packages and configurations. This means you have all the expressive
+    power of that language at your disposal, including the ability to
+    abstract over common patterns, which is very useful when managing
+    complex systems. The syntax and semantics of the Nix language are
+    fully described in the
+    <link xlink:href="https://nixos.org/nix/manual/#chap-writing-nix-expressions">Nix
+    manual</link>, but here we give a short overview of the most
+    important constructs useful in NixOS configuration files.
+  </para>
+  <xi:include href="config-file.section.xml" />
+  <xi:include href="abstractions.section.xml" />
+  <xi:include href="modularity.section.xml" />
+  <xi:include href="summary.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/customizing-packages.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/customizing-packages.section.xml
new file mode 100644
index 000000000000..f78b5dc5460c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/customizing-packages.section.xml
@@ -0,0 +1,90 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-customising-packages">
+  <title>Customising Packages</title>
+  <para>
+    Some packages in Nixpkgs have options to enable or disable optional
+    functionality or change other aspects of the package. For instance,
+    the Firefox wrapper package (which provides Firefox with a set of
+    plugins such as the Adobe Flash player) has an option to enable the
+    Google Talk plugin. It can be set in
+    <literal>configuration.nix</literal> as follows:
+    <literal>nixpkgs.config.firefox.enableGoogleTalkPlugin = true;</literal>
+  </para>
+  <warning>
+    <para>
+      Unfortunately, Nixpkgs currently lacks a way to query available
+      configuration options.
+    </para>
+  </warning>
+  <para>
+    Apart from high-level options, it’s possible to tweak a package in
+    almost arbitrary ways, such as changing or disabling dependencies of
+    a package. For instance, the Emacs package in Nixpkgs by default has
+    a dependency on GTK 2. If you want to build it against GTK 3, you
+    can specify that as follows:
+  </para>
+  <programlisting language="bash">
+environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ];
+</programlisting>
+  <para>
+    The function <literal>override</literal> performs the call to the
+    Nix function that produces Emacs, with the original arguments
+    amended by the set of arguments specified by you. So here the
+    function argument <literal>gtk</literal> gets the value
+    <literal>pkgs.gtk3</literal>, causing Emacs to depend on GTK 3. (The
+    parentheses are necessary because in Nix, function application binds
+    more weakly than list construction, so without them,
+    <xref linkend="opt-environment.systemPackages" /> would be a list
+    with two elements.)
+  </para>
+  <para>
+    Even greater customisation is possible using the function
+    <literal>overrideAttrs</literal>. While the
+    <literal>override</literal> mechanism above overrides the arguments
+    of a package function, <literal>overrideAttrs</literal> allows
+    changing the <emphasis>attributes</emphasis> passed to
+    <literal>mkDerivation</literal>. This permits changing any aspect of
+    the package, such as the source code. For instance, if you want to
+    override the source code of Emacs, you can say:
+  </para>
+  <programlisting language="bash">
+environment.systemPackages = [
+  (pkgs.emacs.overrideAttrs (oldAttrs: {
+    name = &quot;emacs-25.0-pre&quot;;
+    src = /path/to/my/emacs/tree;
+  }))
+];
+</programlisting>
+  <para>
+    Here, <literal>overrideAttrs</literal> takes the Nix derivation
+    specified by <literal>pkgs.emacs</literal> and produces a new
+    derivation in which the original’s <literal>name</literal> and
+    <literal>src</literal> attribute have been replaced by the given
+    values by re-calling <literal>stdenv.mkDerivation</literal>. The
+    original attributes are accessible via the function argument, which
+    is conventionally named <literal>oldAttrs</literal>.
+  </para>
+  <para>
+    The overrides shown above are not global. They do not affect the
+    original package; other packages in Nixpkgs continue to depend on
+    the original rather than the customised package. This means that if
+    another package in your system depends on the original package, you
+    end up with two instances of the package. If you want to have
+    everything depend on your customised instance, you can apply a
+    <emphasis>global</emphasis> override as follows:
+  </para>
+  <programlisting language="bash">
+nixpkgs.config.packageOverrides = pkgs:
+  { emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };
+  };
+</programlisting>
+  <para>
+    The effect of this definition is essentially equivalent to modifying
+    the <literal>emacs</literal> attribute in the Nixpkgs source tree.
+    Any package in Nixpkgs that depends on <literal>emacs</literal> will
+    be passed your customised instance. (However, the value
+    <literal>pkgs.emacs</literal> in
+    <literal>nixpkgs.config.packageOverrides</literal> refers to the
+    original rather than overridden instance, to prevent an infinite
+    recursion.)
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/declarative-packages.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/declarative-packages.section.xml
new file mode 100644
index 000000000000..da31f18d9233
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/declarative-packages.section.xml
@@ -0,0 +1,53 @@
+<section xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-declarative-package-mgmt">
+  <title>Declarative Package Management</title>
+  <para>
+    With declarative package management, you specify which packages you
+    want on your system by setting the option
+    <xref linkend="opt-environment.systemPackages" />. For instance,
+    adding the following line to <literal>configuration.nix</literal>
+    enables the Mozilla Thunderbird email application:
+  </para>
+  <programlisting language="bash">
+environment.systemPackages = [ pkgs.thunderbird ];
+</programlisting>
+  <para>
+    The effect of this specification is that the Thunderbird package
+    from Nixpkgs will be built or downloaded as part of the system when
+    you run <literal>nixos-rebuild switch</literal>.
+  </para>
+  <note>
+    <para>
+      Some packages require additional global configuration such as
+      D-Bus or systemd service registration so adding them to
+      <xref linkend="opt-environment.systemPackages" /> might not be
+      sufficient. You are advised to check the
+      <link linkend="ch-options">list of options</link> whether a NixOS
+      module for the package does not exist.
+    </para>
+  </note>
+  <para>
+    You can get a list of the available packages as follows:
+  </para>
+  <programlisting>
+$ nix-env -qaP '*' --description
+nixos.firefox   firefox-23.0   Mozilla Firefox - the browser, reloaded
+...
+</programlisting>
+  <para>
+    The first column in the output is the <emphasis>attribute
+    name</emphasis>, such as <literal>nixos.thunderbird</literal>.
+  </para>
+  <para>
+    Note: the <literal>nixos</literal> prefix tells us that we want to
+    get the package from the <literal>nixos</literal> channel and works
+    only in CLI tools. In declarative configuration use
+    <literal>pkgs</literal> prefix (variable).
+  </para>
+  <para>
+    To <quote>uninstall</quote> a package, simply remove it from
+    <xref linkend="opt-environment.systemPackages" /> and run
+    <literal>nixos-rebuild switch</literal>.
+  </para>
+  <xi:include href="customizing-packages.section.xml" />
+  <xi:include href="adding-custom-packages.section.xml" />
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/file-systems.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/file-systems.chapter.xml
new file mode 100644
index 000000000000..71441d8b4a5b
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/file-systems.chapter.xml
@@ -0,0 +1,55 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="ch-file-systems">
+  <title>File Systems</title>
+  <para>
+    You can define file systems using the <literal>fileSystems</literal>
+    configuration option. For instance, the following definition causes
+    NixOS to mount the Ext4 file system on device
+    <literal>/dev/disk/by-label/data</literal> onto the mount point
+    <literal>/data</literal>:
+  </para>
+  <programlisting language="bash">
+fileSystems.&quot;/data&quot; =
+  { device = &quot;/dev/disk/by-label/data&quot;;
+    fsType = &quot;ext4&quot;;
+  };
+</programlisting>
+  <para>
+    This will create an entry in <literal>/etc/fstab</literal>, which
+    will generate a corresponding
+    <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.mount.html">systemd.mount</link>
+    unit via
+    <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd-fstab-generator.html">systemd-fstab-generator</link>.
+    The filesystem will be mounted automatically unless
+    <literal>&quot;noauto&quot;</literal> is present in
+    <link linkend="opt-fileSystems._name_.options">options</link>.
+    <literal>&quot;noauto&quot;</literal> filesystems can be mounted
+    explicitly using <literal>systemctl</literal> e.g.
+    <literal>systemctl start data.mount</literal>. Mount points are
+    created automatically if they don’t already exist. For
+    <literal>device</literal>, it’s best to use the topology-independent
+    device aliases in <literal>/dev/disk/by-label</literal> and
+    <literal>/dev/disk/by-uuid</literal>, as these don’t change if the
+    topology changes (e.g. if a disk is moved to another IDE
+    controller).
+  </para>
+  <para>
+    You can usually omit the file system type
+    (<literal>fsType</literal>), since <literal>mount</literal> can
+    usually detect the type and load the necessary kernel module
+    automatically. However, if the file system is needed at early boot
+    (in the initial ramdisk) and is not <literal>ext2</literal>,
+    <literal>ext3</literal> or <literal>ext4</literal>, then it’s best
+    to specify <literal>fsType</literal> to ensure that the kernel
+    module is available.
+  </para>
+  <note>
+    <para>
+      System startup will fail if any of the filesystems fails to mount,
+      dropping you to the emergency shell. You can make a mount
+      asynchronous and non-critical by adding
+      <literal>options = [ &quot;nofail&quot; ];</literal>.
+    </para>
+  </note>
+  <xi:include href="luks-file-systems.section.xml" />
+  <xi:include href="sshfs-file-systems.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/firewall.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/firewall.section.xml
new file mode 100644
index 000000000000..24c19bb1c66d
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/firewall.section.xml
@@ -0,0 +1,39 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-firewall">
+  <title>Firewall</title>
+  <para>
+    NixOS has a simple stateful firewall that blocks incoming
+    connections and other unexpected packets. The firewall applies to
+    both IPv4 and IPv6 traffic. It is enabled by default. It can be
+    disabled as follows:
+  </para>
+  <programlisting language="bash">
+networking.firewall.enable = false;
+</programlisting>
+  <para>
+    If the firewall is enabled, you can open specific TCP ports to the
+    outside world:
+  </para>
+  <programlisting language="bash">
+networking.firewall.allowedTCPPorts = [ 80 443 ];
+</programlisting>
+  <para>
+    Note that TCP port 22 (ssh) is opened automatically if the SSH
+    daemon is enabled
+    (<literal>services.openssh.enable = true</literal>). UDP ports can
+    be opened through
+    <xref linkend="opt-networking.firewall.allowedUDPPorts" />.
+  </para>
+  <para>
+    To open ranges of TCP ports:
+  </para>
+  <programlisting language="bash">
+networking.firewall.allowedTCPPortRanges = [
+  { from = 4000; to = 4007; }
+  { from = 8000; to = 8010; }
+];
+</programlisting>
+  <para>
+    Similarly, UDP port ranges can be opened through
+    <xref linkend="opt-networking.firewall.allowedUDPPortRanges" />.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/gpu-accel.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/gpu-accel.chapter.xml
new file mode 100644
index 000000000000..8e780c5dee95
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/gpu-accel.chapter.xml
@@ -0,0 +1,239 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-gpu-accel">
+  <title>GPU acceleration</title>
+  <para>
+    NixOS provides various APIs that benefit from GPU hardware
+    acceleration, such as VA-API and VDPAU for video playback; OpenGL
+    and Vulkan for 3D graphics; and OpenCL for general-purpose
+    computing. This chapter describes how to set up GPU hardware
+    acceleration (as far as this is not done automatically) and how to
+    verify that hardware acceleration is indeed used.
+  </para>
+  <para>
+    Most of the aforementioned APIs are agnostic with regards to which
+    display server is used. Consequently, these instructions should
+    apply both to the X Window System and Wayland compositors.
+  </para>
+  <section xml:id="sec-gpu-accel-opencl">
+    <title>OpenCL</title>
+    <para>
+      <link xlink:href="https://en.wikipedia.org/wiki/OpenCL">OpenCL</link>
+      is a general compute API. It is used by various applications such
+      as Blender and Darktable to accelerate certain operations.
+    </para>
+    <para>
+      OpenCL applications load drivers through the <emphasis>Installable
+      Client Driver</emphasis> (ICD) mechanism. In this mechanism, an
+      ICD file specifies the path to the OpenCL driver for a particular
+      GPU family. In NixOS, there are two ways to make ICD files visible
+      to the ICD loader. The first is through the
+      <literal>OCL_ICD_VENDORS</literal> environment variable. This
+      variable can contain a directory which is scanned by the ICL
+      loader for ICD files. For example:
+    </para>
+    <programlisting>
+$ export \
+  OCL_ICD_VENDORS=`nix-build '&lt;nixpkgs&gt;' --no-out-link -A rocm-opencl-icd`/etc/OpenCL/vendors/
+</programlisting>
+    <para>
+      The second mechanism is to add the OpenCL driver package to
+      <xref linkend="opt-hardware.opengl.extraPackages" />. This links
+      the ICD file under <literal>/run/opengl-driver</literal>, where it
+      will be visible to the ICD loader.
+    </para>
+    <para>
+      The proper installation of OpenCL drivers can be verified through
+      the <literal>clinfo</literal> command of the clinfo package. This
+      command will report the number of hardware devices that is found
+      and give detailed information for each device:
+    </para>
+    <programlisting>
+$ clinfo | head -n3
+Number of platforms  1
+Platform Name        AMD Accelerated Parallel Processing
+Platform Vendor      Advanced Micro Devices, Inc.
+</programlisting>
+    <section xml:id="sec-gpu-accel-opencl-amd">
+      <title>AMD</title>
+      <para>
+        Modern AMD
+        <link xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
+        Core Next</link> (GCN) GPUs are supported through the
+        rocm-opencl-icd package. Adding this package to
+        <xref linkend="opt-hardware.opengl.extraPackages" /> enables
+        OpenCL support:
+      </para>
+      <programlisting language="bash">
+hardware.opengl.extraPackages = [
+  rocm-opencl-icd
+];
+</programlisting>
+    </section>
+    <section xml:id="sec-gpu-accel-opencl-intel">
+      <title>Intel</title>
+      <para>
+        <link xlink:href="https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units#Gen8">Intel
+        Gen8 and later GPUs</link> are supported by the Intel NEO OpenCL
+        runtime that is provided by the intel-compute-runtime package.
+        For Gen7 GPUs, the deprecated Beignet runtime can be used, which
+        is provided by the beignet package. The proprietary Intel OpenCL
+        runtime, in the intel-ocl package, is an alternative for Gen7
+        GPUs.
+      </para>
+      <para>
+        The intel-compute-runtime, beignet, or intel-ocl package can be
+        added to <xref linkend="opt-hardware.opengl.extraPackages" /> to
+        enable OpenCL support. For example, for Gen8 and later GPUs, the
+        following configuration can be used:
+      </para>
+      <programlisting language="bash">
+hardware.opengl.extraPackages = [
+  intel-compute-runtime
+];
+</programlisting>
+    </section>
+  </section>
+  <section xml:id="sec-gpu-accel-vulkan">
+    <title>Vulkan</title>
+    <para>
+      <link xlink:href="https://en.wikipedia.org/wiki/Vulkan_(API)">Vulkan</link>
+      is a graphics and compute API for GPUs. It is used directly by
+      games or indirectly though compatibility layers like
+      <link xlink:href="https://github.com/doitsujin/dxvk/wiki">DXVK</link>.
+    </para>
+    <para>
+      By default, if <xref linkend="opt-hardware.opengl.driSupport" />
+      is enabled, mesa is installed and provides Vulkan for supported
+      hardware.
+    </para>
+    <para>
+      Similar to OpenCL, Vulkan drivers are loaded through the
+      <emphasis>Installable Client Driver</emphasis> (ICD) mechanism.
+      ICD files for Vulkan are JSON files that specify the path to the
+      driver library and the supported Vulkan version. All successfully
+      loaded drivers are exposed to the application as different GPUs.
+      In NixOS, there are two ways to make ICD files visible to Vulkan
+      applications: an environment variable and a module option.
+    </para>
+    <para>
+      The first option is through the
+      <literal>VK_ICD_FILENAMES</literal> environment variable. This
+      variable can contain multiple JSON files, separated by
+      <literal>:</literal>. For example:
+    </para>
+    <programlisting>
+$ export \
+  VK_ICD_FILENAMES=`nix-build '&lt;nixpkgs&gt;' --no-out-link -A amdvlk`/share/vulkan/icd.d/amd_icd64.json
+</programlisting>
+    <para>
+      The second mechanism is to add the Vulkan driver package to
+      <xref linkend="opt-hardware.opengl.extraPackages" />. This links
+      the ICD file under <literal>/run/opengl-driver</literal>, where it
+      will be visible to the ICD loader.
+    </para>
+    <para>
+      The proper installation of Vulkan drivers can be verified through
+      the <literal>vulkaninfo</literal> command of the vulkan-tools
+      package. This command will report the hardware devices and drivers
+      found, in this example output amdvlk and radv:
+    </para>
+    <programlisting>
+$ vulkaninfo | grep GPU
+                GPU id  : 0 (Unknown AMD GPU)
+                GPU id  : 1 (AMD RADV NAVI10 (LLVM 9.0.1))
+     ...
+GPU0:
+        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
+        deviceName     = Unknown AMD GPU
+GPU1:
+        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
+</programlisting>
+    <para>
+      A simple graphical application that uses Vulkan is
+      <literal>vkcube</literal> from the vulkan-tools package.
+    </para>
+    <section xml:id="sec-gpu-accel-vulkan-amd">
+      <title>AMD</title>
+      <para>
+        Modern AMD
+        <link xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
+        Core Next</link> (GCN) GPUs are supported through either radv,
+        which is part of mesa, or the amdvlk package. Adding the amdvlk
+        package to <xref linkend="opt-hardware.opengl.extraPackages" />
+        makes amdvlk the default driver and hides radv and lavapipe from
+        the device list. A specific driver can be forced as follows:
+      </para>
+      <programlisting language="bash">
+hardware.opengl.extraPackages = [
+  pkgs.amdvlk
+];
+
+# To enable Vulkan support for 32-bit applications, also add:
+hardware.opengl.extraPackages32 = [
+  pkgs.driversi686Linux.amdvlk
+];
+
+# Force radv
+environment.variables.AMD_VULKAN_ICD = &quot;RADV&quot;;
+# Or
+environment.variables.VK_ICD_FILENAMES =
+  &quot;/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json&quot;;
+</programlisting>
+    </section>
+  </section>
+  <section xml:id="sec-gpu-accel-common-issues">
+    <title>Common issues</title>
+    <section xml:id="sec-gpu-accel-common-issues-permissions">
+      <title>User permissions</title>
+      <para>
+        Except where noted explicitly, it should not be necessary to
+        adjust user permissions to use these acceleration APIs. In the
+        default configuration, GPU devices have world-read/write
+        permissions (<literal>/dev/dri/renderD*</literal>) or are tagged
+        as <literal>uaccess</literal>
+        (<literal>/dev/dri/card*</literal>). The access control lists of
+        devices with the <literal>uaccess</literal> tag will be updated
+        automatically when a user logs in through
+        <literal>systemd-logind</literal>. For example, if the user
+        <emphasis>jane</emphasis> is logged in, the access control list
+        should look as follows:
+      </para>
+      <programlisting>
+$ getfacl /dev/dri/card0
+# file: dev/dri/card0
+# owner: root
+# group: video
+user::rw-
+user:jane:rw-
+group::rw-
+mask::rw-
+other::---
+</programlisting>
+      <para>
+        If you disabled (this functionality of)
+        <literal>systemd-logind</literal>, you may need to add the user
+        to the <literal>video</literal> group and log in again.
+      </para>
+    </section>
+    <section xml:id="sec-gpu-accel-common-issues-mixing-nixpkgs">
+      <title>Mixing different versions of nixpkgs</title>
+      <para>
+        The <emphasis>Installable Client Driver</emphasis> (ICD)
+        mechanism used by OpenCL and Vulkan loads runtimes into its
+        address space using <literal>dlopen</literal>. Mixing an ICD
+        loader mechanism and runtimes from different version of nixpkgs
+        may not work. For example, if the ICD loader uses an older
+        version of glibc than the runtime, the runtime may not be
+        loadable due to missing symbols. Unfortunately, the loader will
+        generally be quiet about such issues.
+      </para>
+      <para>
+        If you suspect that you are running into library version
+        mismatches between an ICL loader and a runtime, you could run an
+        application with the <literal>LD_DEBUG</literal> variable set to
+        get more diagnostic information. For example, OpenCL can be
+        tested with <literal>LD_DEBUG=files clinfo</literal>, which
+        should report missing symbols.
+      </para>
+    </section>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/ipv4-config.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/ipv4-config.section.xml
new file mode 100644
index 000000000000..047ba2165f07
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/ipv4-config.section.xml
@@ -0,0 +1,43 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-ipv4">
+  <title>IPv4 Configuration</title>
+  <para>
+    By default, NixOS uses DHCP (specifically,
+    <literal>dhcpcd</literal>) to automatically configure network
+    interfaces. However, you can configure an interface manually as
+    follows:
+  </para>
+  <programlisting language="bash">
+networking.interfaces.eth0.ipv4.addresses = [ {
+  address = &quot;192.168.1.2&quot;;
+  prefixLength = 24;
+} ];
+</programlisting>
+  <para>
+    Typically you’ll also want to set a default gateway and set of name
+    servers:
+  </para>
+  <programlisting language="bash">
+networking.defaultGateway = &quot;192.168.1.1&quot;;
+networking.nameservers = [ &quot;8.8.8.8&quot; ];
+</programlisting>
+  <note>
+    <para>
+      Statically configured interfaces are set up by the systemd service
+      <literal>interface-name-cfg.service</literal>. The default gateway
+      and name server configuration is performed by
+      <literal>network-setup.service</literal>.
+    </para>
+  </note>
+  <para>
+    The host name is set using
+    <xref linkend="opt-networking.hostName" />:
+  </para>
+  <programlisting language="bash">
+networking.hostName = &quot;cartman&quot;;
+</programlisting>
+  <para>
+    The default host name is <literal>nixos</literal>. Set it to the
+    empty string (<literal>&quot;&quot;</literal>) to allow the DHCP
+    server to provide the host name.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/ipv6-config.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/ipv6-config.section.xml
new file mode 100644
index 000000000000..137c3d772a86
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/ipv6-config.section.xml
@@ -0,0 +1,47 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-ipv6">
+  <title>IPv6 Configuration</title>
+  <para>
+    IPv6 is enabled by default. Stateless address autoconfiguration is
+    used to automatically assign IPv6 addresses to all interfaces, and
+    Privacy Extensions (RFC 4946) are enabled by default. You can adjust
+    the default for this by setting
+    <xref linkend="opt-networking.tempAddresses" />. This option may be
+    overridden on a per-interface basis by
+    <xref linkend="opt-networking.interfaces._name_.tempAddress" />. You
+    can disable IPv6 support globally by setting:
+  </para>
+  <programlisting language="bash">
+networking.enableIPv6 = false;
+</programlisting>
+  <para>
+    You can disable IPv6 on a single interface using a normal sysctl (in
+    this example, we use interface <literal>eth0</literal>):
+  </para>
+  <programlisting language="bash">
+boot.kernel.sysctl.&quot;net.ipv6.conf.eth0.disable_ipv6&quot; = true;
+</programlisting>
+  <para>
+    As with IPv4 networking interfaces are automatically configured via
+    DHCPv6. You can configure an interface manually:
+  </para>
+  <programlisting language="bash">
+networking.interfaces.eth0.ipv6.addresses = [ {
+  address = &quot;fe00:aa:bb:cc::2&quot;;
+  prefixLength = 64;
+} ];
+</programlisting>
+  <para>
+    For configuring a gateway, optionally with explicitly specified
+    interface:
+  </para>
+  <programlisting language="bash">
+networking.defaultGateway6 = {
+  address = &quot;fe00::1&quot;;
+  interface = &quot;enp0s3&quot;;
+};
+</programlisting>
+  <para>
+    See <xref linkend="sec-ipv4" /> for similar examples and additional
+    information.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/kubernetes.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/kubernetes.chapter.xml
new file mode 100644
index 000000000000..83a50d7c49d1
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/kubernetes.chapter.xml
@@ -0,0 +1,126 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-kubernetes">
+  <title>Kubernetes</title>
+  <para>
+    The NixOS Kubernetes module is a collective term for a handful of
+    individual submodules implementing the Kubernetes cluster
+    components.
+  </para>
+  <para>
+    There are generally two ways of enabling Kubernetes on NixOS. One
+    way is to enable and configure cluster components appropriately by
+    hand:
+  </para>
+  <programlisting language="bash">
+services.kubernetes = {
+  apiserver.enable = true;
+  controllerManager.enable = true;
+  scheduler.enable = true;
+  addonManager.enable = true;
+  proxy.enable = true;
+  flannel.enable = true;
+};
+</programlisting>
+  <para>
+    Another way is to assign cluster roles (&quot;master&quot; and/or
+    &quot;node&quot;) to the host. This enables apiserver,
+    controllerManager, scheduler, addonManager, kube-proxy and etcd:
+  </para>
+  <programlisting language="bash">
+services.kubernetes.roles = [ &quot;master&quot; ];
+</programlisting>
+  <para>
+    While this will enable the kubelet and kube-proxy only:
+  </para>
+  <programlisting language="bash">
+services.kubernetes.roles = [ &quot;node&quot; ];
+</programlisting>
+  <para>
+    Assigning both the master and node roles is usable if you want a
+    single node Kubernetes cluster for dev or testing purposes:
+  </para>
+  <programlisting language="bash">
+services.kubernetes.roles = [ &quot;master&quot; &quot;node&quot; ];
+</programlisting>
+  <para>
+    Note: Assigning either role will also default both
+    <xref linkend="opt-services.kubernetes.flannel.enable" /> and
+    <xref linkend="opt-services.kubernetes.easyCerts" /> to true. This
+    sets up flannel as CNI and activates automatic PKI bootstrapping.
+  </para>
+  <para>
+    As of kubernetes 1.10.X it has been deprecated to open
+    non-tls-enabled ports on kubernetes components. Thus, from NixOS
+    19.03 all plain HTTP ports have been disabled by default. While
+    opening insecure ports is still possible, it is recommended not to
+    bind these to other interfaces than loopback. To re-enable the
+    insecure port on the apiserver, see options:
+    <xref linkend="opt-services.kubernetes.apiserver.insecurePort" />
+    and
+    <xref linkend="opt-services.kubernetes.apiserver.insecureBindAddress" />
+  </para>
+  <note>
+    <para>
+      As of NixOS 19.03, it is mandatory to configure:
+      <xref linkend="opt-services.kubernetes.masterAddress" />. The
+      masterAddress must be resolveable and routeable by all cluster
+      nodes. In single node clusters, this can be set to
+      <literal>localhost</literal>.
+    </para>
+  </note>
+  <para>
+    Role-based access control (RBAC) authorization mode is enabled by
+    default. This means that anonymous requests to the apiserver secure
+    port will expectedly cause a permission denied error. All cluster
+    components must therefore be configured with x509 certificates for
+    two-way tls communication. The x509 certificate subject section
+    determines the roles and permissions granted by the apiserver to
+    perform clusterwide or namespaced operations. See also:
+    <link xlink:href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">
+    Using RBAC Authorization</link>.
+  </para>
+  <para>
+    The NixOS kubernetes module provides an option for automatic
+    certificate bootstrapping and configuration,
+    <xref linkend="opt-services.kubernetes.easyCerts" />. The PKI
+    bootstrapping process involves setting up a certificate authority
+    (CA) daemon (cfssl) on the kubernetes master node. cfssl generates a
+    CA-cert for the cluster, and uses the CA-cert for signing
+    subordinate certs issued to each of the cluster components.
+    Subsequently, the certmgr daemon monitors active certificates and
+    renews them when needed. For single node Kubernetes clusters,
+    setting <xref linkend="opt-services.kubernetes.easyCerts" /> = true
+    is sufficient and no further action is required. For joining extra
+    node machines to an existing cluster on the other hand, establishing
+    initial trust is mandatory.
+  </para>
+  <para>
+    To add new nodes to the cluster: On any (non-master) cluster node
+    where <xref linkend="opt-services.kubernetes.easyCerts" /> is
+    enabled, the helper script
+    <literal>nixos-kubernetes-node-join</literal> is available on PATH.
+    Given a token on stdin, it will copy the token to the kubernetes
+    secrets directory and restart the certmgr service. As requested
+    certificates are issued, the script will restart kubernetes cluster
+    components as needed for them to pick up new keypairs.
+  </para>
+  <note>
+    <para>
+      Multi-master (HA) clusters are not supported by the easyCerts
+      module.
+    </para>
+  </note>
+  <para>
+    In order to interact with an RBAC-enabled cluster as an
+    administrator, one needs to have cluster-admin privileges. By
+    default, when easyCerts is enabled, a cluster-admin kubeconfig file
+    is generated and linked into
+    <literal>/etc/kubernetes/cluster-admin.kubeconfig</literal> as
+    determined by
+    <xref linkend="opt-services.kubernetes.pki.etcClusterAdminKubeconfig" />.
+    <literal>export KUBECONFIG=/etc/kubernetes/cluster-admin.kubeconfig</literal>
+    will make kubectl use this kubeconfig to access and authenticate the
+    cluster. The cluster-admin kubeconfig references an auto-generated
+    keypair owned by root. Thus, only root on the kubernetes master may
+    obtain cluster-admin rights by means of this file.
+  </para>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/linux-kernel.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/linux-kernel.chapter.xml
new file mode 100644
index 000000000000..f804d0a3b8c2
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/linux-kernel.chapter.xml
@@ -0,0 +1,150 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-kernel-config">
+  <title>Linux Kernel</title>
+  <para>
+    You can override the Linux kernel and associated packages using the
+    option <literal>boot.kernelPackages</literal>. For instance, this
+    selects the Linux 3.10 kernel:
+  </para>
+  <programlisting language="bash">
+boot.kernelPackages = pkgs.linuxPackages_3_10;
+</programlisting>
+  <para>
+    Note that this not only replaces the kernel, but also packages that
+    are specific to the kernel version, such as the NVIDIA video
+    drivers. This ensures that driver packages are consistent with the
+    kernel.
+  </para>
+  <para>
+    The default Linux kernel configuration should be fine for most
+    users. You can see the configuration of your current kernel with the
+    following command:
+  </para>
+  <programlisting>
+zcat /proc/config.gz
+</programlisting>
+  <para>
+    If you want to change the kernel configuration, you can use the
+    <literal>packageOverrides</literal> feature (see
+    <xref linkend="sec-customising-packages" />). For instance, to
+    enable support for the kernel debugger KGDB:
+  </para>
+  <programlisting language="bash">
+nixpkgs.config.packageOverrides = pkgs:
+  { linux_3_4 = pkgs.linux_3_4.override {
+      extraConfig =
+        ''
+          KGDB y
+        '';
+    };
+  };
+</programlisting>
+  <para>
+    <literal>extraConfig</literal> takes a list of Linux kernel
+    configuration options, one per line. The name of the option should
+    not include the prefix <literal>CONFIG_</literal>. The option value
+    is typically <literal>y</literal>, <literal>n</literal> or
+    <literal>m</literal> (to build something as a kernel module).
+  </para>
+  <para>
+    Kernel modules for hardware devices are generally loaded
+    automatically by <literal>udev</literal>. You can force a module to
+    be loaded via <xref linkend="opt-boot.kernelModules" />, e.g.
+  </para>
+  <programlisting language="bash">
+boot.kernelModules = [ &quot;fuse&quot; &quot;kvm-intel&quot; &quot;coretemp&quot; ];
+</programlisting>
+  <para>
+    If the module is required early during the boot (e.g. to mount the
+    root file system), you can use
+    <xref linkend="opt-boot.initrd.kernelModules" />:
+  </para>
+  <programlisting language="bash">
+boot.initrd.kernelModules = [ &quot;cifs&quot; ];
+</programlisting>
+  <para>
+    This causes the specified modules and their dependencies to be added
+    to the initial ramdisk.
+  </para>
+  <para>
+    Kernel runtime parameters can be set through
+    <xref linkend="opt-boot.kernel.sysctl" />, e.g.
+  </para>
+  <programlisting language="bash">
+boot.kernel.sysctl.&quot;net.ipv4.tcp_keepalive_time&quot; = 120;
+</programlisting>
+  <para>
+    sets the kernel’s TCP keepalive time to 120 seconds. To see the
+    available parameters, run <literal>sysctl -a</literal>.
+  </para>
+  <section xml:id="sec-linux-config-customizing">
+    <title>Customize your kernel</title>
+    <para>
+      The first step before compiling the kernel is to generate an
+      appropriate <literal>.config</literal> configuration. Either you
+      pass your own config via the <literal>configfile</literal> setting
+      of <literal>linuxManualConfig</literal>:
+    </para>
+    <programlisting language="bash">
+custom-kernel = super.linuxManualConfig {
+  inherit (super) stdenv hostPlatform;
+  inherit (linux_4_9) src;
+  version = &quot;${linux_4_9.version}-custom&quot;;
+
+  configfile = /home/me/my_kernel_config;
+  allowImportFromDerivation = true;
+};
+</programlisting>
+    <para>
+      You can edit the config with this snippet (by default
+      <literal>make menuconfig</literal> won't work out of the box on
+      nixos):
+    </para>
+    <programlisting>
+nix-shell -E 'with import &lt;nixpkgs&gt; {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})'
+</programlisting>
+    <para>
+      or you can let nixpkgs generate the configuration. Nixpkgs
+      generates it via answering the interactive kernel utility
+      <literal>make config</literal>. The answers depend on parameters
+      passed to
+      <literal>pkgs/os-specific/linux/kernel/generic.nix</literal>
+      (which you can influence by overriding
+      <literal>extraConfig, autoModules, modDirVersion, preferBuiltin, extraConfig</literal>).
+    </para>
+    <programlisting language="bash">
+mptcp93.override ({
+  name=&quot;mptcp-local&quot;;
+
+  ignoreConfigErrors = true;
+  autoModules = false;
+  kernelPreferBuiltin = true;
+
+  enableParallelBuilding = true;
+
+  extraConfig = ''
+    DEBUG_KERNEL y
+    FRAME_POINTER y
+    KGDB y
+    KGDB_SERIAL_CONSOLE y
+    DEBUG_INFO y
+  '';
+});
+</programlisting>
+  </section>
+  <section xml:id="sec-linux-config-developing-modules">
+    <title>Developing kernel modules</title>
+    <para>
+      When developing kernel modules it's often convenient to run
+      edit-compile-run loop as quickly as possible. See below snippet as
+      an example of developing <literal>mellanox</literal> drivers.
+    </para>
+    <programlisting>
+$ nix-build '&lt;nixpkgs&gt;' -A linuxPackages.kernel.dev
+$ nix-shell '&lt;nixpkgs&gt;' -A linuxPackages.kernel
+$ unpackPhase
+$ cd linux-*
+$ make -C $dev/lib/modules/*/build M=$(pwd)/drivers/net/ethernet/mellanox modules
+# insmod ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko
+</programlisting>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/luks-file-systems.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/luks-file-systems.section.xml
new file mode 100644
index 000000000000..42b766eba98b
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/luks-file-systems.section.xml
@@ -0,0 +1,84 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-luks-file-systems">
+  <title>LUKS-Encrypted File Systems</title>
+  <para>
+    NixOS supports file systems that are encrypted using
+    <emphasis>LUKS</emphasis> (Linux Unified Key Setup). For example,
+    here is how you create an encrypted Ext4 file system on the device
+    <literal>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</literal>:
+  </para>
+  <programlisting>
+# cryptsetup luksFormat /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d
+
+WARNING!
+========
+This will overwrite data on /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d irrevocably.
+
+Are you sure? (Type uppercase yes): YES
+Enter LUKS passphrase: ***
+Verify passphrase: ***
+
+# cryptsetup luksOpen /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d crypted
+Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: ***
+
+# mkfs.ext4 /dev/mapper/crypted
+</programlisting>
+  <para>
+    The LUKS volume should be automatically picked up by
+    <literal>nixos-generate-config</literal>, but you might want to
+    verify that your <literal>hardware-configuration.nix</literal> looks
+    correct. To manually ensure that the system is automatically mounted
+    at boot time as <literal>/</literal>, add the following to
+    <literal>configuration.nix</literal>:
+  </para>
+  <programlisting language="bash">
+boot.initrd.luks.devices.crypted.device = &quot;/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d&quot;;
+fileSystems.&quot;/&quot;.device = &quot;/dev/mapper/crypted&quot;;
+</programlisting>
+  <para>
+    Should grub be used as bootloader, and <literal>/boot</literal> is
+    located on an encrypted partition, it is necessary to add the
+    following grub option:
+  </para>
+  <programlisting language="bash">
+boot.loader.grub.enableCryptodisk = true;
+</programlisting>
+  <section xml:id="sec-luks-file-systems-fido2">
+    <title>FIDO2</title>
+    <para>
+      NixOS also supports unlocking your LUKS-Encrypted file system
+      using a FIDO2 compatible token. In the following example, we will
+      create a new FIDO2 credential and add it as a new key to our
+      existing device <literal>/dev/sda2</literal>:
+    </para>
+    <programlisting>
+# export FIDO2_LABEL=&quot;/dev/sda2 @ $HOSTNAME&quot;
+# fido2luks credential &quot;$FIDO2_LABEL&quot;
+f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
+
+# fido2luks -i add-key /dev/sda2 f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
+Password:
+Password (again):
+Old password:
+Old password (again):
+Added to key to device /dev/sda2, slot: 2
+</programlisting>
+    <para>
+      To ensure that this file system is decrypted using the FIDO2
+      compatible key, add the following to
+      <literal>configuration.nix</literal>:
+    </para>
+    <programlisting language="bash">
+boot.initrd.luks.fido2Support = true;
+boot.initrd.luks.devices.&quot;/dev/sda2&quot;.fido2.credential = &quot;f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7&quot;;
+</programlisting>
+    <para>
+      You can also use the FIDO2 passwordless setup, but for security
+      reasons, you might want to enable it only when your device is PIN
+      protected, such as
+      <link xlink:href="https://trezor.io/">Trezor</link>.
+    </para>
+    <programlisting language="bash">
+boot.initrd.luks.devices.&quot;/dev/sda2&quot;.fido2.passwordLess = true;
+</programlisting>
+  </section>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/modularity.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/modularity.section.xml
new file mode 100644
index 000000000000..a7688090fcc5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/modularity.section.xml
@@ -0,0 +1,152 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-modularity">
+  <title>Modularity</title>
+  <para>
+    The NixOS configuration mechanism is modular. If your
+    <literal>configuration.nix</literal> becomes too big, you can split
+    it into multiple files. Likewise, if you have multiple NixOS
+    configurations (e.g. for different computers) with some commonality,
+    you can move the common configuration into a shared file.
+  </para>
+  <para>
+    Modules have exactly the same syntax as
+    <literal>configuration.nix</literal>. In fact,
+    <literal>configuration.nix</literal> is itself a module. You can use
+    other modules by including them from
+    <literal>configuration.nix</literal>, e.g.:
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{ imports = [ ./vpn.nix ./kde.nix ];
+  services.httpd.enable = true;
+  environment.systemPackages = [ pkgs.emacs ];
+  ...
+}
+</programlisting>
+  <para>
+    Here, we include two modules from the same directory,
+    <literal>vpn.nix</literal> and <literal>kde.nix</literal>. The
+    latter might look like this:
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{ services.xserver.enable = true;
+  services.xserver.displayManager.sddm.enable = true;
+  services.xserver.desktopManager.plasma5.enable = true;
+  environment.systemPackages = [ pkgs.vim ];
+}
+</programlisting>
+  <para>
+    Note that both <literal>configuration.nix</literal> and
+    <literal>kde.nix</literal> define the option
+    <xref linkend="opt-environment.systemPackages" />. When multiple
+    modules define an option, NixOS will try to
+    <emphasis>merge</emphasis> the definitions. In the case of
+    <xref linkend="opt-environment.systemPackages" />, that’s easy: the
+    lists of packages can simply be concatenated. The value in
+    <literal>configuration.nix</literal> is merged last, so for
+    list-type options, it will appear at the end of the merged list. If
+    you want it to appear first, you can use
+    <literal>mkBefore</literal>:
+  </para>
+  <programlisting language="bash">
+boot.kernelModules = mkBefore [ &quot;kvm-intel&quot; ];
+</programlisting>
+  <para>
+    This causes the <literal>kvm-intel</literal> kernel module to be
+    loaded before any other kernel modules.
+  </para>
+  <para>
+    For other types of options, a merge may not be possible. For
+    instance, if two modules define
+    <xref linkend="opt-services.httpd.adminAddr" />,
+    <literal>nixos-rebuild</literal> will give an error:
+  </para>
+  <programlisting>
+The unique option `services.httpd.adminAddr' is defined multiple times, in `/etc/nixos/httpd.nix' and `/etc/nixos/configuration.nix'.
+</programlisting>
+  <para>
+    When that happens, it’s possible to force one definition take
+    precedence over the others:
+  </para>
+  <programlisting language="bash">
+services.httpd.adminAddr = pkgs.lib.mkForce &quot;bob@example.org&quot;;
+</programlisting>
+  <para>
+    When using multiple modules, you may need to access configuration
+    values defined in other modules. This is what the
+    <literal>config</literal> function argument is for: it contains the
+    complete, merged system configuration. That is,
+    <literal>config</literal> is the result of combining the
+    configurations returned by every module <footnote>
+      <para>
+        If you’re wondering how it’s possible that the (indirect)
+        <emphasis>result</emphasis> of a function is passed as an
+        <emphasis>input</emphasis> to that same function: that’s because
+        Nix is a <quote>lazy</quote> language — it only computes values
+        when they are needed. This works as long as no individual
+        configuration value depends on itself.
+      </para>
+    </footnote> . For example, here is a module that adds some packages
+    to <xref linkend="opt-environment.systemPackages" /> only if
+    <xref linkend="opt-services.xserver.enable" /> is set to
+    <literal>true</literal> somewhere else:
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{ environment.systemPackages =
+    if config.services.xserver.enable then
+      [ pkgs.firefox
+        pkgs.thunderbird
+      ]
+    else
+      [ ];
+}
+</programlisting>
+  <para>
+    With multiple modules, it may not be obvious what the final value of
+    a configuration option is. The command
+    <literal>nixos-option</literal> allows you to find out:
+  </para>
+  <programlisting>
+$ nixos-option services.xserver.enable
+true
+
+$ nixos-option boot.kernelModules
+[ &quot;tun&quot; &quot;ipv6&quot; &quot;loop&quot; ... ]
+</programlisting>
+  <para>
+    Interactive exploration of the configuration is possible using
+    <literal>nix repl</literal>, a read-eval-print loop for Nix
+    expressions. A typical use:
+  </para>
+  <programlisting>
+$ nix repl '&lt;nixpkgs/nixos&gt;'
+
+nix-repl&gt; config.networking.hostName
+&quot;mandark&quot;
+
+nix-repl&gt; map (x: x.hostName) config.services.httpd.virtualHosts
+[ &quot;example.org&quot; &quot;example.gov&quot; ]
+</programlisting>
+  <para>
+    While abstracting your configuration, you may find it useful to
+    generate modules using code, instead of writing files. The example
+    below would have the same effect as importing a file which sets
+    those options.
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+let netConfig = hostName: {
+  networking.hostName = hostName;
+  networking.useDHCP = false;
+};
+
+in
+
+{ imports = [ (netConfig &quot;nixos.localdomain&quot;) ]; }
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/network-manager.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/network-manager.section.xml
new file mode 100644
index 000000000000..8f0d6d680ae0
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/network-manager.section.xml
@@ -0,0 +1,49 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-networkmanager">
+  <title>NetworkManager</title>
+  <para>
+    To facilitate network configuration, some desktop environments use
+    NetworkManager. You can enable NetworkManager by setting:
+  </para>
+  <programlisting language="bash">
+networking.networkmanager.enable = true;
+</programlisting>
+  <para>
+    some desktop managers (e.g., GNOME) enable NetworkManager
+    automatically for you.
+  </para>
+  <para>
+    All users that should have permission to change network settings
+    must belong to the <literal>networkmanager</literal> group:
+  </para>
+  <programlisting language="bash">
+users.users.alice.extraGroups = [ &quot;networkmanager&quot; ];
+</programlisting>
+  <para>
+    NetworkManager is controlled using either <literal>nmcli</literal>
+    or <literal>nmtui</literal> (curses-based terminal user interface).
+    See their manual pages for details on their usage. Some desktop
+    environments (GNOME, KDE) have their own configuration tools for
+    NetworkManager. On XFCE, there is no configuration tool for
+    NetworkManager by default: by enabling
+    <xref linkend="opt-programs.nm-applet.enable" />, the graphical
+    applet will be installed and will launch automatically when the
+    graphical session is started.
+  </para>
+  <note>
+    <para>
+      <literal>networking.networkmanager</literal> and
+      <literal>networking.wireless</literal> (WPA Supplicant) can be
+      used together if desired. To do this you need to instruct
+      NetworkManager to ignore those interfaces like:
+    </para>
+    <programlisting language="bash">
+networking.networkmanager.unmanaged = [
+   &quot;*&quot; &quot;except:type:wwan&quot; &quot;except:type:gsm&quot;
+];
+</programlisting>
+    <para>
+      Refer to the option description for the exact syntax and
+      references to external documentation.
+    </para>
+  </note>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/networking.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/networking.chapter.xml
new file mode 100644
index 000000000000..2ed86ea3b589
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/networking.chapter.xml
@@ -0,0 +1,15 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-networking">
+  <title>Networking</title>
+  <para>
+    This section describes how to configure networking components on
+    your NixOS machine.
+  </para>
+  <xi:include href="network-manager.section.xml" />
+  <xi:include href="ssh.section.xml" />
+  <xi:include href="ipv4-config.section.xml" />
+  <xi:include href="ipv6-config.section.xml" />
+  <xi:include href="firewall.section.xml" />
+  <xi:include href="wireless.section.xml" />
+  <xi:include href="ad-hoc-network-config.section.xml" />
+  <xi:include href="renaming-interfaces.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/package-mgmt.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/package-mgmt.chapter.xml
new file mode 100644
index 000000000000..d3727edbe08d
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/package-mgmt.chapter.xml
@@ -0,0 +1,28 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-package-management">
+  <title>Package Management</title>
+  <para>
+    This section describes how to add additional packages to your
+    system. NixOS has two distinct styles of package management:
+  </para>
+  <itemizedlist>
+    <listitem>
+      <para>
+        <emphasis>Declarative</emphasis>, where you declare what
+        packages you want in your <literal>configuration.nix</literal>.
+        Every time you run <literal>nixos-rebuild</literal>, NixOS will
+        ensure that you get a consistent set of binaries corresponding
+        to your specification.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        <emphasis>Ad hoc</emphasis>, where you install, upgrade and
+        uninstall packages via the <literal>nix-env</literal> command.
+        This style allows mixing packages from different Nixpkgs
+        versions. It’s the only choice for non-root users.
+      </para>
+    </listitem>
+  </itemizedlist>
+  <xi:include href="declarative-packages.section.xml" />
+  <xi:include href="ad-hoc-packages.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles.chapter.xml
new file mode 100644
index 000000000000..6f5fc130c6a0
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles.chapter.xml
@@ -0,0 +1,38 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="ch-profiles">
+  <title>Profiles</title>
+  <para>
+    In some cases, it may be desirable to take advantage of
+    commonly-used, predefined configurations provided by nixpkgs, but
+    different from those that come as default. This is a role fulfilled
+    by NixOS's Profiles, which come as files living in
+    <literal>&lt;nixpkgs/nixos/modules/profiles&gt;</literal>. That is
+    to say, expected usage is to add them to the imports list of your
+    <literal>/etc/configuration.nix</literal> as such:
+  </para>
+  <programlisting language="bash">
+imports = [
+  &lt;nixpkgs/nixos/modules/profiles/profile-name.nix&gt;
+];
+</programlisting>
+  <para>
+    Even if some of these profiles seem only useful in the context of
+    install media, many are actually intended to be used in real
+    installs.
+  </para>
+  <para>
+    What follows is a brief explanation on the purpose and use-case for
+    each profile. Detailing each option configured by each one is out of
+    scope.
+  </para>
+  <xi:include href="profiles/all-hardware.section.xml" />
+  <xi:include href="profiles/base.section.xml" />
+  <xi:include href="profiles/clone-config.section.xml" />
+  <xi:include href="profiles/demo.section.xml" />
+  <xi:include href="profiles/docker-container.section.xml" />
+  <xi:include href="profiles/graphical.section.xml" />
+  <xi:include href="profiles/hardened.section.xml" />
+  <xi:include href="profiles/headless.section.xml" />
+  <xi:include href="profiles/installation-device.section.xml" />
+  <xi:include href="profiles/minimal.section.xml" />
+  <xi:include href="profiles/qemu-guest.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/all-hardware.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/all-hardware.section.xml
new file mode 100644
index 000000000000..43ac5edea7f8
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/all-hardware.section.xml
@@ -0,0 +1,15 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-all-hardware">
+  <title>All Hardware</title>
+  <para>
+    Enables all hardware supported by NixOS: i.e., all firmware is
+    included, and all devices from which one may boot are enabled in the
+    initrd. Its primary use is in the NixOS installation CDs.
+  </para>
+  <para>
+    The enabled kernel modules include support for SATA and PATA, SCSI
+    (partially), USB, Firewire (untested), Virtio (QEMU, KVM, etc.),
+    VMware, and Hyper-V. Additionally,
+    <xref linkend="opt-hardware.enableAllFirmware" /> is enabled, and
+    the firmware for the ZyDAS ZD1211 chipset is specifically installed.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/base.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/base.section.xml
new file mode 100644
index 000000000000..83d35bd28676
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/base.section.xml
@@ -0,0 +1,10 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-base">
+  <title>Base</title>
+  <para>
+    Defines the software packages included in the <quote>minimal</quote>
+    installation CD. It installs several utilities useful in a simple
+    recovery or install media, such as a text-mode web browser, and
+    tools for manipulating block devices, networking, hardware
+    diagnostics, and filesystems (with their respective kernel modules).
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/clone-config.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/clone-config.section.xml
new file mode 100644
index 000000000000..9430b49ea33d
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/clone-config.section.xml
@@ -0,0 +1,16 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-clone-config">
+  <title>Clone Config</title>
+  <para>
+    This profile is used in installer images. It provides an editable
+    configuration.nix that imports all the modules that were also used
+    when creating the image in the first place. As a result it allows
+    users to edit and rebuild the live-system.
+  </para>
+  <para>
+    On images where the installation media also becomes an installation
+    target, copying over <literal>configuration.nix</literal> should be
+    disabled by setting <literal>installer.cloneConfig</literal> to
+    <literal>false</literal>. For example, this is done in
+    <literal>sd-image-aarch64-installer.nix</literal>.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/demo.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/demo.section.xml
new file mode 100644
index 000000000000..09c2680a1067
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/demo.section.xml
@@ -0,0 +1,10 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-demo">
+  <title>Demo</title>
+  <para>
+    This profile just enables a <literal>demo</literal> user, with
+    password <literal>demo</literal>, uid <literal>1000</literal>,
+    <literal>wheel</literal> group and
+    <link linkend="opt-services.xserver.displayManager.autoLogin">autologin
+    in the SDDM display manager</link>.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/docker-container.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/docker-container.section.xml
new file mode 100644
index 000000000000..97c2a92dcab5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/docker-container.section.xml
@@ -0,0 +1,12 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-docker-container">
+  <title>Docker Container</title>
+  <para>
+    This is the profile from which the Docker images are generated. It
+    prepares a working system by importing the
+    <link linkend="sec-profile-minimal">Minimal</link> and
+    <link linkend="sec-profile-clone-config">Clone Config</link>
+    profiles, and setting appropriate configuration options that are
+    useful inside a container context, like
+    <xref linkend="opt-boot.isContainer" />.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/graphical.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/graphical.section.xml
new file mode 100644
index 000000000000..1b109519d436
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/graphical.section.xml
@@ -0,0 +1,14 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-graphical">
+  <title>Graphical</title>
+  <para>
+    Defines a NixOS configuration with the Plasma 5 desktop. It’s used
+    by the graphical installation CD.
+  </para>
+  <para>
+    It sets <xref linkend="opt-services.xserver.enable" />,
+    <xref linkend="opt-services.xserver.displayManager.sddm.enable" />,
+    <xref linkend="opt-services.xserver.desktopManager.plasma5.enable" />,
+    and <xref linkend="opt-services.xserver.libinput.enable" /> to true.
+    It also includes glxinfo and firefox in the system packages list.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/hardened.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/hardened.section.xml
new file mode 100644
index 000000000000..44c11786d940
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/hardened.section.xml
@@ -0,0 +1,25 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-hardened">
+  <title>Hardened</title>
+  <para>
+    A profile with most (vanilla) hardening options enabled by default,
+    potentially at the cost of stability, features and performance.
+  </para>
+  <para>
+    This includes a hardened kernel, and limiting the system information
+    available to processes through the <literal>/sys</literal> and
+    <literal>/proc</literal> filesystems. It also disables the User
+    Namespaces feature of the kernel, which stops Nix from being able to
+    build anything (this particular setting can be overriden via
+    <xref linkend="opt-security.allowUserNamespaces" />). See the
+    <link xlink:href="https://github.com/nixos/nixpkgs/tree/master/nixos/modules/profiles/hardened.nix">profile
+    source</link> for further detail on which settings are altered.
+  </para>
+  <warning>
+    <para>
+      This profile enables options that are known to affect system
+      stability. If you experience any stability issues when using the
+      profile, try disabling it. If you report an issue and use this
+      profile, always mention that you do.
+    </para>
+  </warning>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/headless.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/headless.section.xml
new file mode 100644
index 000000000000..0910b9ffaad2
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/headless.section.xml
@@ -0,0 +1,15 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-headless">
+  <title>Headless</title>
+  <para>
+    Common configuration for headless machines (e.g., Amazon EC2
+    instances).
+  </para>
+  <para>
+    Disables <link linkend="opt-sound.enable">sound</link>,
+    <link linkend="opt-boot.vesa">vesa</link>, serial consoles,
+    <link linkend="opt-systemd.enableEmergencyMode">emergency
+    mode</link>, <link linkend="opt-boot.loader.grub.splashImage">grub
+    splash images</link> and configures the kernel to reboot
+    automatically on panic.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/installation-device.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/installation-device.section.xml
new file mode 100644
index 000000000000..837e69df06e1
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/installation-device.section.xml
@@ -0,0 +1,32 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-installation-device">
+  <title>Installation Device</title>
+  <para>
+    Provides a basic configuration for installation devices like CDs.
+    This enables redistributable firmware, includes the
+    <link linkend="sec-profile-clone-config">Clone Config profile</link>
+    and a copy of the Nixpkgs channel, so
+    <literal>nixos-install</literal> works out of the box.
+  </para>
+  <para>
+    Documentation for
+    <link linkend="opt-documentation.enable">Nixpkgs</link> and
+    <link linkend="opt-documentation.nixos.enable">NixOS</link> are
+    forcefully enabled (to override the
+    <link linkend="sec-profile-minimal">Minimal profile</link>
+    preference); the NixOS manual is shown automatically on TTY 8,
+    udisks is disabled. Autologin is enabled as <literal>nixos</literal>
+    user, while passwordless login as both <literal>root</literal> and
+    <literal>nixos</literal> is possible. Passwordless
+    <literal>sudo</literal> is enabled too.
+    <link linkend="opt-networking.wireless.enable">wpa_supplicant</link>
+    is enabled, but configured to not autostart.
+  </para>
+  <para>
+    It is explained how to login, start the ssh server, and if
+    available, how to start the display manager.
+  </para>
+  <para>
+    Several settings are tweaked so that the installer has a better
+    chance of succeeding under low-memory environments.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/minimal.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/minimal.section.xml
new file mode 100644
index 000000000000..a3fe30357dff
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/minimal.section.xml
@@ -0,0 +1,13 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-minimal">
+  <title>Minimal</title>
+  <para>
+    This profile defines a small NixOS configuration. It does not
+    contain any graphical stuff. It’s a very short file that enables
+    <link linkend="opt-environment.noXlibs">noXlibs</link>, sets
+    <xref linkend="opt-i18n.supportedLocales" /> to only support the
+    user-selected locale,
+    <link linkend="opt-documentation.enable">disables packages’
+    documentation</link>, and <link linkend="opt-sound.enable">disables
+    sound</link>.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/qemu-guest.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/qemu-guest.section.xml
new file mode 100644
index 000000000000..f33464f9db4d
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/profiles/qemu-guest.section.xml
@@ -0,0 +1,11 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-profile-qemu-guest">
+  <title>QEMU Guest</title>
+  <para>
+    This profile contains common configuration for virtual machines
+    running under QEMU (using virtio).
+  </para>
+  <para>
+    It makes virtio modules available on the initrd and sets the system
+    time from the hardware clock to work around a bug in qemu-kvm.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/renaming-interfaces.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/renaming-interfaces.section.xml
new file mode 100644
index 000000000000..1c32e30b3f85
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/renaming-interfaces.section.xml
@@ -0,0 +1,62 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-rename-ifs">
+  <title>Renaming network interfaces</title>
+  <para>
+    NixOS uses the udev
+    <link xlink:href="https://systemd.io/PREDICTABLE_INTERFACE_NAMES/">predictable
+    naming scheme</link> to assign names to network interfaces. This
+    means that by default cards are not given the traditional names like
+    <literal>eth0</literal> or <literal>eth1</literal>, whose order can
+    change unpredictably across reboots. Instead, relying on physical
+    locations and firmware information, the scheme produces names like
+    <literal>ens1</literal>, <literal>enp2s0</literal>, etc.
+  </para>
+  <para>
+    These names are predictable but less memorable and not necessarily
+    stable: for example installing new hardware or changing firmware
+    settings can result in a
+    <link xlink:href="https://github.com/systemd/systemd/issues/3715#issue-165347602">name
+    change</link>. If this is undesirable, for example if you have a
+    single ethernet card, you can revert to the traditional scheme by
+    setting
+    <xref linkend="opt-networking.usePredictableInterfaceNames" /> to
+    <literal>false</literal>.
+  </para>
+  <section xml:id="sec-custom-ifnames">
+    <title>Assigning custom names</title>
+    <para>
+      In case there are multiple interfaces of the same type, it’s
+      better to assign custom names based on the device hardware
+      address. For example, we assign the name <literal>wan</literal> to
+      the interface with MAC address
+      <literal>52:54:00:12:01:01</literal> using a netword link unit:
+    </para>
+    <programlisting language="bash">
+systemd.network.links.&quot;10-wan&quot; = {
+  matchConfig.MACAddress = &quot;52:54:00:12:01:01&quot;;
+  linkConfig.Name = &quot;wan&quot;;
+};
+</programlisting>
+    <para>
+      Note that links are directly read by udev, <emphasis>not
+      networkd</emphasis>, and will work even if networkd is disabled.
+    </para>
+    <para>
+      Alternatively, we can use a plain old udev rule:
+    </para>
+    <programlisting language="bash">
+services.udev.initrdRules = ''
+  SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, \
+  ATTR{address}==&quot;52:54:00:12:01:01&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;wan&quot;
+'';
+</programlisting>
+    <warning>
+      <para>
+        The rule must be installed in the initrd using
+        <literal>services.udev.initrdRules</literal>, not the usual
+        <literal>services.udev.extraRules</literal> option. This is to
+        avoid race conditions with other programs controlling the
+        interface.
+      </para>
+    </warning>
+  </section>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/ssh.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/ssh.section.xml
new file mode 100644
index 000000000000..037418d8ea4d
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/ssh.section.xml
@@ -0,0 +1,23 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-ssh">
+  <title>Secure Shell Access</title>
+  <para>
+    Secure shell (SSH) access to your machine can be enabled by setting:
+  </para>
+  <programlisting language="bash">
+services.openssh.enable = true;
+</programlisting>
+  <para>
+    By default, root logins using a password are disallowed. They can be
+    disabled entirely by setting
+    <xref linkend="opt-services.openssh.permitRootLogin" /> to
+    <literal>&quot;no&quot;</literal>.
+  </para>
+  <para>
+    You can declaratively specify authorised RSA/DSA public keys for a
+    user as follows:
+  </para>
+  <programlisting language="bash">
+users.users.alice.openssh.authorizedKeys.keys =
+  [ &quot;ssh-dss AAAAB3NzaC1kc3MAAACBAPIkGWVEt4...&quot; ];
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/sshfs-file-systems.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/sshfs-file-systems.section.xml
index 6b317aa63e9a..5d74712f35dc 100644
--- a/nixpkgs/nixos/doc/manual/from_md/configuration/sshfs-file-systems.section.xml
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/sshfs-file-systems.section.xml
@@ -51,8 +51,8 @@ SHA256:yjxl3UbTn31fLWeyLYTAKYJPRmzknjQZoyG8gSNEoIE my-user@workstation
     </para>
     <para>
       The file system can be configured in NixOS via the usual
-      <link xlink:href="options.html#opt-fileSystems">fileSystems</link>
-      option. Here’s a typical setup:
+      <link linkend="opt-fileSystems">fileSystems</link> option. Here’s
+      a typical setup:
     </para>
     <programlisting language="bash">
 {
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/subversion.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/subversion.chapter.xml
new file mode 100644
index 000000000000..794c2c34e399
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/subversion.chapter.xml
@@ -0,0 +1,121 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="module-services-subversion">
+  <title>Subversion</title>
+  <para>
+    <link xlink:href="https://subversion.apache.org/">Subversion</link>
+    is a centralized version-control system. It can use a
+    <link xlink:href="http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.choosing">variety
+    of protocols</link> for communication between client and server.
+  </para>
+  <section xml:id="module-services-subversion-apache-httpd">
+    <title>Subversion inside Apache HTTP</title>
+    <para>
+      This section focuses on configuring a web-based server on top of
+      the Apache HTTP server, which uses
+      <link xlink:href="http://www.webdav.org/">WebDAV</link>/<link xlink:href="http://www.webdav.org/deltav/WWW10/deltav-intro.htm">DeltaV</link>
+      for communication.
+    </para>
+    <para>
+      For more information on the general setup, please refer to the
+      <link xlink:href="http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.httpd">the
+      appropriate section of the Subversion book</link>.
+    </para>
+    <para>
+      To configure, include in
+      <literal>/etc/nixos/configuration.nix</literal> code to activate
+      Apache HTTP, setting
+      <xref linkend="opt-services.httpd.adminAddr" /> appropriately:
+    </para>
+    <programlisting language="bash">
+services.httpd.enable = true;
+services.httpd.adminAddr = ...;
+networking.firewall.allowedTCPPorts = [ 80 443 ];
+</programlisting>
+    <para>
+      For a simple Subversion server with basic authentication,
+      configure the Subversion module for Apache as follows, setting
+      <literal>hostName</literal> and <literal>documentRoot</literal>
+      appropriately, and <literal>SVNParentPath</literal> to the parent
+      directory of the repositories,
+      <literal>AuthzSVNAccessFile</literal> to the location of the
+      <literal>.authz</literal> file describing access permission, and
+      <literal>AuthUserFile</literal> to the password file.
+    </para>
+    <programlisting language="bash">
+services.httpd.extraModules = [
+    # note that order is *super* important here
+    { name = &quot;dav_svn&quot;; path = &quot;${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so&quot;; }
+    { name = &quot;authz_svn&quot;; path = &quot;${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so&quot;; }
+  ];
+  services.httpd.virtualHosts = {
+    &quot;svn&quot; = {
+       hostName = HOSTNAME;
+       documentRoot = DOCUMENTROOT;
+       locations.&quot;/svn&quot;.extraConfig = ''
+           DAV svn
+           SVNParentPath REPO_PARENT
+           AuthzSVNAccessFile ACCESS_FILE
+           AuthName &quot;SVN Repositories&quot;
+           AuthType Basic
+           AuthUserFile PASSWORD_FILE
+           Require valid-user
+      '';
+    }
+</programlisting>
+    <para>
+      The key <literal>&quot;svn&quot;</literal> is just a symbolic name
+      identifying the virtual host. The
+      <literal>&quot;/svn&quot;</literal> in
+      <literal>locations.&quot;/svn&quot;.extraConfig</literal> is the
+      path underneath which the repositories will be served.
+    </para>
+    <para>
+      <link xlink:href="https://wiki.archlinux.org/index.php/Subversion">This
+      page</link> explains how to set up the Subversion configuration
+      itself. This boils down to the following:
+    </para>
+    <para>
+      Underneath <literal>REPO_PARENT</literal> repositories can be set
+      up as follows:
+    </para>
+    <programlisting>
+$ svn create REPO_NAME
+</programlisting>
+    <para>
+      Repository files need to be accessible by
+      <literal>wwwrun</literal>:
+    </para>
+    <programlisting>
+$ chown -R wwwrun:wwwrun REPO_PARENT
+</programlisting>
+    <para>
+      The password file <literal>PASSWORD_FILE</literal> can be created
+      as follows:
+    </para>
+    <programlisting>
+$ htpasswd -cs PASSWORD_FILE USER_NAME
+</programlisting>
+    <para>
+      Additional users can be set up similarly, omitting the
+      <literal>c</literal> flag:
+    </para>
+    <programlisting>
+$ htpasswd -s PASSWORD_FILE USER_NAME
+</programlisting>
+    <para>
+      The file describing access permissions
+      <literal>ACCESS_FILE</literal> will look something like the
+      following:
+    </para>
+    <programlisting language="bash">
+[/]
+* = r
+
+[REPO_NAME:/]
+USER_NAME = rw
+</programlisting>
+    <para>
+      The Subversion repositories will be accessible as
+      <literal>http://HOSTNAME/svn/REPO_NAME</literal>.
+    </para>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/summary.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/summary.section.xml
new file mode 100644
index 000000000000..96a178c4930e
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/summary.section.xml
@@ -0,0 +1,332 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-nix-syntax-summary">
+  <title>Syntax Summary</title>
+  <para>
+    Below is a summary of the most important syntactic constructs in the
+    Nix expression language. It’s not complete. In particular, there are
+    many other built-in functions. See the
+    <link xlink:href="https://nixos.org/nix/manual/#chap-writing-nix-expressions">Nix
+    manual</link> for the rest.
+  </para>
+  <informaltable>
+    <tgroup cols="2">
+      <colspec align="left" />
+      <colspec align="left" />
+      <thead>
+        <row>
+          <entry>
+            Example
+          </entry>
+          <entry>
+            Description
+          </entry>
+        </row>
+      </thead>
+      <tbody>
+        <row>
+          <entry>
+            <emphasis>Basic values</emphasis>
+          </entry>
+          <entry>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>&quot;Hello world&quot;</literal>
+          </entry>
+          <entry>
+            A string
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>&quot;${pkgs.bash}/bin/sh&quot;</literal>
+          </entry>
+          <entry>
+            A string containing an expression (expands to
+            <literal>&quot;/nix/store/hash-bash-version/bin/sh&quot;</literal>)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>true</literal>, <literal>false</literal>
+          </entry>
+          <entry>
+            Booleans
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>123</literal>
+          </entry>
+          <entry>
+            An integer
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>./foo.png</literal>
+          </entry>
+          <entry>
+            A path (relative to the containing Nix expression)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <emphasis>Compound values</emphasis>
+          </entry>
+          <entry>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x = 1; y = 2; }</literal>
+          </entry>
+          <entry>
+            A set with attributes named <literal>x</literal> and
+            <literal>y</literal>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ foo.bar = 1; }</literal>
+          </entry>
+          <entry>
+            A nested set, equivalent to
+            <literal>{ foo = { bar = 1; }; }</literal>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>rec { x = &quot;foo&quot;; y = x + &quot;bar&quot;; }</literal>
+          </entry>
+          <entry>
+            A recursive set, equivalent to
+            <literal>{ x = &quot;foo&quot;; y = &quot;foobar&quot;; }</literal>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>[ &quot;foo&quot; &quot;bar&quot; ]</literal>
+          </entry>
+          <entry>
+            A list with two elements
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <emphasis>Operators</emphasis>
+          </entry>
+          <entry>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>&quot;foo&quot; + &quot;bar&quot;</literal>
+          </entry>
+          <entry>
+            String concatenation
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>1 + 2</literal>
+          </entry>
+          <entry>
+            Integer addition
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>&quot;foo&quot; == &quot;f&quot; + &quot;oo&quot;</literal>
+          </entry>
+          <entry>
+            Equality test (evaluates to <literal>true</literal>)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>&quot;foo&quot; != &quot;bar&quot;</literal>
+          </entry>
+          <entry>
+            Inequality test (evaluates to <literal>true</literal>)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>!true</literal>
+          </entry>
+          <entry>
+            Boolean negation
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x = 1; y = 2; }.x</literal>
+          </entry>
+          <entry>
+            Attribute selection (evaluates to <literal>1</literal>)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x = 1; y = 2; }.z or 3</literal>
+          </entry>
+          <entry>
+            Attribute selection with default (evaluates to
+            <literal>3</literal>)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x = 1; y = 2; } // { z = 3; }</literal>
+          </entry>
+          <entry>
+            Merge two sets (attributes in the right-hand set taking
+            precedence)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <emphasis>Control structures</emphasis>
+          </entry>
+          <entry>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>if 1 + 1 == 2 then &quot;yes!&quot; else &quot;no!&quot;</literal>
+          </entry>
+          <entry>
+            Conditional expression
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>assert 1 + 1 == 2; &quot;yes!&quot;</literal>
+          </entry>
+          <entry>
+            Assertion check (evaluates to
+            <literal>&quot;yes!&quot;</literal>). See
+            <xref linkend="sec-assertions" /> for using assertions in
+            modules
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>let x = &quot;foo&quot;; y = &quot;bar&quot;; in x + y</literal>
+          </entry>
+          <entry>
+            Variable definition
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>with pkgs.lib; head [ 1 2 3 ]</literal>
+          </entry>
+          <entry>
+            Add all attributes from the given set to the scope
+            (evaluates to <literal>1</literal>)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <emphasis>Functions (lambdas)</emphasis>
+          </entry>
+          <entry>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>x: x + 1</literal>
+          </entry>
+          <entry>
+            A function that expects an integer and returns it increased
+            by 1
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>(x: x + 1) 100</literal>
+          </entry>
+          <entry>
+            A function call (evaluates to 101)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>let inc = x: x + 1; in inc (inc (inc 100))</literal>
+          </entry>
+          <entry>
+            A function bound to a variable and subsequently called by
+            name (evaluates to 103)
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x, y }: x + y</literal>
+          </entry>
+          <entry>
+            A function that expects a set with required attributes
+            <literal>x</literal> and <literal>y</literal> and
+            concatenates them
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x, y ? &quot;bar&quot; }: x + y</literal>
+          </entry>
+          <entry>
+            A function that expects a set with required attribute
+            <literal>x</literal> and optional <literal>y</literal>,
+            using <literal>&quot;bar&quot;</literal> as default value
+            for <literal>y</literal>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x, y, ... }: x + y</literal>
+          </entry>
+          <entry>
+            A function that expects a set with required attributes
+            <literal>x</literal> and <literal>y</literal> and ignores
+            any other attributes
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>{ x, y } @ args: x + y</literal>
+          </entry>
+          <entry>
+            A function that expects a set with required attributes
+            <literal>x</literal> and <literal>y</literal>, and binds the
+            whole set to <literal>args</literal>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <emphasis>Built-in functions</emphasis>
+          </entry>
+          <entry>
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>import ./foo.nix</literal>
+          </entry>
+          <entry>
+            Load and return Nix expression in given file
+          </entry>
+        </row>
+        <row>
+          <entry>
+            <literal>map (x: x + x) [ 1 2 3 ]</literal>
+          </entry>
+          <entry>
+            Apply a function to every element of a list (evaluates to
+            <literal>[ 2 4 6 ]</literal>)
+          </entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/user-mgmt.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/user-mgmt.chapter.xml
new file mode 100644
index 000000000000..06492d5c2512
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/user-mgmt.chapter.xml
@@ -0,0 +1,105 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-user-management">
+  <title>User Management</title>
+  <para>
+    NixOS supports both declarative and imperative styles of user
+    management. In the declarative style, users are specified in
+    <literal>configuration.nix</literal>. For instance, the following
+    states that a user account named <literal>alice</literal> shall
+    exist:
+  </para>
+  <programlisting language="bash">
+users.users.alice = {
+  isNormalUser = true;
+  home = &quot;/home/alice&quot;;
+  description = &quot;Alice Foobar&quot;;
+  extraGroups = [ &quot;wheel&quot; &quot;networkmanager&quot; ];
+  openssh.authorizedKeys.keys = [ &quot;ssh-dss AAAAB3Nza... alice@foobar&quot; ];
+};
+</programlisting>
+  <para>
+    Note that <literal>alice</literal> is a member of the
+    <literal>wheel</literal> and <literal>networkmanager</literal>
+    groups, which allows her to use <literal>sudo</literal> to execute
+    commands as <literal>root</literal> and to configure the network,
+    respectively. Also note the SSH public key that allows remote logins
+    with the corresponding private key. Users created in this way do not
+    have a password by default, so they cannot log in via mechanisms
+    that require a password. However, you can use the
+    <literal>passwd</literal> program to set a password, which is
+    retained across invocations of <literal>nixos-rebuild</literal>.
+  </para>
+  <para>
+    If you set <xref linkend="opt-users.mutableUsers" /> to false, then
+    the contents of <literal>/etc/passwd</literal> and
+    <literal>/etc/group</literal> will be congruent to your NixOS
+    configuration. For instance, if you remove a user from
+    <xref linkend="opt-users.users" /> and run nixos-rebuild, the user
+    account will cease to exist. Also, imperative commands for managing
+    users and groups, such as useradd, are no longer available.
+    Passwords may still be assigned by setting the user's
+    <link linkend="opt-users.users._name_.hashedPassword">hashedPassword</link>
+    option. A hashed password can be generated using
+    <literal>mkpasswd -m sha-512</literal>.
+  </para>
+  <para>
+    A user ID (uid) is assigned automatically. You can also specify a
+    uid manually by adding
+  </para>
+  <programlisting language="bash">
+uid = 1000;
+</programlisting>
+  <para>
+    to the user specification.
+  </para>
+  <para>
+    Groups can be specified similarly. The following states that a group
+    named <literal>students</literal> shall exist:
+  </para>
+  <programlisting language="bash">
+users.groups.students.gid = 1000;
+</programlisting>
+  <para>
+    As with users, the group ID (gid) is optional and will be assigned
+    automatically if it’s missing.
+  </para>
+  <para>
+    In the imperative style, users and groups are managed by commands
+    such as <literal>useradd</literal>, <literal>groupmod</literal> and
+    so on. For instance, to create a user account named
+    <literal>alice</literal>:
+  </para>
+  <programlisting>
+# useradd -m alice
+</programlisting>
+  <para>
+    To make all nix tools available to this new user use `su - USER`
+    which opens a login shell (==shell that loads the profile) for given
+    user. This will create the ~/.nix-defexpr symlink. So run:
+  </para>
+  <programlisting>
+# su - alice -c &quot;true&quot;
+</programlisting>
+  <para>
+    The flag <literal>-m</literal> causes the creation of a home
+    directory for the new user, which is generally what you want. The
+    user does not have an initial password and therefore cannot log in.
+    A password can be set using the <literal>passwd</literal> utility:
+  </para>
+  <programlisting>
+# passwd alice
+Enter new UNIX password: ***
+Retype new UNIX password: ***
+</programlisting>
+  <para>
+    A user can be deleted using <literal>userdel</literal>:
+  </para>
+  <programlisting>
+# userdel -r alice
+</programlisting>
+  <para>
+    The flag <literal>-r</literal> deletes the user’s home directory.
+    Accounts can be modified using <literal>usermod</literal>. Unix
+    groups can be managed using <literal>groupadd</literal>,
+    <literal>groupmod</literal> and <literal>groupdel</literal>.
+  </para>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/wayland.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/wayland.chapter.xml
new file mode 100644
index 000000000000..1e90d4f31177
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/wayland.chapter.xml
@@ -0,0 +1,31 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-wayland">
+  <title>Wayland</title>
+  <para>
+    While X11 (see <xref linkend="sec-x11" />) is still the primary
+    display technology on NixOS, Wayland support is steadily improving.
+    Where X11 separates the X Server and the window manager, on Wayland
+    those are combined: a Wayland Compositor is like an X11 window
+    manager, but also embeds the Wayland 'Server' functionality. This
+    means it is sufficient to install a Wayland Compositor such as sway
+    without separately enabling a Wayland server:
+  </para>
+  <programlisting language="bash">
+programs.sway.enable = true;
+</programlisting>
+  <para>
+    This installs the sway compositor along with some essential
+    utilities. Now you can start sway from the TTY console.
+  </para>
+  <para>
+    If you are using a wlroots-based compositor, like sway, and want to
+    be able to share your screen, you might want to activate this
+    option:
+  </para>
+  <programlisting language="bash">
+xdg.portal.wlr.enable = true;
+</programlisting>
+  <para>
+    and configure Pipewire using
+    <xref linkend="opt-services.pipewire.enable" /> and related options.
+  </para>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/wireless.section.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/wireless.section.xml
new file mode 100644
index 000000000000..82bc20135157
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/wireless.section.xml
@@ -0,0 +1,73 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-wireless">
+  <title>Wireless Networks</title>
+  <para>
+    For a desktop installation using NetworkManager (e.g., GNOME), you
+    just have to make sure the user is in the
+    <literal>networkmanager</literal> group and you can skip the rest of
+    this section on wireless networks.
+  </para>
+  <para>
+    NixOS will start wpa_supplicant for you if you enable this setting:
+  </para>
+  <programlisting language="bash">
+networking.wireless.enable = true;
+</programlisting>
+  <para>
+    NixOS lets you specify networks for wpa_supplicant declaratively:
+  </para>
+  <programlisting language="bash">
+networking.wireless.networks = {
+  echelon = {                # SSID with no spaces or special characters
+    psk = &quot;abcdefgh&quot;;
+  };
+  &quot;echelon's AP&quot; = {         # SSID with spaces and/or special characters
+    psk = &quot;ijklmnop&quot;;
+  };
+  echelon = {                # Hidden SSID
+    hidden = true;
+    psk = &quot;qrstuvwx&quot;;
+  };
+  free.wifi = {};            # Public wireless network
+};
+</programlisting>
+  <para>
+    Be aware that keys will be written to the nix store in plaintext!
+    When no networks are set, it will default to using a configuration
+    file at <literal>/etc/wpa_supplicant.conf</literal>. You should edit
+    this file yourself to define wireless networks, WPA keys and so on
+    (see wpa_supplicant.conf(5)).
+  </para>
+  <para>
+    If you are using WPA2 you can generate pskRaw key using
+    <literal>wpa_passphrase</literal>:
+  </para>
+  <programlisting>
+$ wpa_passphrase ESSID PSK
+network={
+        ssid=&quot;echelon&quot;
+        #psk=&quot;abcdefgh&quot;
+        psk=dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435
+}
+</programlisting>
+  <programlisting language="bash">
+networking.wireless.networks = {
+  echelon = {
+    pskRaw = &quot;dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435&quot;;
+  };
+}
+</programlisting>
+  <para>
+    or you can use it to directly generate the
+    <literal>wpa_supplicant.conf</literal>:
+  </para>
+  <programlisting>
+# wpa_passphrase ESSID PSK &gt; /etc/wpa_supplicant.conf
+</programlisting>
+  <para>
+    After you have edited the <literal>wpa_supplicant.conf</literal>,
+    you need to restart the wpa_supplicant service.
+  </para>
+  <programlisting>
+# systemctl restart wpa_supplicant.service
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml
new file mode 100644
index 000000000000..274d0d817bc1
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml
@@ -0,0 +1,381 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-x11">
+  <title>X Window System</title>
+  <para>
+    The X Window System (X11) provides the basis of NixOS’ graphical
+    user interface. It can be enabled as follows:
+  </para>
+  <programlisting language="bash">
+services.xserver.enable = true;
+</programlisting>
+  <para>
+    The X server will automatically detect and use the appropriate video
+    driver from a set of X.org drivers (such as <literal>vesa</literal>
+    and <literal>intel</literal>). You can also specify a driver
+    manually, e.g.
+  </para>
+  <programlisting language="bash">
+services.xserver.videoDrivers = [ &quot;r128&quot; ];
+</programlisting>
+  <para>
+    to enable X.org’s <literal>xf86-video-r128</literal> driver.
+  </para>
+  <para>
+    You also need to enable at least one desktop or window manager.
+    Otherwise, you can only log into a plain undecorated
+    <literal>xterm</literal> window. Thus you should pick one or more of
+    the following lines:
+  </para>
+  <programlisting language="bash">
+services.xserver.desktopManager.plasma5.enable = true;
+services.xserver.desktopManager.xfce.enable = true;
+services.xserver.desktopManager.gnome.enable = true;
+services.xserver.desktopManager.mate.enable = true;
+services.xserver.windowManager.xmonad.enable = true;
+services.xserver.windowManager.twm.enable = true;
+services.xserver.windowManager.icewm.enable = true;
+services.xserver.windowManager.i3.enable = true;
+services.xserver.windowManager.herbstluftwm.enable = true;
+</programlisting>
+  <para>
+    NixOS’s default <emphasis>display manager</emphasis> (the program
+    that provides a graphical login prompt and manages the X server) is
+    LightDM. You can select an alternative one by picking one of the
+    following lines:
+  </para>
+  <programlisting language="bash">
+services.xserver.displayManager.sddm.enable = true;
+services.xserver.displayManager.gdm.enable = true;
+</programlisting>
+  <para>
+    You can set the keyboard layout (and optionally the layout variant):
+  </para>
+  <programlisting language="bash">
+services.xserver.layout = &quot;de&quot;;
+services.xserver.xkbVariant = &quot;neo&quot;;
+</programlisting>
+  <para>
+    The X server is started automatically at boot time. If you don’t
+    want this to happen, you can set:
+  </para>
+  <programlisting language="bash">
+services.xserver.autorun = false;
+</programlisting>
+  <para>
+    The X server can then be started manually:
+  </para>
+  <programlisting>
+# systemctl start display-manager.service
+</programlisting>
+  <para>
+    On 64-bit systems, if you want OpenGL for 32-bit programs such as in
+    Wine, you should also set the following:
+  </para>
+  <programlisting language="bash">
+hardware.opengl.driSupport32Bit = true;
+</programlisting>
+  <section xml:id="sec-x11-auto-login">
+    <title>Auto-login</title>
+    <para>
+      The x11 login screen can be skipped entirely, automatically
+      logging you into your window manager and desktop environment when
+      you boot your computer.
+    </para>
+    <para>
+      This is especially helpful if you have disk encryption enabled.
+      Since you already have to provide a password to decrypt your disk,
+      entering a second password to login can be redundant.
+    </para>
+    <para>
+      To enable auto-login, you need to define your default window
+      manager and desktop environment. If you wanted no desktop
+      environment and i3 as your your window manager, you'd define:
+    </para>
+    <programlisting language="bash">
+services.xserver.displayManager.defaultSession = &quot;none+i3&quot;;
+</programlisting>
+    <para>
+      Every display manager in NixOS supports auto-login, here is an
+      example using lightdm for a user <literal>alice</literal>:
+    </para>
+    <programlisting language="bash">
+services.xserver.displayManager.lightdm.enable = true;
+services.xserver.displayManager.autoLogin.enable = true;
+services.xserver.displayManager.autoLogin.user = &quot;alice&quot;;
+</programlisting>
+  </section>
+  <section xml:id="sec-x11--graphics-cards-intel">
+    <title>Intel Graphics drivers</title>
+    <para>
+      There are two choices for Intel Graphics drivers in X.org:
+      <literal>modesetting</literal> (included in the xorg-server
+      itself) and <literal>intel</literal> (provided by the package
+      xf86-video-intel).
+    </para>
+    <para>
+      The default and recommended is <literal>modesetting</literal>. It
+      is a generic driver which uses the kernel
+      <link xlink:href="https://en.wikipedia.org/wiki/Mode_setting">mode
+      setting</link> (KMS) mechanism. It supports Glamor (2D graphics
+      acceleration via OpenGL) and is actively maintained but may
+      perform worse in some cases (like in old chipsets).
+    </para>
+    <para>
+      The second driver, <literal>intel</literal>, is specific to Intel
+      GPUs, but not recommended by most distributions: it lacks several
+      modern features (for example, it doesn't support Glamor) and the
+      package hasn't been officially updated since 2015.
+    </para>
+    <para>
+      The results vary depending on the hardware, so you may have to try
+      both drivers. Use the option
+      <xref linkend="opt-services.xserver.videoDrivers" /> to set one.
+      The recommended configuration for modern systems is:
+    </para>
+    <programlisting language="bash">
+services.xserver.videoDrivers = [ &quot;modesetting&quot; ];
+services.xserver.useGlamor = true;
+</programlisting>
+    <para>
+      If you experience screen tearing no matter what, this
+      configuration was reported to resolve the issue:
+    </para>
+    <programlisting language="bash">
+services.xserver.videoDrivers = [ &quot;intel&quot; ];
+services.xserver.deviceSection = ''
+  Option &quot;DRI&quot; &quot;2&quot;
+  Option &quot;TearFree&quot; &quot;true&quot;
+'';
+</programlisting>
+    <para>
+      Note that this will likely downgrade the performance compared to
+      <literal>modesetting</literal> or <literal>intel</literal> with
+      DRI 3 (default).
+    </para>
+  </section>
+  <section xml:id="sec-x11-graphics-cards-nvidia">
+    <title>Proprietary NVIDIA drivers</title>
+    <para>
+      NVIDIA provides a proprietary driver for its graphics cards that
+      has better 3D performance than the X.org drivers. It is not
+      enabled by default because it’s not free software. You can enable
+      it as follows:
+    </para>
+    <programlisting language="bash">
+services.xserver.videoDrivers = [ &quot;nvidia&quot; ];
+</programlisting>
+    <para>
+      Or if you have an older card, you may have to use one of the
+      legacy drivers:
+    </para>
+    <programlisting language="bash">
+services.xserver.videoDrivers = [ &quot;nvidiaLegacy390&quot; ];
+services.xserver.videoDrivers = [ &quot;nvidiaLegacy340&quot; ];
+services.xserver.videoDrivers = [ &quot;nvidiaLegacy304&quot; ];
+</programlisting>
+    <para>
+      You may need to reboot after enabling this driver to prevent a
+      clash with other kernel modules.
+    </para>
+  </section>
+  <section xml:id="sec-x11--graphics-cards-amd">
+    <title>Proprietary AMD drivers</title>
+    <para>
+      AMD provides a proprietary driver for its graphics cards that is
+      not enabled by default because it’s not Free Software, is often
+      broken in nixpkgs and as of this writing doesn't offer more
+      features or performance. If you still want to use it anyway, you
+      need to explicitly set:
+    </para>
+    <programlisting language="bash">
+services.xserver.videoDrivers = [ &quot;amdgpu-pro&quot; ];
+</programlisting>
+    <para>
+      You will need to reboot after enabling this driver to prevent a
+      clash with other kernel modules.
+    </para>
+  </section>
+  <section xml:id="sec-x11-touchpads">
+    <title>Touchpads</title>
+    <para>
+      Support for Synaptics touchpads (found in many laptops such as the
+      Dell Latitude series) can be enabled as follows:
+    </para>
+    <programlisting language="bash">
+services.xserver.libinput.enable = true;
+</programlisting>
+    <para>
+      The driver has many options (see <xref linkend="ch-options" />).
+      For instance, the following disables tap-to-click behavior:
+    </para>
+    <programlisting language="bash">
+services.xserver.libinput.touchpad.tapping = false;
+</programlisting>
+    <para>
+      Note: the use of <literal>services.xserver.synaptics</literal> is
+      deprecated since NixOS 17.09.
+    </para>
+  </section>
+  <section xml:id="sec-x11-gtk-and-qt-themes">
+    <title>GTK/Qt themes</title>
+    <para>
+      GTK themes can be installed either to user profile or system-wide
+      (via <literal>environment.systemPackages</literal>). To make Qt 5
+      applications look similar to GTK ones, you can use the following
+      configuration:
+    </para>
+    <programlisting language="bash">
+qt5.enable = true;
+qt5.platformTheme = &quot;gtk2&quot;;
+qt5.style = &quot;gtk2&quot;;
+</programlisting>
+  </section>
+  <section xml:id="custom-xkb-layouts">
+    <title>Custom XKB layouts</title>
+    <para>
+      It is possible to install custom
+      <link xlink:href="https://en.wikipedia.org/wiki/X_keyboard_extension">
+      XKB </link> keyboard layouts using the option
+      <literal>services.xserver.extraLayouts</literal>.
+    </para>
+    <para>
+      As a first example, we are going to create a layout based on the
+      basic US layout, with an additional layer to type some greek
+      symbols by pressing the right-alt key.
+    </para>
+    <para>
+      Create a file called <literal>us-greek</literal> with the
+      following content (under a directory called
+      <literal>symbols</literal>; it's an XKB peculiarity that will help
+      with testing):
+    </para>
+    <programlisting language="bash">
+xkb_symbols &quot;us-greek&quot;
+{
+  include &quot;us(basic)&quot;            // includes the base US keys
+  include &quot;level3(ralt_switch)&quot;  // configures right alt as a third level switch
+
+  key &lt;LatA&gt; { [ a, A, Greek_alpha ] };
+  key &lt;LatB&gt; { [ b, B, Greek_beta  ] };
+  key &lt;LatG&gt; { [ g, G, Greek_gamma ] };
+  key &lt;LatD&gt; { [ d, D, Greek_delta ] };
+  key &lt;LatZ&gt; { [ z, Z, Greek_zeta  ] };
+};
+</programlisting>
+    <para>
+      A minimal layout specification must include the following:
+    </para>
+    <programlisting language="bash">
+services.xserver.extraLayouts.us-greek = {
+  description = &quot;US layout with alt-gr greek&quot;;
+  languages   = [ &quot;eng&quot; ];
+  symbolsFile = /yourpath/symbols/us-greek;
+};
+</programlisting>
+    <note>
+      <para>
+        The name (after <literal>extraLayouts.</literal>) should match
+        the one given to the <literal>xkb_symbols</literal> block.
+      </para>
+    </note>
+    <para>
+      Applying this customization requires rebuilding several packages,
+      and a broken XKB file can lead to the X session crashing at login.
+      Therefore, you're strongly advised to <emphasis role="strong">test
+      your layout before applying it</emphasis>:
+    </para>
+    <programlisting>
+$ nix-shell -p xorg.xkbcomp
+$ setxkbmap -I/yourpath us-greek -print | xkbcomp -I/yourpath - $DISPLAY
+</programlisting>
+    <para>
+      You can inspect the predefined XKB files for examples:
+    </para>
+    <programlisting>
+$ echo &quot;$(nix-build --no-out-link '&lt;nixpkgs&gt;' -A xorg.xkeyboardconfig)/etc/X11/xkb/&quot;
+</programlisting>
+    <para>
+      Once the configuration is applied, and you did a logout/login
+      cycle, the layout should be ready to use. You can try it by e.g.
+      running <literal>setxkbmap us-greek</literal> and then type
+      <literal>&lt;alt&gt;+a</literal> (it may not get applied in your
+      terminal straight away). To change the default, the usual
+      <literal>services.xserver.layout</literal> option can still be
+      used.
+    </para>
+    <para>
+      A layout can have several other components besides
+      <literal>xkb_symbols</literal>, for example we will define new
+      keycodes for some multimedia key and bind these to some symbol.
+    </para>
+    <para>
+      Use the <emphasis>xev</emphasis> utility from
+      <literal>pkgs.xorg.xev</literal> to find the codes of the keys of
+      interest, then create a <literal>media-key</literal> file to hold
+      the keycodes definitions
+    </para>
+    <programlisting language="bash">
+xkb_keycodes &quot;media&quot;
+{
+ &lt;volUp&gt;   = 123;
+ &lt;volDown&gt; = 456;
+}
+</programlisting>
+    <para>
+      Now use the newly define keycodes in <literal>media-sym</literal>:
+    </para>
+    <programlisting language="bash">
+xkb_symbols &quot;media&quot;
+{
+ key.type = &quot;ONE_LEVEL&quot;;
+ key &lt;volUp&gt;   { [ XF86AudioLowerVolume ] };
+ key &lt;volDown&gt; { [ XF86AudioRaiseVolume ] };
+}
+</programlisting>
+    <para>
+      As before, to install the layout do
+    </para>
+    <programlisting language="bash">
+services.xserver.extraLayouts.media = {
+  description  = &quot;Multimedia keys remapping&quot;;
+  languages    = [ &quot;eng&quot; ];
+  symbolsFile  = /path/to/media-key;
+  keycodesFile = /path/to/media-sym;
+};
+</programlisting>
+    <note>
+      <para>
+        The function
+        <literal>pkgs.writeText &lt;filename&gt; &lt;content&gt;</literal>
+        can be useful if you prefer to keep the layout definitions
+        inside the NixOS configuration.
+      </para>
+    </note>
+    <para>
+      Unfortunately, the Xorg server does not (currently) support
+      setting a keymap directly but relies instead on XKB rules to
+      select the matching components (keycodes, types, ...) of a layout.
+      This means that components other than symbols won't be loaded by
+      default. As a workaround, you can set the keymap using
+      <literal>setxkbmap</literal> at the start of the session with:
+    </para>
+    <programlisting language="bash">
+services.xserver.displayManager.sessionCommands = &quot;setxkbmap -keycodes media&quot;;
+</programlisting>
+    <para>
+      If you are manually starting the X server, you should set the
+      argument <literal>-xkbdir /etc/X11/xkb</literal>, otherwise X
+      won't find your layout files. For example with
+      <literal>xinit</literal> run
+    </para>
+    <programlisting>
+$ xinit -- -xkbdir /etc/X11/xkb
+</programlisting>
+    <para>
+      To learn how to write layouts take a look at the XKB
+      <link xlink:href="https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Enhancing.html#Defining_New_Layouts">documentation
+      </link>. More example layouts can also be found
+      <link xlink:href="https://wiki.archlinux.org/index.php/X_KeyBoard_extension#Basic_examples">here
+      </link>.
+    </para>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/configuration/xfce.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/configuration/xfce.chapter.xml
new file mode 100644
index 000000000000..f96ef2e8c483
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/configuration/xfce.chapter.xml
@@ -0,0 +1,62 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-xfce">
+  <title>Xfce Desktop Environment</title>
+  <para>
+    To enable the Xfce Desktop Environment, set
+  </para>
+  <programlisting language="bash">
+services.xserver.desktopManager.xfce.enable = true;
+services.xserver.displayManager.defaultSession = &quot;xfce&quot;;
+</programlisting>
+  <para>
+    Optionally, <emphasis>picom</emphasis> can be enabled for nice
+    graphical effects, some example settings:
+  </para>
+  <programlisting language="bash">
+services.picom = {
+  enable = true;
+  fade = true;
+  inactiveOpacity = 0.9;
+  shadow = true;
+  fadeDelta = 4;
+};
+</programlisting>
+  <para>
+    Some Xfce programs are not installed automatically. To install them
+    manually (system wide), put them into your
+    <xref linkend="opt-environment.systemPackages" /> from
+    <literal>pkgs.xfce</literal>.
+  </para>
+  <section xml:id="sec-xfce-thunar-plugins">
+    <title>Thunar Plugins</title>
+    <para>
+      If you'd like to add extra plugins to Thunar, add them to
+      <xref linkend="opt-services.xserver.desktopManager.xfce.thunarPlugins" />.
+      You shouldn't just add them to
+      <xref linkend="opt-environment.systemPackages" />.
+    </para>
+  </section>
+  <section xml:id="sec-xfce-troubleshooting">
+    <title>Troubleshooting</title>
+    <para>
+      Even after enabling udisks2, volume management might not work.
+      Thunar and/or the desktop takes time to show up. Thunar will spit
+      out this kind of message on start (look at
+      <literal>journalctl --user -b</literal>).
+    </para>
+    <programlisting>
+Thunar:2410): GVFS-RemoteVolumeMonitor-WARNING **: remote volume monitor with dbus name org.gtk.Private.UDisks2VolumeMonitor is not supported
+</programlisting>
+    <para>
+      This is caused by some needed GNOME services not running. This is
+      all fixed by enabling &quot;Launch GNOME services on startup&quot;
+      in the Advanced tab of the Session and Startup settings panel.
+      Alternatively, you can run this command to do the same thing.
+    </para>
+    <programlisting>
+$ xfconf-query -c xfce4-session -p /compat/LaunchGNOME -s true
+</programlisting>
+    <para>
+      A log-out and re-log will be needed for this to take effect.
+    </para>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/building-parts.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/development/building-parts.chapter.xml
new file mode 100644
index 000000000000..4df24cc95652
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/building-parts.chapter.xml
@@ -0,0 +1,124 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-building-parts">
+  <title>Building Specific Parts of NixOS</title>
+  <para>
+    With the command <literal>nix-build</literal>, you can build
+    specific parts of your NixOS configuration. This is done as follows:
+  </para>
+  <programlisting>
+$ cd /path/to/nixpkgs/nixos
+$ nix-build -A config.option
+</programlisting>
+  <para>
+    where <literal>option</literal> is a NixOS option with type
+    <quote>derivation</quote> (i.e. something that can be built).
+    Attributes of interest include:
+  </para>
+  <variablelist>
+    <varlistentry>
+      <term>
+        <literal>system.build.toplevel</literal>
+      </term>
+      <listitem>
+        <para>
+          The top-level option that builds the entire NixOS system.
+          Everything else in your configuration is indirectly pulled in
+          by this option. This is what <literal>nixos-rebuild</literal>
+          builds and what <literal>/run/current-system</literal> points
+          to afterwards.
+        </para>
+        <para>
+          A shortcut to build this is:
+        </para>
+        <programlisting>
+$ nix-build -A system
+</programlisting>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>system.build.manual.manualHTML</literal>
+      </term>
+      <listitem>
+        <para>
+          The NixOS manual.
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>system.build.etc</literal>
+      </term>
+      <listitem>
+        <para>
+          A tree of symlinks that form the static parts of
+          <literal>/etc</literal>.
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>system.build.initialRamdisk</literal> ,
+        <literal>system.build.kernel</literal>
+      </term>
+      <listitem>
+        <para>
+          The initial ramdisk and kernel of the system. This allows a
+          quick way to test whether the kernel and the initial ramdisk
+          boot correctly, by using QEMU’s <literal>-kernel</literal> and
+          <literal>-initrd</literal> options:
+        </para>
+        <programlisting>
+$ nix-build -A config.system.build.initialRamdisk -o initrd
+$ nix-build -A config.system.build.kernel -o kernel
+$ qemu-system-x86_64 -kernel ./kernel/bzImage -initrd ./initrd/initrd -hda /dev/null
+</programlisting>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>system.build.nixos-rebuild</literal> ,
+        <literal>system.build.nixos-install</literal> ,
+        <literal>system.build.nixos-generate-config</literal>
+      </term>
+      <listitem>
+        <para>
+          These build the corresponding NixOS commands.
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>systemd.units.unit-name.unit</literal>
+      </term>
+      <listitem>
+        <para>
+          This builds the unit with the specified name. Note that since
+          unit names contain dots (e.g.
+          <literal>httpd.service</literal>), you need to put them
+          between quotes, like this:
+        </para>
+        <programlisting>
+$ nix-build -A 'config.systemd.units.&quot;httpd.service&quot;.unit'
+</programlisting>
+        <para>
+          You can also test individual units, without rebuilding the
+          whole system, by putting them in
+          <literal>/run/systemd/system</literal>:
+        </para>
+        <programlisting>
+$ cp $(nix-build -A 'config.systemd.units.&quot;httpd.service&quot;.unit')/httpd.service \
+    /run/systemd/system/tmp-httpd.service
+# systemctl daemon-reload
+# systemctl start tmp-httpd.service
+</programlisting>
+        <para>
+          Note that the unit must not have the same name as any unit in
+          <literal>/etc/systemd/system</literal> since those take
+          precedence over <literal>/run/systemd/system</literal>. That’s
+          why the unit is installed as
+          <literal>tmp-httpd.service</literal> here.
+        </para>
+      </listitem>
+    </varlistentry>
+  </variablelist>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/freeform-modules.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/freeform-modules.section.xml
new file mode 100644
index 000000000000..86a9cf3140d8
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/freeform-modules.section.xml
@@ -0,0 +1,87 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-freeform-modules">
+  <title>Freeform modules</title>
+  <para>
+    Freeform modules allow you to define values for option paths that
+    have not been declared explicitly. This can be used to add
+    attribute-specific types to what would otherwise have to be
+    <literal>attrsOf</literal> options in order to accept all attribute
+    names.
+  </para>
+  <para>
+    This feature can be enabled by using the attribute
+    <literal>freeformType</literal> to define a freeform type. By doing
+    this, all assignments without an associated option will be merged
+    using the freeform type and combined into the resulting
+    <literal>config</literal> set. Since this feature nullifies name
+    checking for entire option trees, it is only recommended for use in
+    submodules.
+  </para>
+  <anchor xml:id="ex-freeform-module" />
+  <para>
+    <emphasis role="strong">Example: Freeform submodule</emphasis>
+  </para>
+  <para>
+    The following shows a submodule assigning a freeform type that
+    allows arbitrary attributes with <literal>str</literal> values below
+    <literal>settings</literal>, but also declares an option for the
+    <literal>settings.port</literal> attribute to have it type-checked
+    and assign a default value. See
+    <link linkend="ex-settings-typed-attrs">Example: Declaring a
+    type-checked <literal>settings</literal> attribute</link> for a more
+    complete example.
+  </para>
+  <programlisting language="bash">
+{ lib, config, ... }: {
+
+  options.settings = lib.mkOption {
+    type = lib.types.submodule {
+
+      freeformType = with lib.types; attrsOf str;
+
+      # We want this attribute to be checked for the correct type
+      options.port = lib.mkOption {
+        type = lib.types.port;
+        # Declaring the option also allows defining a default value
+        default = 8080;
+      };
+
+    };
+  };
+}
+</programlisting>
+  <para>
+    And the following shows what such a module then allows
+  </para>
+  <programlisting language="bash">
+{
+  # Not a declared option, but the freeform type allows this
+  settings.logLevel = &quot;debug&quot;;
+
+  # Not allowed because the the freeform type only allows strings
+  # settings.enable = true;
+
+  # Allowed because there is a port option declared
+  settings.port = 80;
+
+  # Not allowed because the port option doesn't allow strings
+  # settings.port = &quot;443&quot;;
+}
+</programlisting>
+  <note>
+    <para>
+      Freeform attributes cannot depend on other attributes of the same
+      set without infinite recursion:
+    </para>
+    <programlisting language="bash">
+{
+  # This throws infinite recursion encountered
+  settings.logLevel = lib.mkIf (config.settings.port == 80) &quot;debug&quot;;
+}
+</programlisting>
+    <para>
+      To prevent this, declare options for all attributes that need to
+      depend on others. For above example this means to declare
+      <literal>logLevel</literal> to be an option.
+    </para>
+  </note>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/importing-modules.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/importing-modules.section.xml
new file mode 100644
index 000000000000..cb04dde67c83
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/importing-modules.section.xml
@@ -0,0 +1,47 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-importing-modules">
+  <title>Importing Modules</title>
+  <para>
+    Sometimes NixOS modules need to be used in configuration but exist
+    outside of Nixpkgs. These modules can be imported:
+  </para>
+  <programlisting language="bash">
+{ config, lib, pkgs, ... }:
+
+{
+  imports =
+    [ # Use a locally-available module definition in
+      # ./example-module/default.nix
+        ./example-module
+    ];
+
+  services.exampleModule.enable = true;
+}
+</programlisting>
+  <para>
+    The environment variable <literal>NIXOS_EXTRA_MODULE_PATH</literal>
+    is an absolute path to a NixOS module that is included alongside the
+    Nixpkgs NixOS modules. Like any NixOS module, this module can import
+    additional modules:
+  </para>
+  <programlisting language="bash">
+# ./module-list/default.nix
+[
+  ./example-module1
+  ./example-module2
+]
+</programlisting>
+  <programlisting language="bash">
+# ./extra-module/default.nix
+{ imports = import ./module-list.nix; }
+</programlisting>
+  <programlisting language="bash">
+# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module
+{ config, lib, pkgs, ... }:
+
+{
+  # No `imports` needed
+
+  services.exampleModule1.enable = true;
+}
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/meta-attributes.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/meta-attributes.section.xml
new file mode 100644
index 000000000000..f535d94602bd
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/meta-attributes.section.xml
@@ -0,0 +1,55 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-meta-attributes">
+  <title>Meta Attributes</title>
+  <para>
+    Like Nix packages, NixOS modules can declare meta-attributes to
+    provide extra information. Module meta attributes are defined in the
+    <literal>meta.nix</literal> special module.
+  </para>
+  <para>
+    <literal>meta</literal> is a top level attribute like
+    <literal>options</literal> and <literal>config</literal>. Available
+    meta-attributes are <literal>maintainers</literal> and
+    <literal>doc</literal>.
+  </para>
+  <para>
+    Each of the meta-attributes must be defined at most once per module
+    file.
+  </para>
+  <programlisting language="bash">
+{ config, lib, pkgs, ... }:
+{
+  options = {
+    ...
+  };
+
+  config = {
+    ...
+  };
+
+  meta = {
+    maintainers = with lib.maintainers; [ ericsagnes ];
+    doc = ./default.xml;
+  };
+}
+</programlisting>
+  <itemizedlist>
+    <listitem>
+      <para>
+        <literal>maintainers</literal> contains a list of the module
+        maintainers.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        <literal>doc</literal> points to a valid DocBook file containing
+        the module documentation. Its contents is automatically added to
+        <xref linkend="ch-configuration" />. Changes to a module
+        documentation have to be checked to not break building the NixOS
+        manual:
+      </para>
+      <programlisting>
+$ nix-build nixos/release.nix -A manual.x86_64-linux
+</programlisting>
+    </listitem>
+  </itemizedlist>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/nixos-tests.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/development/nixos-tests.chapter.xml
new file mode 100644
index 000000000000..b9ff2269676c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/nixos-tests.chapter.xml
@@ -0,0 +1,14 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-nixos-tests">
+  <title>NixOS Tests</title>
+  <para>
+    When you add some feature to NixOS, you should write a test for it.
+    NixOS tests are kept in the directory
+    <literal>nixos/tests</literal>, and are executed (using Nix) by a
+    testing framework that automatically starts one or more virtual
+    machines containing the NixOS system(s) required for the test.
+  </para>
+  <xi:include href="writing-nixos-tests.section.xml" />
+  <xi:include href="running-nixos-tests.section.xml" />
+  <xi:include href="running-nixos-tests-interactively.section.xml" />
+  <xi:include href="linking-nixos-tests-to-packages.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/option-declarations.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/option-declarations.section.xml
new file mode 100644
index 000000000000..85a59a543d14
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/option-declarations.section.xml
@@ -0,0 +1,203 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-option-declarations">
+  <title>Option Declarations</title>
+  <para>
+    An option declaration specifies the name, type and description of a
+    NixOS configuration option. It is invalid to define an option that
+    hasn’t been declared in any module. An option declaration generally
+    looks like this:
+  </para>
+  <programlisting language="bash">
+options = {
+  name = mkOption {
+    type = type specification;
+    default = default value;
+    example = example value;
+    description = &quot;Description for use in the NixOS manual.&quot;;
+  };
+};
+</programlisting>
+  <para>
+    The attribute names within the <literal>name</literal> attribute
+    path must be camel cased in general but should, as an exception,
+    match the
+    <link xlink:href="https://nixos.org/nixpkgs/manual/#sec-package-naming">
+    package attribute name</link> when referencing a Nixpkgs package.
+    For example, the option
+    <literal>services.nix-serve.bindAddress</literal> references the
+    <literal>nix-serve</literal> Nixpkgs package.
+  </para>
+  <para>
+    The function <literal>mkOption</literal> accepts the following
+    arguments.
+  </para>
+  <variablelist>
+    <varlistentry>
+      <term>
+        <literal>type</literal>
+      </term>
+      <listitem>
+        <para>
+          The type of the option (see
+          <xref linkend="sec-option-types" />). It may be omitted, but
+          that’s not advisable since it may lead to errors that are hard
+          to diagnose.
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>default</literal>
+      </term>
+      <listitem>
+        <para>
+          The default value used if no value is defined by any module. A
+          default is not required; but if a default is not given, then
+          users of the module will have to define the value of the
+          option, otherwise an error will be thrown.
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>example</literal>
+      </term>
+      <listitem>
+        <para>
+          An example value that will be shown in the NixOS manual.
+        </para>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>
+        <literal>description</literal>
+      </term>
+      <listitem>
+        <para>
+          A textual description of the option, in DocBook format, that
+          will be included in the NixOS manual.
+        </para>
+      </listitem>
+    </varlistentry>
+  </variablelist>
+  <section xml:id="sec-option-declarations-eot">
+    <title>Extensible Option Types</title>
+    <para>
+      Extensible option types is a feature that allow to extend certain
+      types declaration through multiple module files. This feature only
+      work with a restricted set of types, namely
+      <literal>enum</literal> and <literal>submodules</literal> and any
+      composed forms of them.
+    </para>
+    <para>
+      Extensible option types can be used for <literal>enum</literal>
+      options that affects multiple modules, or as an alternative to
+      related <literal>enable</literal> options.
+    </para>
+    <para>
+      As an example, we will take the case of display managers. There is
+      a central display manager module for generic display manager
+      options and a module file per display manager backend (sddm, gdm
+      ...).
+    </para>
+    <para>
+      There are two approach to this module structure:
+    </para>
+    <itemizedlist>
+      <listitem>
+        <para>
+          Managing the display managers independently by adding an
+          enable option to every display manager module backend. (NixOS)
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          Managing the display managers in the central module by adding
+          an option to select which display manager backend to use.
+        </para>
+      </listitem>
+    </itemizedlist>
+    <para>
+      Both approaches have problems.
+    </para>
+    <para>
+      Making backends independent can quickly become hard to manage. For
+      display managers, there can be only one enabled at a time, but the
+      type system can not enforce this restriction as there is no
+      relation between each backend <literal>enable</literal> option. As
+      a result, this restriction has to be done explicitely by adding
+      assertions in each display manager backend module.
+    </para>
+    <para>
+      On the other hand, managing the display managers backends in the
+      central module will require to change the central module option
+      every time a new backend is added or removed.
+    </para>
+    <para>
+      By using extensible option types, it is possible to create a
+      placeholder option in the central module
+      (<link linkend="ex-option-declaration-eot-service">Example:
+      Extensible type placeholder in the service module</link>), and to
+      extend it in each backend module
+      (<link linkend="ex-option-declaration-eot-backend-gdm">Example:
+      Extending
+      <literal>services.xserver.displayManager.enable</literal> in the
+      <literal>gdm</literal> module</link>,
+      <link linkend="ex-option-declaration-eot-backend-sddm">Example:
+      Extending
+      <literal>services.xserver.displayManager.enable</literal> in the
+      <literal>sddm</literal> module</link>).
+    </para>
+    <para>
+      As a result, <literal>displayManager.enable</literal> option
+      values can be added without changing the main service module file
+      and the type system automatically enforce that there can only be a
+      single display manager enabled.
+    </para>
+    <anchor xml:id="ex-option-declaration-eot-service" />
+    <para>
+      <emphasis role="strong">Example: Extensible type placeholder in
+      the service module</emphasis>
+    </para>
+    <programlisting language="bash">
+services.xserver.displayManager.enable = mkOption {
+  description = &quot;Display manager to use&quot;;
+  type = with types; nullOr (enum [ ]);
+};
+</programlisting>
+    <anchor xml:id="ex-option-declaration-eot-backend-gdm" />
+    <para>
+      <emphasis role="strong">Example: Extending
+      <literal>services.xserver.displayManager.enable</literal> in the
+      <literal>gdm</literal> module</emphasis>
+    </para>
+    <programlisting language="bash">
+services.xserver.displayManager.enable = mkOption {
+  type = with types; nullOr (enum [ &quot;gdm&quot; ]);
+};
+</programlisting>
+    <anchor xml:id="ex-option-declaration-eot-backend-sddm" />
+    <para>
+      <emphasis role="strong">Example: Extending
+      <literal>services.xserver.displayManager.enable</literal> in the
+      <literal>sddm</literal> module</emphasis>
+    </para>
+    <programlisting language="bash">
+services.xserver.displayManager.enable = mkOption {
+  type = with types; nullOr (enum [ &quot;sddm&quot; ]);
+};
+</programlisting>
+    <para>
+      The placeholder declaration is a standard
+      <literal>mkOption</literal> declaration, but it is important that
+      extensible option declarations only use the
+      <literal>type</literal> argument.
+    </para>
+    <para>
+      Extensible option types work with any of the composed variants of
+      <literal>enum</literal> such as
+      <literal>with types; nullOr (enum [ &quot;foo&quot; &quot;bar&quot; ])</literal>
+      or
+      <literal>with types; listOf (enum [ &quot;foo&quot; &quot;bar&quot; ])</literal>.
+    </para>
+  </section>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/option-def.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/option-def.section.xml
new file mode 100644
index 000000000000..8c9ef181affd
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/option-def.section.xml
@@ -0,0 +1,104 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-option-definitions">
+  <title>Option Definitions</title>
+  <para>
+    Option definitions are generally straight-forward bindings of values
+    to option names, like
+  </para>
+  <programlisting language="bash">
+config = {
+  services.httpd.enable = true;
+};
+</programlisting>
+  <para>
+    However, sometimes you need to wrap an option definition or set of
+    option definitions in a <emphasis>property</emphasis> to achieve
+    certain effects:
+  </para>
+  <section xml:id="sec-option-definitions-delaying-conditionals">
+    <title>Delaying Conditionals</title>
+    <para>
+      If a set of option definitions is conditional on the value of
+      another option, you may need to use <literal>mkIf</literal>.
+      Consider, for instance:
+    </para>
+    <programlisting language="bash">
+config = if config.services.httpd.enable then {
+  environment.systemPackages = [ ... ];
+  ...
+} else {};
+</programlisting>
+    <para>
+      This definition will cause Nix to fail with an <quote>infinite
+      recursion</quote> error. Why? Because the value of
+      <literal>config.services.httpd.enable</literal> depends on the
+      value being constructed here. After all, you could also write the
+      clearly circular and contradictory:
+    </para>
+    <programlisting language="bash">
+config = if config.services.httpd.enable then {
+  services.httpd.enable = false;
+} else {
+  services.httpd.enable = true;
+};
+</programlisting>
+    <para>
+      The solution is to write:
+    </para>
+    <programlisting language="bash">
+config = mkIf config.services.httpd.enable {
+  environment.systemPackages = [ ... ];
+  ...
+};
+</programlisting>
+    <para>
+      The special function <literal>mkIf</literal> causes the evaluation
+      of the conditional to be <quote>pushed down</quote> into the
+      individual definitions, as if you had written:
+    </para>
+    <programlisting language="bash">
+config = {
+  environment.systemPackages = if config.services.httpd.enable then [ ... ] else [];
+  ...
+};
+</programlisting>
+  </section>
+  <section xml:id="sec-option-definitions-setting-priorities">
+    <title>Setting Priorities</title>
+    <para>
+      A module can override the definitions of an option in other
+      modules by setting a <emphasis>priority</emphasis>. All option
+      definitions that do not have the lowest priority value are
+      discarded. By default, option definitions have priority 1000. You
+      can specify an explicit priority by using
+      <literal>mkOverride</literal>, e.g.
+    </para>
+    <programlisting language="bash">
+services.openssh.enable = mkOverride 10 false;
+</programlisting>
+    <para>
+      This definition causes all other definitions with priorities above
+      10 to be discarded. The function <literal>mkForce</literal> is
+      equal to <literal>mkOverride 50</literal>.
+    </para>
+  </section>
+  <section xml:id="sec-option-definitions-merging">
+    <title>Merging Configurations</title>
+    <para>
+      In conjunction with <literal>mkIf</literal>, it is sometimes
+      useful for a module to return multiple sets of option definitions,
+      to be merged together as if they were declared in separate
+      modules. This can be done using <literal>mkMerge</literal>:
+    </para>
+    <programlisting language="bash">
+config = mkMerge
+  [ # Unconditional stuff.
+    { environment.systemPackages = [ ... ];
+    }
+    # Conditional stuff.
+    (mkIf config.services.bla.enable {
+      environment.systemPackages = [ ... ];
+    })
+  ];
+</programlisting>
+  </section>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/option-types.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/option-types.section.xml
new file mode 100644
index 000000000000..c83ffa2add53
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/option-types.section.xml
@@ -0,0 +1,987 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-option-types">
+  <title>Options Types</title>
+  <para>
+    Option types are a way to put constraints on the values a module
+    option can take. Types are also responsible of how values are merged
+    in case of multiple value definitions.
+  </para>
+  <section xml:id="sec-option-types-basic">
+    <title>Basic Types</title>
+    <para>
+      Basic types are the simplest available types in the module system.
+      Basic types include multiple string types that mainly differ in
+      how definition merging is handled.
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>types.bool</literal>
+        </term>
+        <listitem>
+          <para>
+            A boolean, its values can be <literal>true</literal> or
+            <literal>false</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.path</literal>
+        </term>
+        <listitem>
+          <para>
+            A filesystem path, defined as anything that when coerced to
+            a string starts with a slash. Even if derivations can be
+            considered as path, the more specific
+            <literal>types.package</literal> should be preferred.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.package</literal>
+        </term>
+        <listitem>
+          <para>
+            A derivation or a store path.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.anything</literal>
+        </term>
+        <listitem>
+          <para>
+            A type that accepts any value and recursively merges
+            attribute sets together. This type is recommended when the
+            option type is unknown.
+          </para>
+          <anchor xml:id="ex-types-anything" />
+          <para>
+            <emphasis role="strong">Example:
+            <literal>types.anything</literal> Example</emphasis>
+          </para>
+          <para>
+            Two definitions of this type like
+          </para>
+          <programlisting language="bash">
+{
+  str = lib.mkDefault &quot;foo&quot;;
+  pkg.hello = pkgs.hello;
+  fun.fun = x: x + 1;
+}
+</programlisting>
+          <programlisting language="bash">
+{
+  str = lib.mkIf true &quot;bar&quot;;
+  pkg.gcc = pkgs.gcc;
+  fun.fun = lib.mkForce (x: x + 2);
+}
+</programlisting>
+          <para>
+            will get merged to
+          </para>
+          <programlisting language="bash">
+{
+  str = &quot;bar&quot;;
+  pkg.gcc = pkgs.gcc;
+  pkg.hello = pkgs.hello;
+  fun.fun = x: x + 2;
+}
+</programlisting>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.attrs</literal>
+        </term>
+        <listitem>
+          <para>
+            A free-form attribute set.
+          </para>
+          <warning>
+            <para>
+              This type will be deprecated in the future because it
+              doesn't recurse into attribute sets, silently drops
+              earlier attribute definitions, and doesn't discharge
+              <literal>lib.mkDefault</literal>,
+              <literal>lib.mkIf</literal> and co. For allowing arbitrary
+              attribute sets, prefer
+              <literal>types.attrsOf types.anything</literal> instead
+              which doesn't have these problems.
+            </para>
+          </warning>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+    <para>
+      Integer-related types:
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>types.int</literal>
+        </term>
+        <listitem>
+          <para>
+            A signed integer.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.ints.{s8, s16, s32}</literal>
+        </term>
+        <listitem>
+          <para>
+            Signed integers with a fixed length (8, 16 or 32 bits). They
+            go from −2^n/2 to 2^n/2−1 respectively (e.g.
+            <literal>−128</literal> to <literal>127</literal> for 8
+            bits).
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.ints.unsigned</literal>
+        </term>
+        <listitem>
+          <para>
+            An unsigned integer (that is &gt;= 0).
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.ints.{u8, u16, u32}</literal>
+        </term>
+        <listitem>
+          <para>
+            Unsigned integers with a fixed length (8, 16 or 32 bits).
+            They go from 0 to 2^n−1 respectively (e.g.
+            <literal>0</literal> to <literal>255</literal> for 8 bits).
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.ints.positive</literal>
+        </term>
+        <listitem>
+          <para>
+            A positive integer (that is &gt; 0).
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.port</literal>
+        </term>
+        <listitem>
+          <para>
+            A port number. This type is an alias to
+            <literal>types.ints.u16</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+    <para>
+      String-related types:
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>types.str</literal>
+        </term>
+        <listitem>
+          <para>
+            A string. Multiple definitions cannot be merged.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.lines</literal>
+        </term>
+        <listitem>
+          <para>
+            A string. Multiple definitions are concatenated with a new
+            line <literal>&quot;\n&quot;</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.commas</literal>
+        </term>
+        <listitem>
+          <para>
+            A string. Multiple definitions are concatenated with a comma
+            <literal>&quot;,&quot;</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.envVar</literal>
+        </term>
+        <listitem>
+          <para>
+            A string. Multiple definitions are concatenated with a
+            collon <literal>&quot;:&quot;</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.strMatching</literal>
+        </term>
+        <listitem>
+          <para>
+            A string matching a specific regular expression. Multiple
+            definitions cannot be merged. The regular expression is
+            processed using <literal>builtins.match</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </section>
+  <section xml:id="sec-option-types-value">
+    <title>Value Types</title>
+    <para>
+      Value types are types that take a value parameter.
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>types.enum</literal>
+          <emphasis><literal>l</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            One element of the list
+            <emphasis><literal>l</literal></emphasis>, e.g.
+            <literal>types.enum [ &quot;left&quot; &quot;right&quot; ]</literal>.
+            Multiple definitions cannot be merged.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.separatedString</literal>
+          <emphasis><literal>sep</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            A string with a custom separator
+            <emphasis><literal>sep</literal></emphasis>, e.g.
+            <literal>types.separatedString &quot;|&quot;</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.ints.between</literal>
+          <emphasis><literal>lowest highest</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            An integer between
+            <emphasis><literal>lowest</literal></emphasis> and
+            <emphasis><literal>highest</literal></emphasis> (both
+            inclusive). Useful for creating types like
+            <literal>types.port</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.submodule</literal>
+          <emphasis><literal>o</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            A set of sub options
+            <emphasis><literal>o</literal></emphasis>.
+            <emphasis><literal>o</literal></emphasis> can be an
+            attribute set, a function returning an attribute set, or a
+            path to a file containing such a value. Submodules are used
+            in composed types to create modular options. This is
+            equivalent to
+            <literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
+            Submodules are detailed in
+            <link linkend="section-option-types-submodule">Submodule</link>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.submoduleWith</literal> {
+          <emphasis><literal>modules</literal></emphasis>,
+          <emphasis><literal>specialArgs</literal></emphasis> ? {},
+          <emphasis><literal>shorthandOnlyDefinesConfig</literal></emphasis>
+          ? false }
+        </term>
+        <listitem>
+          <para>
+            Like <literal>types.submodule</literal>, but more flexible
+            and with better defaults. It has parameters
+          </para>
+          <itemizedlist>
+            <listitem>
+              <para>
+                <emphasis><literal>modules</literal></emphasis> A list
+                of modules to use by default for this submodule type.
+                This gets combined with all option definitions to build
+                the final list of modules that will be included.
+              </para>
+              <note>
+                <para>
+                  Only options defined with this argument are included
+                  in rendered documentation.
+                </para>
+              </note>
+            </listitem>
+            <listitem>
+              <para>
+                <emphasis><literal>specialArgs</literal></emphasis> An
+                attribute set of extra arguments to be passed to the
+                module functions. The option
+                <literal>_module.args</literal> should be used instead
+                for most arguments since it allows overriding.
+                <emphasis><literal>specialArgs</literal></emphasis>
+                should only be used for arguments that can't go through
+                the module fixed-point, because of infinite recursion or
+                other problems. An example is overriding the
+                <literal>lib</literal> argument, because
+                <literal>lib</literal> itself is used to define
+                <literal>_module.args</literal>, which makes using
+                <literal>_module.args</literal> to define it impossible.
+              </para>
+            </listitem>
+            <listitem>
+              <para>
+                <emphasis><literal>shorthandOnlyDefinesConfig</literal></emphasis>
+                Whether definitions of this type should default to the
+                <literal>config</literal> section of a module (see
+                <link linkend="ex-module-syntax">Example: Structure of
+                NixOS Modules</link>) if it is an attribute set.
+                Enabling this only has a benefit when the submodule
+                defines an option named <literal>config</literal> or
+                <literal>options</literal>. In such a case it would
+                allow the option to be set with
+                <literal>the-submodule.config = &quot;value&quot;</literal>
+                instead of requiring
+                <literal>the-submodule.config.config = &quot;value&quot;</literal>.
+                This is because only when modules
+                <emphasis>don't</emphasis> set the
+                <literal>config</literal> or <literal>options</literal>
+                keys, all keys are interpreted as option definitions in
+                the <literal>config</literal> section. Enabling this
+                option implicitly puts all attributes in the
+                <literal>config</literal> section.
+              </para>
+              <para>
+                With this option enabled, defining a
+                non-<literal>config</literal> section requires using a
+                function:
+                <literal>the-submodule = { ... }: { options = { ... }; }</literal>.
+              </para>
+            </listitem>
+          </itemizedlist>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </section>
+  <section xml:id="sec-option-types-composed">
+    <title>Composed Types</title>
+    <para>
+      Composed types are types that take a type as parameter.
+      <literal>listOf int</literal> and
+      <literal>either int str</literal> are examples of composed types.
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>types.listOf</literal>
+          <emphasis><literal>t</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            A list of <emphasis><literal>t</literal></emphasis> type,
+            e.g. <literal>types.listOf int</literal>. Multiple
+            definitions are merged with list concatenation.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.attrsOf</literal>
+          <emphasis><literal>t</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            An attribute set of where all the values are of
+            <emphasis><literal>t</literal></emphasis> type. Multiple
+            definitions result in the joined attribute set.
+          </para>
+          <note>
+            <para>
+              This type is <emphasis>strict</emphasis> in its values,
+              which in turn means attributes cannot depend on other
+              attributes. See <literal> types.lazyAttrsOf</literal> for
+              a lazy version.
+            </para>
+          </note>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.lazyAttrsOf</literal>
+          <emphasis><literal>t</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            An attribute set of where all the values are of
+            <emphasis><literal>t</literal></emphasis> type. Multiple
+            definitions result in the joined attribute set. This is the
+            lazy version of <literal>types.attrsOf </literal>, allowing
+            attributes to depend on each other.
+          </para>
+          <warning>
+            <para>
+              This version does not fully support conditional
+              definitions! With an option <literal>foo</literal> of this
+              type and a definition
+              <literal>foo.attr = lib.mkIf false 10</literal>,
+              evaluating <literal>foo ? attr</literal> will return
+              <literal>true</literal> even though it should be false.
+              Accessing the value will then throw an error. For types
+              <emphasis><literal>t</literal></emphasis> that have an
+              <literal>emptyValue</literal> defined, that value will be
+              returned instead of throwing an error. So if the type of
+              <literal>foo.attr</literal> was
+              <literal>lazyAttrsOf (nullOr int)</literal>,
+              <literal>null</literal> would be returned instead for the
+              same <literal>mkIf false</literal> definition.
+            </para>
+          </warning>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.nullOr</literal>
+          <emphasis><literal>t</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            <literal>null</literal> or type
+            <emphasis><literal>t</literal></emphasis>. Multiple
+            definitions are merged according to type
+            <emphasis><literal>t</literal></emphasis>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.uniq</literal>
+          <emphasis><literal>t</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            Ensures that type <emphasis><literal>t</literal></emphasis>
+            cannot be merged. It is used to ensure option definitions
+            are declared only once.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.either</literal>
+          <emphasis><literal>t1 t2</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            Type <emphasis><literal>t1</literal></emphasis> or type
+            <emphasis><literal>t2</literal></emphasis>, e.g.
+            <literal>with types; either int str</literal>. Multiple
+            definitions cannot be merged.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.oneOf</literal> [
+          <emphasis><literal>t1 t2</literal></emphasis> ... ]
+        </term>
+        <listitem>
+          <para>
+            Type <emphasis><literal>t1</literal></emphasis> or type
+            <emphasis><literal>t2</literal></emphasis> and so forth,
+            e.g. <literal>with types; oneOf [ int str bool ]</literal>.
+            Multiple definitions cannot be merged.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>types.coercedTo</literal>
+          <emphasis><literal>from f to</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            Type <emphasis><literal>to</literal></emphasis> or type
+            <emphasis><literal>from</literal></emphasis> which will be
+            coerced to type <emphasis><literal>to</literal></emphasis>
+            using function <emphasis><literal>f</literal></emphasis>
+            which takes an argument of type
+            <emphasis><literal>from</literal></emphasis> and return a
+            value of type <emphasis><literal>to</literal></emphasis>.
+            Can be used to preserve backwards compatibility of an option
+            if its type was changed.
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </section>
+  <section xml:id="section-option-types-submodule">
+    <title>Submodule</title>
+    <para>
+      <literal>submodule</literal> is a very powerful type that defines
+      a set of sub-options that are handled like a separate module.
+    </para>
+    <para>
+      It takes a parameter <emphasis><literal>o</literal></emphasis>,
+      that should be a set, or a function returning a set with an
+      <literal>options</literal> key defining the sub-options. Submodule
+      option definitions are type-checked accordingly to the
+      <literal>options</literal> declarations. Of course, you can nest
+      submodule option definitons for even higher modularity.
+    </para>
+    <para>
+      The option set can be defined directly
+      (<link linkend="ex-submodule-direct">Example: Directly defined
+      submodule</link>) or as reference
+      (<link linkend="ex-submodule-reference">Example: Submodule defined
+      as a reference</link>).
+    </para>
+    <anchor xml:id="ex-submodule-direct" />
+    <para>
+      <emphasis role="strong">Example: Directly defined
+      submodule</emphasis>
+    </para>
+    <programlisting language="bash">
+options.mod = mkOption {
+  description = &quot;submodule example&quot;;
+  type = with types; submodule {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = str;
+      };
+    };
+  };
+};
+</programlisting>
+    <anchor xml:id="ex-submodule-reference" />
+    <para>
+      <emphasis role="strong">Example: Submodule defined as a
+      reference</emphasis>
+    </para>
+    <programlisting language="bash">
+let
+  modOptions = {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = int;
+      };
+    };
+  };
+in
+options.mod = mkOption {
+  description = &quot;submodule example&quot;;
+  type = with types; submodule modOptions;
+};
+</programlisting>
+    <para>
+      The <literal>submodule</literal> type is especially interesting
+      when used with composed types like <literal>attrsOf</literal> or
+      <literal>listOf</literal>. When composed with
+      <literal>listOf</literal>
+      (<link linkend="ex-submodule-listof-declaration">Example:
+      Declaration of a list of submodules</link>),
+      <literal>submodule</literal> allows multiple definitions of the
+      submodule option set
+      (<link linkend="ex-submodule-listof-definition">Example:
+      Definition of a list of submodules</link>).
+    </para>
+    <anchor xml:id="ex-submodule-listof-declaration" />
+    <para>
+      <emphasis role="strong">Example: Declaration of a list of
+      submodules</emphasis>
+    </para>
+    <programlisting language="bash">
+options.mod = mkOption {
+  description = &quot;submodule example&quot;;
+  type = with types; listOf (submodule {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = str;
+      };
+    };
+  });
+};
+</programlisting>
+    <anchor xml:id="ex-submodule-listof-definition" />
+    <para>
+      <emphasis role="strong">Example: Definition of a list of
+      submodules</emphasis>
+    </para>
+    <programlisting language="bash">
+config.mod = [
+  { foo = 1; bar = &quot;one&quot;; }
+  { foo = 2; bar = &quot;two&quot;; }
+];
+</programlisting>
+    <para>
+      When composed with <literal>attrsOf</literal>
+      (<link linkend="ex-submodule-attrsof-declaration">Example:
+      Declaration of attribute sets of submodules</link>),
+      <literal>submodule</literal> allows multiple named definitions of
+      the submodule option set
+      (<link linkend="ex-submodule-attrsof-definition">Example:
+      Definition of attribute sets of submodules</link>).
+    </para>
+    <anchor xml:id="ex-submodule-attrsof-declaration" />
+    <para>
+      <emphasis role="strong">Example: Declaration of attribute sets of
+      submodules</emphasis>
+    </para>
+    <programlisting language="bash">
+options.mod = mkOption {
+  description = &quot;submodule example&quot;;
+  type = with types; attrsOf (submodule {
+    options = {
+      foo = mkOption {
+        type = int;
+      };
+      bar = mkOption {
+        type = str;
+      };
+    };
+  });
+};
+</programlisting>
+    <anchor xml:id="ex-submodule-attrsof-definition" />
+    <para>
+      <emphasis role="strong">Example: Definition of attribute sets of
+      submodules</emphasis>
+    </para>
+    <programlisting language="bash">
+config.mod.one = { foo = 1; bar = &quot;one&quot;; };
+config.mod.two = { foo = 2; bar = &quot;two&quot;; };
+</programlisting>
+  </section>
+  <section xml:id="sec-option-types-extending">
+    <title>Extending types</title>
+    <para>
+      Types are mainly characterized by their <literal>check</literal>
+      and <literal>merge</literal> functions.
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>check</literal>
+        </term>
+        <listitem>
+          <para>
+            The function to type check the value. Takes a value as
+            parameter and return a boolean. It is possible to extend a
+            type check with the <literal>addCheck</literal> function
+            (<link linkend="ex-extending-type-check-1">Example: Adding a
+            type check</link>), or to fully override the check function
+            (<link linkend="ex-extending-type-check-2">Example:
+            Overriding a type check</link>).
+          </para>
+          <anchor xml:id="ex-extending-type-check-1" />
+          <para>
+            <emphasis role="strong">Example: Adding a type
+            check</emphasis>
+          </para>
+          <programlisting language="bash">
+byte = mkOption {
+  description = &quot;An integer between 0 and 255.&quot;;
+  type = types.addCheck types.int (x: x &gt;= 0 &amp;&amp; x &lt;= 255);
+};
+</programlisting>
+          <anchor xml:id="ex-extending-type-check-2" />
+          <para>
+            <emphasis role="strong">Example: Overriding a type
+            check</emphasis>
+          </para>
+          <programlisting language="bash">
+nixThings = mkOption {
+  description = &quot;words that start with 'nix'&quot;;
+  type = types.str // {
+    check = (x: lib.hasPrefix &quot;nix&quot; x)
+  };
+};
+</programlisting>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>merge</literal>
+        </term>
+        <listitem>
+          <para>
+            Function to merge the options values when multiple values
+            are set. The function takes two parameters,
+            <literal>loc</literal> the option path as a list of strings,
+            and <literal>defs</literal> the list of defined values as a
+            list. It is possible to override a type merge function for
+            custom needs.
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </section>
+  <section xml:id="sec-option-types-custom">
+    <title>Custom Types</title>
+    <para>
+      Custom types can be created with the
+      <literal>mkOptionType</literal> function. As type creation
+      includes some more complex topics such as submodule handling, it
+      is recommended to get familiar with <literal>types.nix</literal>
+      code before creating a new type.
+    </para>
+    <para>
+      The only required parameter is <literal>name</literal>.
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>name</literal>
+        </term>
+        <listitem>
+          <para>
+            A string representation of the type function name.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>definition</literal>
+        </term>
+        <listitem>
+          <para>
+            Description of the type used in documentation. Give
+            information of the type and any of its arguments.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>check</literal>
+        </term>
+        <listitem>
+          <para>
+            A function to type check the definition value. Takes the
+            definition value as a parameter and returns a boolean
+            indicating the type check result, <literal>true</literal>
+            for success and <literal>false</literal> for failure.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>merge</literal>
+        </term>
+        <listitem>
+          <para>
+            A function to merge multiple definitions values. Takes two
+            parameters:
+          </para>
+          <variablelist>
+            <varlistentry>
+              <term>
+                <emphasis><literal>loc</literal></emphasis>
+              </term>
+              <listitem>
+                <para>
+                  The option path as a list of strings, e.g.
+                  <literal>[&quot;boot&quot; &quot;loader &quot;grub&quot; &quot;enable&quot;]</literal>.
+                </para>
+              </listitem>
+            </varlistentry>
+            <varlistentry>
+              <term>
+                <emphasis><literal>defs</literal></emphasis>
+              </term>
+              <listitem>
+                <para>
+                  The list of sets of defined <literal>value</literal>
+                  and <literal>file</literal> where the value was
+                  defined, e.g.
+                  <literal>[ { file = &quot;/foo.nix&quot;; value = 1; } { file = &quot;/bar.nix&quot;; value = 2 } ]</literal>.
+                  The <literal>merge</literal> function should return
+                  the merged value or throw an error in case the values
+                  are impossible or not meant to be merged.
+                </para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>getSubOptions</literal>
+        </term>
+        <listitem>
+          <para>
+            For composed types that can take a submodule as type
+            parameter, this function generate sub-options documentation.
+            It takes the current option prefix as a list and return the
+            set of sub-options. Usually defined in a recursive manner by
+            adding a term to the prefix, e.g.
+            <literal>prefix: elemType.getSubOptions (prefix ++ [&quot;prefix&quot;])</literal>
+            where
+            <emphasis><literal>&quot;prefix&quot;</literal></emphasis>
+            is the newly added prefix.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>getSubModules</literal>
+        </term>
+        <listitem>
+          <para>
+            For composed types that can take a submodule as type
+            parameter, this function should return the type parameters
+            submodules. If the type parameter is called
+            <literal>elemType</literal>, the function should just
+            recursively look into submodules by returning
+            <literal>elemType.getSubModules;</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>substSubModules</literal>
+        </term>
+        <listitem>
+          <para>
+            For composed types that can take a submodule as type
+            parameter, this function can be used to substitute the
+            parameter of a submodule type. It takes a module as
+            parameter and return the type with the submodule options
+            substituted. It is usually defined as a type function call
+            with a recursive call to <literal>substSubModules</literal>,
+            e.g for a type <literal>composedType</literal> that take an
+            <literal>elemtype</literal> type parameter, this function
+            should be defined as
+            <literal>m: composedType (elemType.substSubModules m)</literal>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>typeMerge</literal>
+        </term>
+        <listitem>
+          <para>
+            A function to merge multiple type declarations. Takes the
+            type to merge <literal>functor</literal> as parameter. A
+            <literal>null</literal> return value means that type cannot
+            be merged.
+          </para>
+          <variablelist>
+            <varlistentry>
+              <term>
+                <emphasis><literal>f</literal></emphasis>
+              </term>
+              <listitem>
+                <para>
+                  The type to merge <literal>functor</literal>.
+                </para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+          <para>
+            Note: There is a generic <literal>defaultTypeMerge</literal>
+            that work with most of value and composed types.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>functor</literal>
+        </term>
+        <listitem>
+          <para>
+            An attribute set representing the type. It is used for type
+            operations and has the following keys:
+          </para>
+          <variablelist>
+            <varlistentry>
+              <term>
+                <literal>type</literal>
+              </term>
+              <listitem>
+                <para>
+                  The type function.
+                </para>
+              </listitem>
+            </varlistentry>
+            <varlistentry>
+              <term>
+                <literal>wrapped</literal>
+              </term>
+              <listitem>
+                <para>
+                  Holds the type parameter for composed types.
+                </para>
+              </listitem>
+            </varlistentry>
+            <varlistentry>
+              <term>
+                <literal>payload</literal>
+              </term>
+              <listitem>
+                <para>
+                  Holds the value parameter for value types. The types
+                  that have a <literal>payload</literal> are the
+                  <literal>enum</literal>,
+                  <literal>separatedString</literal> and
+                  <literal>submodule</literal> types.
+                </para>
+              </listitem>
+            </varlistentry>
+            <varlistentry>
+              <term>
+                <literal>binOp</literal>
+              </term>
+              <listitem>
+                <para>
+                  A binary operation that can merge the payloads of two
+                  same types. Defined as a function that take two
+                  payloads as parameters and return the payloads merged.
+                </para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </section>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/replace-modules.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/replace-modules.section.xml
new file mode 100644
index 000000000000..cf8a39ba844f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/replace-modules.section.xml
@@ -0,0 +1,70 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-replace-modules">
+  <title>Replace Modules</title>
+  <para>
+    Modules that are imported can also be disabled. The option
+    declarations, config implementation and the imports of a disabled
+    module will be ignored, allowing another to take it's place. This
+    can be used to import a set of modules from another channel while
+    keeping the rest of the system on a stable release.
+  </para>
+  <para>
+    <literal>disabledModules</literal> is a top level attribute like
+    <literal>imports</literal>, <literal>options</literal> and
+    <literal>config</literal>. It contains a list of modules that will
+    be disabled. This can either be the full path to the module or a
+    string with the filename relative to the modules path (eg.
+    &lt;nixpkgs/nixos/modules&gt; for nixos).
+  </para>
+  <para>
+    This example will replace the existing postgresql module with the
+    version defined in the nixos-unstable channel while keeping the rest
+    of the modules and packages from the original nixos channel. This
+    only overrides the module definition, this won't use postgresql from
+    nixos-unstable unless explicitly configured to do so.
+  </para>
+  <programlisting language="bash">
+{ config, lib, pkgs, ... }:
+
+{
+  disabledModules = [ &quot;services/databases/postgresql.nix&quot; ];
+
+  imports =
+    [ # Use postgresql service from nixos-unstable channel.
+      # sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
+      &lt;nixos-unstable/nixos/modules/services/databases/postgresql.nix&gt;
+    ];
+
+  services.postgresql.enable = true;
+}
+</programlisting>
+  <para>
+    This example shows how to define a custom module as a replacement
+    for an existing module. Importing this module will disable the
+    original module without having to know it's implementation details.
+  </para>
+  <programlisting language="bash">
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.programs.man;
+in
+
+{
+  disabledModules = [ &quot;services/programs/man.nix&quot; ];
+
+  options = {
+    programs.man.enable = mkOption {
+      type = types.bool;
+      default = true;
+      description = &quot;Whether to enable manual pages.&quot;;
+    };
+  };
+
+  config = mkIf cfg.enabled {
+    warnings = [ &quot;disabled manpages for production deployments.&quot; ];
+  };
+}
+</programlisting>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/settings-options.section.xml b/nixpkgs/nixos/doc/manual/from_md/development/settings-options.section.xml
new file mode 100644
index 000000000000..c9430b77579c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/settings-options.section.xml
@@ -0,0 +1,285 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-settings-options">
+  <title>Options for Program Settings</title>
+  <para>
+    Many programs have configuration files where program-specific
+    settings can be declared. File formats can be separated into two
+    categories:
+  </para>
+  <itemizedlist>
+    <listitem>
+      <para>
+        Nix-representable ones: These can trivially be mapped to a
+        subset of Nix syntax. E.g. JSON is an example, since its values
+        like <literal>{&quot;foo&quot;:{&quot;bar&quot;:10}}</literal>
+        can be mapped directly to Nix:
+        <literal>{ foo = { bar = 10; }; }</literal>. Other examples are
+        INI, YAML and TOML. The following section explains the
+        convention for these settings.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Non-nix-representable ones: These can't be trivially mapped to a
+        subset of Nix syntax. Most generic programming languages are in
+        this group, e.g. bash, since the statement
+        <literal>if true; then echo hi; fi</literal> doesn't have a
+        trivial representation in Nix.
+      </para>
+      <para>
+        Currently there are no fixed conventions for these, but it is
+        common to have a <literal>configFile</literal> option for
+        setting the configuration file path directly. The default value
+        of <literal>configFile</literal> can be an auto-generated file,
+        with convenient options for controlling the contents. For
+        example an option of type <literal>attrsOf str</literal> can be
+        used for representing environment variables which generates a
+        section like <literal>export FOO=&quot;foo&quot;</literal>.
+        Often it can also be useful to also include an
+        <literal>extraConfig</literal> option of type
+        <literal>lines</literal> to allow arbitrary text after the
+        autogenerated part of the file.
+      </para>
+    </listitem>
+  </itemizedlist>
+  <section xml:id="sec-settings-nix-representable">
+    <title>Nix-representable Formats (JSON, YAML, TOML, INI,
+    ...)</title>
+    <para>
+      By convention, formats like this are handled with a generic
+      <literal>settings</literal> option, representing the full program
+      configuration as a Nix value. The type of this option should
+      represent the format. The most common formats have a predefined
+      type and string generator already declared under
+      <literal>pkgs.formats</literal>:
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>pkgs.formats.json</literal> { }
+        </term>
+        <listitem>
+          <para>
+            A function taking an empty attribute set (for future
+            extensibility) and returning a set with JSON-specific
+            attributes <literal>type</literal> and
+            <literal>generate</literal> as specified
+            <link linkend="pkgs-formats-result">below</link>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>pkgs.formats.yaml</literal> { }
+        </term>
+        <listitem>
+          <para>
+            A function taking an empty attribute set (for future
+            extensibility) and returning a set with YAML-specific
+            attributes <literal>type</literal> and
+            <literal>generate</literal> as specified
+            <link linkend="pkgs-formats-result">below</link>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>pkgs.formats.ini</literal> {
+          <emphasis><literal>listsAsDuplicateKeys</literal></emphasis> ?
+          false, <emphasis><literal>listToValue</literal></emphasis> ?
+          null, ... }
+        </term>
+        <listitem>
+          <para>
+            A function taking an attribute set with values
+          </para>
+          <variablelist>
+            <varlistentry>
+              <term>
+                <literal>listsAsDuplicateKeys</literal>
+              </term>
+              <listitem>
+                <para>
+                  A boolean for controlling whether list values can be
+                  used to represent duplicate INI keys
+                </para>
+              </listitem>
+            </varlistentry>
+            <varlistentry>
+              <term>
+                <literal>listToValue</literal>
+              </term>
+              <listitem>
+                <para>
+                  A function for turning a list of values into a single
+                  value.
+                </para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+          <para>
+            It returns a set with INI-specific attributes
+            <literal>type</literal> and <literal>generate</literal> as
+            specified <link linkend="pkgs-formats-result">below</link>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>pkgs.formats.toml</literal> { }
+        </term>
+        <listitem>
+          <para>
+            A function taking an empty attribute set (for future
+            extensibility) and returning a set with TOML-specific
+            attributes <literal>type</literal> and
+            <literal>generate</literal> as specified
+            <link linkend="pkgs-formats-result">below</link>.
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+    <para xml:id="pkgs-formats-result">
+      These functions all return an attribute set with these values:
+    </para>
+    <variablelist>
+      <varlistentry>
+        <term>
+          <literal>type</literal>
+        </term>
+        <listitem>
+          <para>
+            A module system type representing a value of the format
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <literal>generate</literal>
+          <emphasis><literal>filename jsonValue</literal></emphasis>
+        </term>
+        <listitem>
+          <para>
+            A function that can render a value of the format to a file.
+            Returns a file path.
+          </para>
+          <note>
+            <para>
+              This function puts the value contents in the Nix store. So
+              this should be avoided for secrets.
+            </para>
+          </note>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+    <anchor xml:id="ex-settings-nix-representable" />
+    <para>
+      <emphasis role="strong">Example: Module with conventional
+      <literal>settings</literal> option</emphasis>
+    </para>
+    <para>
+      The following shows a module for an example program that uses a
+      JSON configuration file. It demonstrates how above values can be
+      used, along with some other related best practices. See the
+      comments for explanations.
+    </para>
+    <programlisting language="bash">
+{ options, config, lib, pkgs, ... }:
+let
+  cfg = config.services.foo;
+  # Define the settings format used for this program
+  settingsFormat = pkgs.formats.json {};
+in {
+
+  options.services.foo = {
+    enable = lib.mkEnableOption &quot;foo service&quot;;
+
+    settings = lib.mkOption {
+      # Setting this type allows for correct merging behavior
+      type = settingsFormat.type;
+      default = {};
+      description = ''
+        Configuration for foo, see
+        &lt;link xlink:href=&quot;https://example.com/docs/foo&quot;/&gt;
+        for supported settings.
+      '';
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    # We can assign some default settings here to make the service work by just
+    # enabling it. We use `mkDefault` for values that can be changed without
+    # problems
+    services.foo.settings = {
+      # Fails at runtime without any value set
+      log_level = lib.mkDefault &quot;WARN&quot;;
+
+      # We assume systemd's `StateDirectory` is used, so we require this value,
+      # therefore no mkDefault
+      data_path = &quot;/var/lib/foo&quot;;
+
+      # Since we use this to create a user we need to know the default value at
+      # eval time
+      user = lib.mkDefault &quot;foo&quot;;
+    };
+
+    environment.etc.&quot;foo.json&quot;.source =
+      # The formats generator function takes a filename and the Nix value
+      # representing the format value and produces a filepath with that value
+      # rendered in the format
+      settingsFormat.generate &quot;foo-config.json&quot; cfg.settings;
+
+    # We know that the `user` attribute exists because we set a default value
+    # for it above, allowing us to use it without worries here
+    users.users.${cfg.settings.user} = { isSystemUser = true; };
+
+    # ...
+  };
+}
+</programlisting>
+    <section xml:id="sec-settings-attrs-options">
+      <title>Option declarations for attributes</title>
+      <para>
+        Some <literal>settings</literal> attributes may deserve some
+        extra care. They may need a different type, default or merging
+        behavior, or they are essential options that should show their
+        documentation in the manual. This can be done using
+        <xref linkend="sec-freeform-modules" />.
+      </para>
+      <para>
+        We extend above example using freeform modules to declare an
+        option for the port, which will enforce it to be a valid integer
+        and make it show up in the manual.
+      </para>
+      <anchor xml:id="ex-settings-typed-attrs" />
+      <para>
+        <emphasis role="strong">Example: Declaring a type-checked
+        <literal>settings</literal> attribute</emphasis>
+      </para>
+      <programlisting language="bash">
+settings = lib.mkOption {
+  type = lib.types.submodule {
+
+    freeformType = settingsFormat.type;
+
+    # Declare an option for the port such that the type is checked and this option
+    # is shown in the manual.
+    options.port = lib.mkOption {
+      type = lib.types.port;
+      default = 8080;
+      description = ''
+        Which port this service should listen on.
+      '';
+    };
+
+  };
+  default = {};
+  description = ''
+    Configuration for Foo, see
+    &lt;link xlink:href=&quot;https://example.com/docs/foo&quot;/&gt;
+    for supported values.
+  '';
+};
+</programlisting>
+    </section>
+  </section>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/sources.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/development/sources.chapter.xml
new file mode 100644
index 000000000000..aac18c9d06c8
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/sources.chapter.xml
@@ -0,0 +1,90 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-getting-sources">
+  <title>Getting the Sources</title>
+  <para>
+    By default, NixOS’s <literal>nixos-rebuild</literal> command uses
+    the NixOS and Nixpkgs sources provided by the
+    <literal>nixos</literal> channel (kept in
+    <literal>/nix/var/nix/profiles/per-user/root/channels/nixos</literal>).
+    To modify NixOS, however, you should check out the latest sources
+    from Git. This is as follows:
+  </para>
+  <programlisting>
+$ git clone https://github.com/NixOS/nixpkgs
+$ cd nixpkgs
+$ git remote update origin
+</programlisting>
+  <para>
+    This will check out the latest Nixpkgs sources to
+    <literal>./nixpkgs</literal> the NixOS sources to
+    <literal>./nixpkgs/nixos</literal>. (The NixOS source tree lives in
+    a subdirectory of the Nixpkgs repository.) The
+    <literal>nixpkgs</literal> repository has branches that correspond
+    to each Nixpkgs/NixOS channel (see <xref linkend="sec-upgrading" />
+    for more information about channels). Thus, the Git branch
+    <literal>origin/nixos-17.03</literal> will contain the latest built
+    and tested version available in the <literal>nixos-17.03</literal>
+    channel.
+  </para>
+  <para>
+    It’s often inconvenient to develop directly on the master branch,
+    since if somebody has just committed (say) a change to GCC, then the
+    binary cache may not have caught up yet and you’ll have to rebuild
+    everything from source. So you may want to create a local branch
+    based on your current NixOS version:
+  </para>
+  <programlisting>
+$ nixos-version
+17.09pre104379.6e0b727 (Hummingbird)
+
+$ git checkout -b local 6e0b727
+</programlisting>
+  <para>
+    Or, to base your local branch on the latest version available in a
+    NixOS channel:
+  </para>
+  <programlisting>
+$ git remote update origin
+$ git checkout -b local origin/nixos-17.03
+</programlisting>
+  <para>
+    (Replace <literal>nixos-17.03</literal> with the name of the channel
+    you want to use.) You can use <literal>git merge</literal> or
+    <literal>git rebase</literal> to keep your local branch in sync with
+    the channel, e.g.
+  </para>
+  <programlisting>
+$ git remote update origin
+$ git merge origin/nixos-17.03
+</programlisting>
+  <para>
+    You can use <literal>git cherry-pick</literal> to copy commits from
+    your local branch to the upstream branch.
+  </para>
+  <para>
+    If you want to rebuild your system using your (modified) sources,
+    you need to tell <literal>nixos-rebuild</literal> about them using
+    the <literal>-I</literal> flag:
+  </para>
+  <programlisting>
+# nixos-rebuild switch -I nixpkgs=/my/sources/nixpkgs
+</programlisting>
+  <para>
+    If you want <literal>nix-env</literal> to use the expressions in
+    <literal>/my/sources</literal>, use
+    <literal>nix-env -f /my/sources/nixpkgs</literal>, or change the
+    default by adding a symlink in <literal>~/.nix-defexpr</literal>:
+  </para>
+  <programlisting>
+$ ln -s /my/sources/nixpkgs ~/.nix-defexpr/nixpkgs
+</programlisting>
+  <para>
+    You may want to delete the symlink
+    <literal>~/.nix-defexpr/channels_root</literal> to prevent root’s
+    NixOS channel from clashing with your own tree (this may break the
+    command-not-found utility though). If you want to go back to the
+    default state, you may just remove the
+    <literal>~/.nix-defexpr</literal> directory completely, log out and
+    log in again and it should have been recreated with a link to the
+    root channels.
+  </para>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/testing-installer.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/development/testing-installer.chapter.xml
new file mode 100644
index 000000000000..286d49f3c291
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/testing-installer.chapter.xml
@@ -0,0 +1,22 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="ch-testing-installer">
+  <title>Testing the Installer</title>
+  <para>
+    Building, burning, and booting from an installation CD is rather
+    tedious, so here is a quick way to see if the installer works
+    properly:
+  </para>
+  <programlisting>
+# mount -t tmpfs none /mnt
+# nixos-generate-config --root /mnt
+$ nix-build '&lt;nixpkgs/nixos&gt;' -A config.system.build.nixos-install
+# ./result/bin/nixos-install
+</programlisting>
+  <para>
+    To start a login shell in the new NixOS installation in
+    <literal>/mnt</literal>:
+  </para>
+  <programlisting>
+$ nix-build '&lt;nixpkgs/nixos&gt;' -A config.system.build.nixos-enter
+# ./result/bin/nixos-enter
+</programlisting>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml
new file mode 100644
index 000000000000..079c80060576
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml
@@ -0,0 +1,144 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-writing-documentation">
+  <title>Writing NixOS Documentation</title>
+  <para>
+    As NixOS grows, so too does the need for a catalogue and explanation
+    of its extensive functionality. Collecting pertinent information
+    from disparate sources and presenting it in an accessible style
+    would be a worthy contribution to the project.
+  </para>
+  <section xml:id="sec-writing-docs-building-the-manual">
+    <title>Building the Manual</title>
+    <para>
+      The DocBook sources of the <xref linkend="book-nixos-manual" />
+      are in the
+      <link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual"><literal>nixos/doc/manual</literal></link>
+      subdirectory of the Nixpkgs repository.
+    </para>
+    <para>
+      You can quickly validate your edits with <literal>make</literal>:
+    </para>
+    <programlisting>
+$ cd /path/to/nixpkgs/nixos/doc/manual
+$ nix-shell
+nix-shell$ make
+</programlisting>
+    <para>
+      Once you are done making modifications to the manual, it's
+      important to build it before committing. You can do that as
+      follows:
+    </para>
+    <programlisting>
+nix-build nixos/release.nix -A manual.x86_64-linux
+</programlisting>
+    <para>
+      When this command successfully finishes, it will tell you where
+      the manual got generated. The HTML will be accessible through the
+      <literal>result</literal> symlink at
+      <literal>./result/share/doc/nixos/index.html</literal>.
+    </para>
+  </section>
+  <section xml:id="sec-writing-docs-editing-docbook-xml">
+    <title>Editing DocBook XML</title>
+    <para>
+      For general information on how to write in DocBook, see
+      <link xlink:href="http://www.docbook.org/tdg5/en/html/docbook.html">DocBook
+      5: The Definitive Guide</link>.
+    </para>
+    <para>
+      Emacs nXML Mode is very helpful for editing DocBook XML because it
+      validates the document as you write, and precisely locates errors.
+      To use it, see <xref linkend="sec-emacs-docbook-xml" />.
+    </para>
+    <para>
+      <link xlink:href="http://pandoc.org">Pandoc</link> can generate
+      DocBook XML from a multitude of formats, which makes a good
+      starting point. Here is an example of Pandoc invocation to convert
+      GitHub-Flavoured MarkDown to DocBook 5 XML:
+    </para>
+    <programlisting>
+pandoc -f markdown_github -t docbook5 docs.md -o my-section.md
+</programlisting>
+    <para>
+      Pandoc can also quickly convert a single
+      <literal>section.xml</literal> to HTML, which is helpful when
+      drafting.
+    </para>
+    <para>
+      Sometimes writing valid DocBook is simply too difficult. In this
+      case, submit your documentation updates in a
+      <link xlink:href="https://github.com/NixOS/nixpkgs/issues/new">GitHub
+      Issue</link> and someone will handle the conversion to XML for
+      you.
+    </para>
+  </section>
+  <section xml:id="sec-writing-docs-creating-a-topic">
+    <title>Creating a Topic</title>
+    <para>
+      You can use an existing topic as a basis for the new topic or
+      create a topic from scratch.
+    </para>
+    <para>
+      Keep the following guidelines in mind when you create and add a
+      topic:
+    </para>
+    <itemizedlist>
+      <listitem>
+        <para>
+          The NixOS
+          <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><literal>book</literal></link>
+          element is in <literal>nixos/doc/manual/manual.xml</literal>.
+          It includes several
+          <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><literal>parts</literal></link>
+          which are in subdirectories.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          Store the topic file in the same directory as the
+          <literal>part</literal> to which it belongs. If your topic is
+          about configuring a NixOS module, then the XML file can be
+          stored alongside the module definition <literal>nix</literal>
+          file.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          If you include multiple words in the file name, separate the
+          words with a dash. For example:
+          <literal>ipv6-config.xml</literal>.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          Make sure that the <literal>xml:id</literal> value is unique.
+          You can use abbreviations if the ID is too long. For example:
+          <literal>nixos-config</literal>.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          Determine whether your topic is a chapter or a section. If you
+          are unsure, open an existing topic file and check whether the
+          main element is chapter or section.
+        </para>
+      </listitem>
+    </itemizedlist>
+  </section>
+  <section xml:id="sec-writing-docs-adding-a-topic">
+    <title>Adding a Topic to the Book</title>
+    <para>
+      Open the parent XML file and add an <literal>xi:include</literal>
+      element to the list of chapters with the file name of the topic
+      that you created. If you created a <literal>section</literal>, you
+      add the file to the <literal>chapter</literal> file. If you
+      created a <literal>chapter</literal>, you add the file to the
+      <literal>part</literal> file.
+    </para>
+    <para>
+      If the topic is about configuring a NixOS module, it can be
+      automatically included in the manual by using the
+      <literal>meta.doc</literal> attribute. See
+      <xref linkend="sec-meta-attributes" /> for an explanation.
+    </para>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/development/writing-modules.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/development/writing-modules.chapter.xml
new file mode 100644
index 000000000000..e33c24f4f12c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/development/writing-modules.chapter.xml
@@ -0,0 +1,196 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-writing-modules">
+  <title>Writing NixOS Modules</title>
+  <para>
+    NixOS has a modular system for declarative configuration. This
+    system combines multiple <emphasis>modules</emphasis> to produce the
+    full system configuration. One of the modules that constitute the
+    configuration is <literal>/etc/nixos/configuration.nix</literal>.
+    Most of the others live in the
+    <link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/modules"><literal>nixos/modules</literal></link>
+    subdirectory of the Nixpkgs tree.
+  </para>
+  <para>
+    Each NixOS module is a file that handles one logical aspect of the
+    configuration, such as a specific kind of hardware, a service, or
+    network settings. A module configuration does not have to handle
+    everything from scratch; it can use the functionality provided by
+    other modules for its implementation. Thus a module can
+    <emphasis>declare</emphasis> options that can be used by other
+    modules, and conversely can <emphasis>define</emphasis> options
+    provided by other modules in its own implementation. For example,
+    the module
+    <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/security/pam.nix"><literal>pam.nix</literal></link>
+    declares the option <literal>security.pam.services</literal> that
+    allows other modules (e.g.
+    <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/ssh/sshd.nix"><literal>sshd.nix</literal></link>)
+    to define PAM services; and it defines the option
+    <literal>environment.etc</literal> (declared by
+    <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/etc/etc.nix"><literal>etc.nix</literal></link>)
+    to cause files to be created in <literal>/etc/pam.d</literal>.
+  </para>
+  <para>
+    In <xref linkend="sec-configuration-syntax" />, we saw the following
+    structure of NixOS modules:
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{ option definitions
+}
+</programlisting>
+  <para>
+    This is actually an <emphasis>abbreviated</emphasis> form of module
+    that only defines options, but does not declare any. The structure
+    of full NixOS modules is shown in
+    <link linkend="ex-module-syntax">Example: Structure of NixOS
+    Modules</link>.
+  </para>
+  <anchor xml:id="ex-module-syntax" />
+  <para>
+    <emphasis role="strong">Example: Structure of NixOS
+    Modules</emphasis>
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ... }:
+
+{
+  imports =
+    [ paths of other modules
+    ];
+
+  options = {
+    option declarations
+  };
+
+  config = {
+    option definitions
+  };
+}
+</programlisting>
+  <para>
+    The meaning of each part is as follows.
+  </para>
+  <itemizedlist>
+    <listitem>
+      <para>
+        The first line makes the current Nix expression a function. The
+        variable <literal>pkgs</literal> contains Nixpkgs (by default,
+        it takes the <literal>nixpkgs</literal> entry of
+        <literal>NIX_PATH</literal>, see the
+        <link xlink:href="https://nixos.org/manual/nix/stable/#sec-common-env">Nix
+        manual</link> for further details), while
+        <literal>config</literal> contains the full system
+        configuration. This line can be omitted if there is no reference
+        to <literal>pkgs</literal> and <literal>config</literal> inside
+        the module.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        This <literal>imports</literal> list enumerates the paths to
+        other NixOS modules that should be included in the evaluation of
+        the system configuration. A default set of modules is defined in
+        the file <literal>modules/module-list.nix</literal>. These don't
+        need to be added in the import list.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        The attribute <literal>options</literal> is a nested set of
+        <emphasis>option declarations</emphasis> (described below).
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        The attribute <literal>config</literal> is a nested set of
+        <emphasis>option definitions</emphasis> (also described below).
+      </para>
+    </listitem>
+  </itemizedlist>
+  <para>
+    <link linkend="locate-example">Example: NixOS Module for the
+    <quote>locate</quote> Service</link> shows a module that handles the
+    regular update of the <quote>locate</quote> database, an index of
+    all files in the file system. This module declares two options that
+    can be defined by other modules (typically the user’s
+    <literal>configuration.nix</literal>):
+    <literal>services.locate.enable</literal> (whether the database
+    should be updated) and <literal>services.locate.interval</literal>
+    (when the update should be done). It implements its functionality by
+    defining two options declared by other modules:
+    <literal>systemd.services</literal> (the set of all systemd
+    services) and <literal>systemd.timers</literal> (the list of
+    commands to be executed periodically by <literal>systemd</literal>).
+  </para>
+  <anchor xml:id="locate-example" />
+  <para>
+    <emphasis role="strong">Example: NixOS Module for the
+    <quote>locate</quote> Service</emphasis>
+  </para>
+  <programlisting language="bash">
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.locate;
+in {
+  options.services.locate = {
+    enable = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        If enabled, NixOS will periodically update the database of
+        files used by the locate command.
+      '';
+    };
+
+    interval = mkOption {
+      type = types.str;
+      default = &quot;02:15&quot;;
+      example = &quot;hourly&quot;;
+      description = ''
+        Update the locate database at this interval. Updates by
+        default at 2:15 AM every day.
+
+        The format is described in
+        systemd.time(7).
+      '';
+    };
+
+    # Other options omitted for documentation
+  };
+
+  config = {
+    systemd.services.update-locatedb =
+      { description = &quot;Update Locate Database&quot;;
+        path  = [ pkgs.su ];
+        script =
+          ''
+            mkdir -m 0755 -p $(dirname ${toString cfg.output})
+            exec updatedb \
+              --localuser=${cfg.localuser} \
+              ${optionalString (!cfg.includeStore) &quot;--prunepaths='/nix/store'&quot;} \
+              --output=${toString cfg.output} ${concatStringsSep &quot; &quot; cfg.extraFlags}
+          '';
+      };
+
+    systemd.timers.update-locatedb = mkIf cfg.enable
+      { description = &quot;Update timer for locate database&quot;;
+        partOf      = [ &quot;update-locatedb.service&quot; ];
+        wantedBy    = [ &quot;timers.target&quot; ];
+        timerConfig.OnCalendar = cfg.interval;
+      };
+  };
+}
+</programlisting>
+  <xi:include href="option-declarations.section.xml" />
+  <xi:include href="option-types.section.xml" />
+  <xi:include href="option-def.section.xml" />
+  <xi:include href="assertions.section.xml" />
+  <xi:include href="meta-attributes.section.xml" />
+  <xi:include href="importing-modules.section.xml" />
+  <xi:include href="replace-modules.section.xml" />
+  <xi:include href="freeform-modules.section.xml" />
+  <xi:include href="settings-options.section.xml" />
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/changing-config.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/installation/changing-config.chapter.xml
new file mode 100644
index 000000000000..86f0b15b41c5
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/changing-config.chapter.xml
@@ -0,0 +1,117 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-changing-config">
+  <title>Changing the Configuration</title>
+  <para>
+    The file <literal>/etc/nixos/configuration.nix</literal> contains
+    the current configuration of your machine. Whenever you’ve
+    <link linkend="ch-configuration">changed something</link> in that
+    file, you should do
+  </para>
+  <programlisting>
+# nixos-rebuild switch
+</programlisting>
+  <para>
+    to build the new configuration, make it the default configuration
+    for booting, and try to realise the configuration in the running
+    system (e.g., by restarting system services).
+  </para>
+  <warning>
+    <para>
+      This command doesn't start/stop
+      <link linkend="opt-systemd.user.services">user services</link>
+      automatically. <literal>nixos-rebuild</literal> only runs a
+      <literal>daemon-reload</literal> for each user with running user
+      services.
+    </para>
+  </warning>
+  <warning>
+    <para>
+      These commands must be executed as root, so you should either run
+      them from a root shell or by prefixing them with
+      <literal>sudo -i</literal>.
+    </para>
+  </warning>
+  <para>
+    You can also do
+  </para>
+  <programlisting>
+# nixos-rebuild test
+</programlisting>
+  <para>
+    to build the configuration and switch the running system to it, but
+    without making it the boot default. So if (say) the configuration
+    locks up your machine, you can just reboot to get back to a working
+    configuration.
+  </para>
+  <para>
+    There is also
+  </para>
+  <programlisting>
+# nixos-rebuild boot
+</programlisting>
+  <para>
+    to build the configuration and make it the boot default, but not
+    switch to it now (so it will only take effect after the next
+    reboot).
+  </para>
+  <para>
+    You can make your configuration show up in a different submenu of
+    the GRUB 2 boot screen by giving it a different <emphasis>profile
+    name</emphasis>, e.g.
+  </para>
+  <programlisting>
+# nixos-rebuild switch -p test
+</programlisting>
+  <para>
+    which causes the new configuration (and previous ones created using
+    <literal>-p test</literal>) to show up in the GRUB submenu
+    <quote>NixOS - Profile 'test'</quote>. This can be useful to
+    separate test configurations from <quote>stable</quote>
+    configurations.
+  </para>
+  <para>
+    Finally, you can do
+  </para>
+  <programlisting>
+$ nixos-rebuild build
+</programlisting>
+  <para>
+    to build the configuration but nothing more. This is useful to see
+    whether everything compiles cleanly.
+  </para>
+  <para>
+    If you have a machine that supports hardware virtualisation, you can
+    also test the new configuration in a sandbox by building and running
+    a QEMU <emphasis>virtual machine</emphasis> that contains the
+    desired configuration. Just do
+  </para>
+  <programlisting>
+$ nixos-rebuild build-vm
+$ ./result/bin/run-*-vm
+</programlisting>
+  <para>
+    The VM does not have any data from your host system, so your
+    existing user accounts and home directories will not be available
+    unless you have set <literal>mutableUsers = false</literal>. Another
+    way is to temporarily add the following to your configuration:
+  </para>
+  <programlisting language="bash">
+users.users.your-user.initialHashedPassword = &quot;test&quot;;
+</programlisting>
+  <para>
+    <emphasis>Important:</emphasis> delete the $hostname.qcow2 file if
+    you have started the virtual machine at least once without the right
+    users, otherwise the changes will not get picked up. You can forward
+    ports on the host to the guest. For instance, the following will
+    forward host port 2222 to guest port 22 (SSH):
+  </para>
+  <programlisting>
+$ QEMU_NET_OPTS=&quot;hostfwd=tcp::2222-:22&quot; ./result/bin/run-*-vm
+</programlisting>
+  <para>
+    allowing you to log in via SSH (assuming you have set the
+    appropriate passwords or SSH authorized keys):
+  </para>
+  <programlisting>
+$ ssh -p 2222 localhost
+</programlisting>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/installing-behind-a-proxy.section.xml b/nixpkgs/nixos/doc/manual/from_md/installation/installing-behind-a-proxy.section.xml
new file mode 100644
index 000000000000..a551807cd47c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/installing-behind-a-proxy.section.xml
@@ -0,0 +1,41 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-installing-behind-proxy">
+  <title>Installing behind a proxy</title>
+  <para>
+    To install NixOS behind a proxy, do the following before running
+    <literal>nixos-install</literal>.
+  </para>
+  <orderedlist numeration="arabic">
+    <listitem>
+      <para>
+        Update proxy configuration in
+        <literal>/mnt/etc/nixos/configuration.nix</literal> to keep the
+        internet accessible after reboot.
+      </para>
+      <programlisting language="bash">
+networking.proxy.default = &quot;http://user:password@proxy:port/&quot;;
+networking.proxy.noProxy = &quot;127.0.0.1,localhost,internal.domain&quot;;
+</programlisting>
+    </listitem>
+    <listitem>
+      <para>
+        Setup the proxy environment variables in the shell where you are
+        running <literal>nixos-install</literal>.
+      </para>
+      <programlisting>
+# proxy_url=&quot;http://user:password@proxy:port/&quot;
+# export http_proxy=&quot;$proxy_url&quot;
+# export HTTP_PROXY=&quot;$proxy_url&quot;
+# export https_proxy=&quot;$proxy_url&quot;
+# export HTTPS_PROXY=&quot;$proxy_url&quot;
+</programlisting>
+    </listitem>
+  </orderedlist>
+  <note>
+    <para>
+      If you are switching networks with different proxy configurations,
+      use the <literal>specialisation</literal> option in
+      <literal>configuration.nix</literal> to switch proxies at runtime.
+      Refer to <xref linkend="ch-options" /> for more information.
+    </para>
+  </note>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/installing-from-other-distro.section.xml b/nixpkgs/nixos/doc/manual/from_md/installation/installing-from-other-distro.section.xml
new file mode 100644
index 000000000000..525531a47813
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/installing-from-other-distro.section.xml
@@ -0,0 +1,388 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-installing-from-other-distro">
+  <title>Installing from another Linux distribution</title>
+  <para>
+    Because Nix (the package manager) &amp; Nixpkgs (the Nix packages
+    collection) can both be installed on any (most?) Linux
+    distributions, they can be used to install NixOS in various creative
+    ways. You can, for instance:
+  </para>
+  <orderedlist numeration="arabic">
+    <listitem>
+      <para>
+        Install NixOS on another partition, from your existing Linux
+        distribution (without the use of a USB or optical device!)
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Install NixOS on the same partition (in place!), from your
+        existing non-NixOS Linux distribution using
+        <literal>NIXOS_LUSTRATE</literal>.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Install NixOS on your hard drive from the Live CD of any Linux
+        distribution.
+      </para>
+    </listitem>
+  </orderedlist>
+  <para>
+    The first steps to all these are the same:
+  </para>
+  <orderedlist numeration="arabic">
+    <listitem>
+      <para>
+        Install the Nix package manager:
+      </para>
+      <para>
+        Short version:
+      </para>
+      <programlisting>
+$ curl -L https://nixos.org/nix/install | sh
+$ . $HOME/.nix-profile/etc/profile.d/nix.sh # …or open a fresh shell
+</programlisting>
+      <para>
+        More details in the
+        <link xlink:href="https://nixos.org/nix/manual/#chap-quick-start">
+        Nix manual</link>
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Switch to the NixOS channel:
+      </para>
+      <para>
+        If you've just installed Nix on a non-NixOS distribution, you
+        will be on the <literal>nixpkgs</literal> channel by default.
+      </para>
+      <programlisting>
+$ nix-channel --list
+nixpkgs https://nixos.org/channels/nixpkgs-unstable
+</programlisting>
+      <para>
+        As that channel gets released without running the NixOS tests,
+        it will be safer to use the <literal>nixos-*</literal> channels
+        instead:
+      </para>
+      <programlisting>
+$ nix-channel --add https://nixos.org/channels/nixos-version nixpkgs
+</programlisting>
+      <para>
+        You may want to throw in a
+        <literal>nix-channel --update</literal> for good measure.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Install the NixOS installation tools:
+      </para>
+      <para>
+        You'll need <literal>nixos-generate-config</literal> and
+        <literal>nixos-install</literal>, but this also makes some man
+        pages and <literal>nixos-enter</literal> available, just in case
+        you want to chroot into your NixOS partition. NixOS installs
+        these by default, but you don't have NixOS yet..
+      </para>
+      <programlisting>
+$ nix-env -f '&lt;nixpkgs&gt;' -iA nixos-install-tools
+</programlisting>
+    </listitem>
+    <listitem>
+      <note>
+        <para>
+          The following 5 steps are only for installing NixOS to another
+          partition. For installing NixOS in place using
+          <literal>NIXOS_LUSTRATE</literal>, skip ahead.
+        </para>
+      </note>
+      <para>
+        Prepare your target partition:
+      </para>
+      <para>
+        At this point it is time to prepare your target partition.
+        Please refer to the partitioning, file-system creation, and
+        mounting steps of <xref linkend="sec-installation" />
+      </para>
+      <para>
+        If you're about to install NixOS in place using
+        <literal>NIXOS_LUSTRATE</literal> there is nothing to do for
+        this step.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Generate your NixOS configuration:
+      </para>
+      <programlisting>
+$ sudo `which nixos-generate-config` --root /mnt
+</programlisting>
+      <para>
+        You'll probably want to edit the configuration files. Refer to
+        the <literal>nixos-generate-config</literal> step in
+        <xref linkend="sec-installation" /> for more information.
+      </para>
+      <para>
+        Consider setting up the NixOS bootloader to give you the ability
+        to boot on your existing Linux partition. For instance, if
+        you're using GRUB and your existing distribution is running
+        Ubuntu, you may want to add something like this to your
+        <literal>configuration.nix</literal>:
+      </para>
+      <programlisting language="bash">
+boot.loader.grub.extraEntries = ''
+  menuentry &quot;Ubuntu&quot; {
+    search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e
+    configfile &quot;($ubuntu)/boot/grub/grub.cfg&quot;
+  }
+'';
+</programlisting>
+      <para>
+        (You can find the appropriate UUID for your partition in
+        <literal>/dev/disk/by-uuid</literal>)
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Create the <literal>nixbld</literal> group and user on your
+        original distribution:
+      </para>
+      <programlisting>
+$ sudo groupadd -g 30000 nixbld
+$ sudo useradd -u 30000 -g nixbld -G nixbld nixbld
+</programlisting>
+    </listitem>
+    <listitem>
+      <para>
+        Download/build/install NixOS:
+      </para>
+      <warning>
+        <para>
+          Once you complete this step, you might no longer be able to
+          boot on existing systems without the help of a rescue USB
+          drive or similar.
+        </para>
+      </warning>
+      <note>
+        <para>
+          On some distributions there are separate PATHS for programs
+          intended only for root. In order for the installation to
+          succeed, you might have to use
+          <literal>PATH=&quot;$PATH:/usr/sbin:/sbin&quot;</literal> in
+          the following command.
+        </para>
+      </note>
+      <programlisting>
+$ sudo PATH=&quot;$PATH&quot; NIX_PATH=&quot;$NIX_PATH&quot; `which nixos-install` --root /mnt
+</programlisting>
+      <para>
+        Again, please refer to the <literal>nixos-install</literal> step
+        in <xref linkend="sec-installation" /> for more information.
+      </para>
+      <para>
+        That should be it for installation to another partition!
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Optionally, you may want to clean up your non-NixOS
+        distribution:
+      </para>
+      <programlisting>
+$ sudo userdel nixbld
+$ sudo groupdel nixbld
+</programlisting>
+      <para>
+        If you do not wish to keep the Nix package manager installed
+        either, run something like
+        <literal>sudo rm -rv ~/.nix-* /nix</literal> and remove the line
+        that the Nix installer added to your
+        <literal>~/.profile</literal>.
+      </para>
+    </listitem>
+    <listitem>
+      <note>
+        <para>
+          The following steps are only for installing NixOS in place
+          using <literal>NIXOS_LUSTRATE</literal>:
+        </para>
+      </note>
+      <para>
+        Generate your NixOS configuration:
+      </para>
+      <programlisting>
+$ sudo `which nixos-generate-config` --root /
+</programlisting>
+      <para>
+        Note that this will place the generated configuration files in
+        <literal>/etc/nixos</literal>. You'll probably want to edit the
+        configuration files. Refer to the
+        <literal>nixos-generate-config</literal> step in
+        <xref linkend="sec-installation" /> for more information.
+      </para>
+      <para>
+        You'll likely want to set a root password for your first boot
+        using the configuration files because you won't have a chance to
+        enter a password until after you reboot. You can initalize the
+        root password to an empty one with this line: (and of course
+        don't forget to set one once you've rebooted or to lock the
+        account with <literal>sudo passwd -l root</literal> if you use
+        <literal>sudo</literal>)
+      </para>
+      <programlisting language="bash">
+users.users.root.initialHashedPassword = &quot;&quot;;
+</programlisting>
+    </listitem>
+    <listitem>
+      <para>
+        Build the NixOS closure and install it in the
+        <literal>system</literal> profile:
+      </para>
+      <programlisting>
+$ nix-env -p /nix/var/nix/profiles/system -f '&lt;nixpkgs/nixos&gt;' -I nixos-config=/etc/nixos/configuration.nix -iA system
+</programlisting>
+    </listitem>
+    <listitem>
+      <para>
+        Change ownership of the <literal>/nix</literal> tree to root
+        (since your Nix install was probably single user):
+      </para>
+      <programlisting>
+$ sudo chown -R 0.0 /nix
+</programlisting>
+    </listitem>
+    <listitem>
+      <para>
+        Set up the <literal>/etc/NIXOS</literal> and
+        <literal>/etc/NIXOS_LUSTRATE</literal> files:
+      </para>
+      <para>
+        <literal>/etc/NIXOS</literal> officializes that this is now a
+        NixOS partition (the bootup scripts require its presence).
+      </para>
+      <para>
+        <literal>/etc/NIXOS_LUSTRATE</literal> tells the NixOS bootup
+        scripts to move <emphasis>everything</emphasis> that's in the
+        root partition to <literal>/old-root</literal>. This will move
+        your existing distribution out of the way in the very early
+        stages of the NixOS bootup. There are exceptions (we do need to
+        keep NixOS there after all), so the NixOS lustrate process will
+        not touch:
+      </para>
+      <itemizedlist>
+        <listitem>
+          <para>
+            The <literal>/nix</literal> directory
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            The <literal>/boot</literal> directory
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            Any file or directory listed in
+            <literal>/etc/NIXOS_LUSTRATE</literal> (one per line)
+          </para>
+        </listitem>
+      </itemizedlist>
+      <note>
+        <para>
+          Support for <literal>NIXOS_LUSTRATE</literal> was added in
+          NixOS 16.09. The act of &quot;lustrating&quot; refers to the
+          wiping of the existing distribution. Creating
+          <literal>/etc/NIXOS_LUSTRATE</literal> can also be used on
+          NixOS to remove all mutable files from your root partition
+          (anything that's not in <literal>/nix</literal> or
+          <literal>/boot</literal> gets &quot;lustrated&quot; on the
+          next boot.
+        </para>
+        <para>
+          lustrate /ˈlʌstreɪt/ verb.
+        </para>
+        <para>
+          purify by expiatory sacrifice, ceremonial washing, or some
+          other ritual action.
+        </para>
+      </note>
+      <para>
+        Let's create the files:
+      </para>
+      <programlisting>
+$ sudo touch /etc/NIXOS
+$ sudo touch /etc/NIXOS_LUSTRATE
+</programlisting>
+      <para>
+        Let's also make sure the NixOS configuration files are kept once
+        we reboot on NixOS:
+      </para>
+      <programlisting>
+$ echo etc/nixos | sudo tee -a /etc/NIXOS_LUSTRATE
+</programlisting>
+    </listitem>
+    <listitem>
+      <para>
+        Finally, move the <literal>/boot</literal> directory of your
+        current distribution out of the way (the lustrate process will
+        take care of the rest once you reboot, but this one must be
+        moved out now because NixOS needs to install its own boot files:
+      </para>
+      <warning>
+        <para>
+          Once you complete this step, your current distribution will no
+          longer be bootable! If you didn't get all the NixOS
+          configuration right, especially those settings pertaining to
+          boot loading and root partition, NixOS may not be bootable
+          either. Have a USB rescue device ready in case this happens.
+        </para>
+      </warning>
+      <programlisting>
+$ sudo mv -v /boot /boot.bak &amp;&amp;
+sudo /nix/var/nix/profiles/system/bin/switch-to-configuration boot
+</programlisting>
+      <para>
+        Cross your fingers, reboot, hopefully you should get a NixOS
+        prompt!
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        If for some reason you want to revert to the old distribution,
+        you'll need to boot on a USB rescue disk and do something along
+        these lines:
+      </para>
+      <programlisting>
+# mkdir root
+# mount /dev/sdaX root
+# mkdir root/nixos-root
+# mv -v root/* root/nixos-root/
+# mv -v root/nixos-root/old-root/* root/
+# mv -v root/boot.bak root/boot  # We had renamed this by hand earlier
+# umount root
+# reboot
+</programlisting>
+      <para>
+        This may work as is or you might also need to reinstall the boot
+        loader.
+      </para>
+      <para>
+        And of course, if you're happy with NixOS and no longer need the
+        old distribution:
+      </para>
+      <programlisting>
+sudo rm -rf /old-root
+</programlisting>
+    </listitem>
+    <listitem>
+      <para>
+        It's also worth noting that this whole process can be automated.
+        This is especially useful for Cloud VMs, where provider do not
+        provide NixOS. For instance,
+        <link xlink:href="https://github.com/elitak/nixos-infect">nixos-infect</link>
+        uses the lustrate process to convert Digital Ocean droplets to
+        NixOS from other distributions automatically.
+      </para>
+    </listitem>
+  </orderedlist>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/installing-pxe.section.xml b/nixpkgs/nixos/doc/manual/from_md/installation/installing-pxe.section.xml
new file mode 100644
index 000000000000..1dd15ddacba8
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/installing-pxe.section.xml
@@ -0,0 +1,42 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-booting-from-pxe">
+  <title>Booting from the <quote>netboot</quote> media (PXE)</title>
+  <para>
+    Advanced users may wish to install NixOS using an existing PXE or
+    iPXE setup.
+  </para>
+  <para>
+    These instructions assume that you have an existing PXE or iPXE
+    infrastructure and simply want to add the NixOS installer as another
+    option. To build the necessary files from a recent version of
+    nixpkgs, you can run:
+  </para>
+  <programlisting>
+nix-build -A netboot.x86_64-linux nixos/release.nix
+</programlisting>
+  <para>
+    This will create a <literal>result</literal> directory containing: *
+    <literal>bzImage</literal> – the Linux kernel *
+    <literal>initrd</literal> – the initrd file *
+    <literal>netboot.ipxe</literal> – an example ipxe script
+    demonstrating the appropriate kernel command line arguments for this
+    image
+  </para>
+  <para>
+    If you’re using plain PXE, configure your boot loader to use the
+    <literal>bzImage</literal> and <literal>initrd</literal> files and
+    have it provide the same kernel command line arguments found in
+    <literal>netboot.ipxe</literal>.
+  </para>
+  <para>
+    If you’re using iPXE, depending on how your HTTP/FTP/etc. server is
+    configured you may be able to use <literal>netboot.ipxe</literal>
+    unmodified, or you may need to update the paths to the files to
+    match your server’s directory layout.
+  </para>
+  <para>
+    In the future we may begin making these files available as build
+    products from hydra at which point we will update this documentation
+    with instructions on how to obtain them either for placing on a
+    dedicated TFTP server or to boot them directly over the internet.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/installing-usb.section.xml b/nixpkgs/nixos/doc/manual/from_md/installation/installing-usb.section.xml
new file mode 100644
index 000000000000..b46a1d565557
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/installing-usb.section.xml
@@ -0,0 +1,35 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-booting-from-usb">
+  <title>Booting from a USB Drive</title>
+  <para>
+    For systems without CD drive, the NixOS live CD can be booted from a
+    USB stick. You can use the <literal>dd</literal> utility to write
+    the image: <literal>dd if=path-to-image of=/dev/sdX</literal>. Be
+    careful about specifying the correct drive; you can use the
+    <literal>lsblk</literal> command to get a list of block devices.
+  </para>
+  <note>
+    <title>On macOS</title>
+    <programlisting>
+$ diskutil list
+[..]
+/dev/diskN (external, physical):
+   #:                       TYPE NAME                    SIZE       IDENTIFIER
+[..]
+$ diskutil unmountDisk diskN
+Unmount of all volumes on diskN was successful
+$ sudo dd if=nix.iso of=/dev/rdiskN
+</programlisting>
+    <para>
+      Using the 'raw' <literal>rdiskN</literal> device instead of
+      <literal>diskN</literal> completes in minutes instead of hours.
+      After <literal>dd</literal> completes, a GUI dialog &quot;The disk
+      you inserted was not readable by this computer&quot; will pop up,
+      which can be ignored.
+    </para>
+  </note>
+  <para>
+    The <literal>dd</literal> utility will write the image verbatim to
+    the drive, making it the recommended option for both UEFI and
+    non-UEFI installations.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/installing-virtualbox-guest.section.xml b/nixpkgs/nixos/doc/manual/from_md/installation/installing-virtualbox-guest.section.xml
new file mode 100644
index 000000000000..c8bb286c8f33
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/installing-virtualbox-guest.section.xml
@@ -0,0 +1,92 @@
+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-instaling-virtualbox-guest">
+  <title>Installing in a VirtualBox guest</title>
+  <para>
+    Installing NixOS into a VirtualBox guest is convenient for users who
+    want to try NixOS without installing it on bare metal. If you want
+    to use a pre-made VirtualBox appliance, it is available at
+    <link xlink:href="https://nixos.org/nixos/download.html">the
+    downloads page</link>. If you want to set up a VirtualBox guest
+    manually, follow these instructions:
+  </para>
+  <orderedlist numeration="arabic">
+    <listitem>
+      <para>
+        Add a New Machine in VirtualBox with OS Type &quot;Linux / Other
+        Linux&quot;
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Base Memory Size: 768 MB or higher.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        New Hard Disk of 8 GB or higher.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Mount the CD-ROM with the NixOS ISO (by clicking on CD/DVD-ROM)
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Click on Settings / System / Processor and enable PAE/NX
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Click on Settings / System / Acceleration and enable
+        &quot;VT-x/AMD-V&quot; acceleration
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Click on Settings / Display / Screen and select VMSVGA as
+        Graphics Controller
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Save the settings, start the virtual machine, and continue
+        installation like normal
+      </para>
+    </listitem>
+  </orderedlist>
+  <para>
+    There are a few modifications you should make in configuration.nix.
+    Enable booting:
+  </para>
+  <programlisting language="bash">
+boot.loader.grub.device = &quot;/dev/sda&quot;;
+</programlisting>
+  <para>
+    Also remove the fsck that runs at startup. It will always fail to
+    run, stopping your boot until you press <literal>*</literal>.
+  </para>
+  <programlisting language="bash">
+boot.initrd.checkJournalingFS = false;
+</programlisting>
+  <para>
+    Shared folders can be given a name and a path in the host system in
+    the VirtualBox settings (Machine / Settings / Shared Folders, then
+    click on the &quot;Add&quot; icon). Add the following to the
+    <literal>/etc/nixos/configuration.nix</literal> to auto-mount them.
+    If you do not add <literal>&quot;nofail&quot;</literal>, the system
+    will not boot properly.
+  </para>
+  <programlisting language="bash">
+{ config, pkgs, ...} :
+{
+  fileSystems.&quot;/virtualboxshare&quot; = {
+    fsType = &quot;vboxsf&quot;;
+    device = &quot;nameofthesharedfolder&quot;;
+    options = [ &quot;rw&quot; &quot;nofail&quot; ];
+  };
+}
+</programlisting>
+  <para>
+    The folder will be available directly under the root directory.
+  </para>
+</section>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/installing.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/installation/installing.chapter.xml
new file mode 100644
index 000000000000..91ab71682977
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/installing.chapter.xml
@@ -0,0 +1,642 @@
+<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-installation">
+  <title>Installing NixOS</title>
+  <section xml:id="sec-installation-booting">
+    <title>Booting the system</title>
+    <para>
+      NixOS can be installed on BIOS or UEFI systems. The procedure for
+      a UEFI installation is by and large the same as a BIOS
+      installation. The differences are mentioned in the steps that
+      follow.
+    </para>
+    <para>
+      The installation media can be burned to a CD, or now more
+      commonly, <quote>burned</quote> to a USB drive (see
+      <xref linkend="sec-booting-from-usb" />).
+    </para>
+    <para>
+      The installation media contains a basic NixOS installation. When
+      it’s finished booting, it should have detected most of your
+      hardware.
+    </para>
+    <para>
+      The NixOS manual is available by running
+      <literal>nixos-help</literal>.
+    </para>
+    <para>
+      You are logged-in automatically as <literal>nixos</literal>. The
+      <literal>nixos</literal> user account has an empty password so you
+      can use <literal>sudo</literal> without a password.
+    </para>
+    <para>
+      If you downloaded the graphical ISO image, you can run
+      <literal>systemctl start display-manager</literal> to start the
+      desktop environment. If you want to continue on the terminal, you
+      can use <literal>loadkeys</literal> to switch to your preferred
+      keyboard layout. (We even provide neo2 via
+      <literal>loadkeys de neo</literal>!)
+    </para>
+    <para>
+      If the text is too small to be legible, try
+      <literal>setfont ter-v32n</literal> to increase the font size.
+    </para>
+    <para>
+      To install over a serial port connect with
+      <literal>115200n8</literal> (e.g.
+      <literal>picocom -b 115200 /dev/ttyUSB0</literal>). When the
+      bootloader lists boot entries, select the serial console boot
+      entry.
+    </para>
+    <section xml:id="sec-installation-booting-networking">
+      <title>Networking in the installer</title>
+      <para>
+        The boot process should have brought up networking (check
+        <literal>ip a</literal>). Networking is necessary for the
+        installer, since it will download lots of stuff (such as source
+        tarballs or Nixpkgs channel binaries). It’s best if you have a
+        DHCP server on your network. Otherwise configure networking
+        manually using <literal>ifconfig</literal>.
+      </para>
+      <para>
+        On the graphical installer, you can configure the network, wifi
+        included, through NetworkManager. Using the
+        <literal>nmtui</literal> program, you can do so even in a
+        non-graphical session. If you prefer to configure the network
+        manually, disable NetworkManager with
+        <literal>systemctl stop NetworkManager</literal>.
+      </para>
+      <para>
+        On the minimal installer, NetworkManager is not available, so
+        configuration must be perfomed manually. To configure the wifi,
+        first start wpa_supplicant with
+        <literal>sudo systemctl start wpa_supplicant</literal>, then run
+        <literal>wpa_cli</literal>. For most home networks, you need to
+        type in the following commands:
+      </para>
+      <programlisting>
+&gt; add_network
+0
+&gt; set_network 0 ssid &quot;myhomenetwork&quot;
+OK
+&gt; set_network 0 psk &quot;mypassword&quot;
+OK
+&gt; set_network 0 key_mgmt WPA-PSK
+OK
+&gt; enable_network 0
+OK
+</programlisting>
+      <para>
+        For enterprise networks, for example
+        <emphasis>eduroam</emphasis>, instead do:
+      </para>
+      <programlisting>
+&gt; add_network
+0
+&gt; set_network 0 ssid &quot;eduroam&quot;
+OK
+&gt; set_network 0 identity &quot;myname@example.com&quot;
+OK
+&gt; set_network 0 password &quot;mypassword&quot;
+OK
+&gt; set_network 0 key_mgmt WPA-EAP
+OK
+&gt; enable_network 0
+OK
+</programlisting>
+      <para>
+        When successfully connected, you should see a line such as this
+        one
+      </para>
+      <programlisting>
+&lt;3&gt;CTRL-EVENT-CONNECTED - Connection to 32:85:ab:ef:24:5c completed [id=0 id_str=]
+</programlisting>
+      <para>
+        you can now leave <literal>wpa_cli</literal> by typing
+        <literal>quit</literal>.
+      </para>
+      <para>
+        If you would like to continue the installation from a different
+        machine you can use activated SSH daemon. You need to copy your
+        ssh key to either
+        <literal>/home/nixos/.ssh/authorized_keys</literal> or
+        <literal>/root/.ssh/authorized_keys</literal> (Tip: For
+        installers with a modifiable filesystem such as the sd-card
+        installer image a key can be manually placed by mounting the
+        image on a different machine). Alternatively you must set a
+        password for either <literal>root</literal> or
+        <literal>nixos</literal> with <literal>passwd</literal> to be
+        able to login.
+      </para>
+    </section>
+  </section>
+  <section xml:id="sec-installation-partitioning">
+    <title>Partitioning and formatting</title>
+    <para>
+      The NixOS installer doesn’t do any partitioning or formatting, so
+      you need to do that yourself.
+    </para>
+    <para>
+      The NixOS installer ships with multiple partitioning tools. The
+      examples below use <literal>parted</literal>, but also provides
+      <literal>fdisk</literal>, <literal>gdisk</literal>,
+      <literal>cfdisk</literal>, and <literal>cgdisk</literal>.
+    </para>
+    <para>
+      The recommended partition scheme differs depending if the computer
+      uses <emphasis>Legacy Boot</emphasis> or
+      <emphasis>UEFI</emphasis>.
+    </para>
+    <section xml:id="sec-installation-partitioning-UEFI">
+      <title>UEFI (GPT)</title>
+      <para>
+        Here's an example partition scheme for UEFI, using
+        <literal>/dev/sda</literal> as the device.
+      </para>
+      <note>
+        <para>
+          You can safely ignore <literal>parted</literal>'s
+          informational message about needing to update /etc/fstab.
+        </para>
+      </note>
+      <orderedlist numeration="arabic">
+        <listitem>
+          <para>
+            Create a <emphasis>GPT</emphasis> partition table.
+          </para>
+          <programlisting>
+# parted /dev/sda -- mklabel gpt
+</programlisting>
+        </listitem>
+        <listitem>
+          <para>
+            Add the <emphasis>root</emphasis> partition. This will fill
+            the disk except for the end part, where the swap will live,
+            and the space left in front (512MiB) which will be used by
+            the boot partition.
+          </para>
+          <programlisting>
+# parted /dev/sda -- mkpart primary 512MiB -8GiB
+</programlisting>
+        </listitem>
+        <listitem>
+          <para>
+            Next, add a <emphasis>swap</emphasis> partition. The size
+            required will vary according to needs, here a 8GiB one is
+            created.
+          </para>
+          <programlisting>
+# parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+</programlisting>
+          <note>
+            <para>
+              The swap partition size rules are no different than for
+              other Linux distributions.
+            </para>
+          </note>
+        </listitem>
+        <listitem>
+          <para>
+            Finally, the <emphasis>boot</emphasis> partition. NixOS by
+            default uses the ESP (EFI system partition) as its
+            <emphasis>/boot</emphasis> partition. It uses the initially
+            reserved 512MiB at the start of the disk.
+          </para>
+          <programlisting>
+# parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
+# parted /dev/sda -- set 3 esp on
+</programlisting>
+        </listitem>
+      </orderedlist>
+      <para>
+        Once complete, you can follow with
+        <xref linkend="sec-installation-partitioning-formatting" />.
+      </para>
+    </section>
+    <section xml:id="sec-installation-partitioning-MBR">
+      <title>Legacy Boot (MBR)</title>
+      <para>
+        Here's an example partition scheme for Legacy Boot, using
+        <literal>/dev/sda</literal> as the device.
+      </para>
+      <note>
+        <para>
+          You can safely ignore <literal>parted</literal>'s
+          informational message about needing to update /etc/fstab.
+        </para>
+      </note>
+      <orderedlist numeration="arabic">
+        <listitem>
+          <para>
+            Create a <emphasis>MBR</emphasis> partition table.
+          </para>
+          <programlisting>
+# parted /dev/sda -- mklabel msdos
+</programlisting>
+        </listitem>
+        <listitem>
+          <para>
+            Add the <emphasis>root</emphasis> partition. This will fill
+            the the disk except for the end part, where the swap will
+            live.
+          </para>
+          <programlisting>
+# parted /dev/sda -- mkpart primary 1MiB -8GiB
+</programlisting>
+        </listitem>
+        <listitem>
+          <para>
+            Finally, add a <emphasis>swap</emphasis> partition. The size
+            required will vary according to needs, here a 8GiB one is
+            created.
+          </para>
+          <programlisting>
+# parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+</programlisting>
+          <note>
+            <para>
+              The swap partition size rules are no different than for
+              other Linux distributions.
+            </para>
+          </note>
+        </listitem>
+      </orderedlist>
+      <para>
+        Once complete, you can follow with
+        <xref linkend="sec-installation-partitioning-formatting" />.
+      </para>
+    </section>
+    <section xml:id="sec-installation-partitioning-formatting">
+      <title>Formatting</title>
+      <para>
+        Use the following commands:
+      </para>
+      <itemizedlist>
+        <listitem>
+          <para>
+            For initialising Ext4 partitions:
+            <literal>mkfs.ext4</literal>. It is recommended that you
+            assign a unique symbolic label to the file system using the
+            option <literal>-L label</literal>, since this makes the
+            file system configuration independent from device changes.
+            For example:
+          </para>
+          <programlisting>
+# mkfs.ext4 -L nixos /dev/sda1
+</programlisting>
+        </listitem>
+        <listitem>
+          <para>
+            For creating swap partitions: <literal>mkswap</literal>.
+            Again it’s recommended to assign a label to the swap
+            partition: <literal>-L label</literal>. For example:
+          </para>
+          <programlisting>
+# mkswap -L swap /dev/sda2
+</programlisting>
+        </listitem>
+        <listitem>
+          <para>
+            <emphasis role="strong">UEFI systems</emphasis>
+          </para>
+          <para>
+            For creating boot partitions: <literal>mkfs.fat</literal>.
+            Again it’s recommended to assign a label to the boot
+            partition: <literal>-n label</literal>. For example:
+          </para>
+          <programlisting>
+# mkfs.fat -F 32 -n boot /dev/sda3
+</programlisting>
+        </listitem>
+        <listitem>
+          <para>
+            For creating LVM volumes, the LVM commands, e.g.,
+            <literal>pvcreate</literal>, <literal>vgcreate</literal>,
+            and <literal>lvcreate</literal>.
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            For creating software RAID devices, use
+            <literal>mdadm</literal>.
+          </para>
+        </listitem>
+      </itemizedlist>
+    </section>
+  </section>
+  <section xml:id="sec-installation-installing">
+    <title>Installing</title>
+    <orderedlist numeration="arabic">
+      <listitem>
+        <para>
+          Mount the target file system on which NixOS should be
+          installed on <literal>/mnt</literal>, e.g.
+        </para>
+        <programlisting>
+# mount /dev/disk/by-label/nixos /mnt
+</programlisting>
+      </listitem>
+      <listitem>
+        <para>
+          <emphasis role="strong">UEFI systems</emphasis>
+        </para>
+        <para>
+          Mount the boot file system on <literal>/mnt/boot</literal>,
+          e.g.
+        </para>
+        <programlisting>
+# mkdir -p /mnt/boot
+# mount /dev/disk/by-label/boot /mnt/boot
+</programlisting>
+      </listitem>
+      <listitem>
+        <para>
+          If your machine has a limited amount of memory, you may want
+          to activate swap devices now
+          (<literal>swapon device</literal>). The installer (or rather,
+          the build actions that it may spawn) may need quite a bit of
+          RAM, depending on your configuration.
+        </para>
+        <programlisting>
+# swapon /dev/sda2
+</programlisting>
+      </listitem>
+      <listitem>
+        <para>
+          You now need to create a file
+          <literal>/mnt/etc/nixos/configuration.nix</literal> that
+          specifies the intended configuration of the system. This is
+          because NixOS has a <emphasis>declarative</emphasis>
+          configuration model: you create or edit a description of the
+          desired configuration of your system, and then NixOS takes
+          care of making it happen. The syntax of the NixOS
+          configuration file is described in
+          <xref linkend="sec-configuration-syntax" />, while a list of
+          available configuration options appears in
+          <xref linkend="ch-options" />. A minimal example is shown in
+          <link linkend="ex-config">Example: NixOS Configuration</link>.
+        </para>
+        <para>
+          The command <literal>nixos-generate-config</literal> can
+          generate an initial configuration file for you:
+        </para>
+        <programlisting>
+# nixos-generate-config --root /mnt
+</programlisting>
+        <para>
+          You should then edit
+          <literal>/mnt/etc/nixos/configuration.nix</literal> to suit
+          your needs:
+        </para>
+        <programlisting>
+# nano /mnt/etc/nixos/configuration.nix
+</programlisting>
+        <para>
+          If you’re using the graphical ISO image, other editors may be
+          available (such as <literal>vim</literal>). If you have
+          network access, you can also install other editors – for
+          instance, you can install Emacs by running
+          <literal>nix-env -f '&lt;nixpkgs&gt;' -iA emacs</literal>.
+        </para>
+        <variablelist>
+          <varlistentry>
+            <term>
+              BIOS systems
+            </term>
+            <listitem>
+              <para>
+                You <emphasis>must</emphasis> set the option
+                <xref linkend="opt-boot.loader.grub.device" /> to
+                specify on which disk the GRUB boot loader is to be
+                installed. Without it, NixOS cannot boot.
+              </para>
+            </listitem>
+          </varlistentry>
+          <varlistentry>
+            <term>
+              UEFI systems
+            </term>
+            <listitem>
+              <para>
+                You <emphasis>must</emphasis> set the option
+                <xref linkend="opt-boot.loader.systemd-boot.enable" />
+                to <literal>true</literal>.
+                <literal>nixos-generate-config</literal> should do this
+                automatically for new configurations when booted in UEFI
+                mode.
+              </para>
+              <para>
+                You may want to look at the options starting with
+                <link linkend="opt-boot.loader.efi.canTouchEfiVariables"><literal>boot.loader.efi</literal></link>
+                and
+                <link linkend="opt-boot.loader.systemd-boot.enable"><literal>boot.loader.systemd-boot</literal></link>
+                as well.
+              </para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+        <para>
+          If there are other operating systems running on the machine
+          before installing NixOS, the
+          <xref linkend="opt-boot.loader.grub.useOSProber" /> option can
+          be set to <literal>true</literal> to automatically add them to
+          the grub menu.
+        </para>
+        <para>
+          If you need to configure networking for your machine the
+          configuration options are described in
+          <xref linkend="sec-networking" />. In particular, while wifi
+          is supported on the installation image, it is not enabled by
+          default in the configuration generated by
+          <literal>nixos-generate-config</literal>.
+        </para>
+        <para>
+          Another critical option is <literal>fileSystems</literal>,
+          specifying the file systems that need to be mounted by NixOS.
+          However, you typically don’t need to set it yourself, because
+          <literal>nixos-generate-config</literal> sets it automatically
+          in
+          <literal>/mnt/etc/nixos/hardware-configuration.nix</literal>
+          from your currently mounted file systems. (The configuration
+          file <literal>hardware-configuration.nix</literal> is included
+          from <literal>configuration.nix</literal> and will be
+          overwritten by future invocations of
+          <literal>nixos-generate-config</literal>; thus, you generally
+          should not modify it.) Additionally, you may want to look at
+          <link xlink:href="https://github.com/NixOS/nixos-hardware">Hardware
+          configuration for known-hardware</link> at this point or after
+          installation.
+        </para>
+        <note>
+          <para>
+            Depending on your hardware configuration or type of file
+            system, you may need to set the option
+            <literal>boot.initrd.kernelModules</literal> to include the
+            kernel modules that are necessary for mounting the root file
+            system, otherwise the installed system will not be able to
+            boot. (If this happens, boot from the installation media
+            again, mount the target file system on
+            <literal>/mnt</literal>, fix
+            <literal>/mnt/etc/nixos/configuration.nix</literal> and
+            rerun <literal>nixos-install</literal>.) In most cases,
+            <literal>nixos-generate-config</literal> will figure out the
+            required modules.
+          </para>
+        </note>
+      </listitem>
+      <listitem>
+        <para>
+          Do the installation:
+        </para>
+        <programlisting>
+# nixos-install
+</programlisting>
+        <para>
+          This will install your system based on the configuration you
+          provided. If anything fails due to a configuration problem or
+          any other issue (such as a network outage while downloading
+          binaries from the NixOS binary cache), you can re-run
+          <literal>nixos-install</literal> after fixing your
+          <literal>configuration.nix</literal>.
+        </para>
+        <para>
+          As the last step, <literal>nixos-install</literal> will ask
+          you to set the password for the <literal>root</literal> user,
+          e.g.
+        </para>
+        <programlisting>
+setting root password...
+New password: ***
+Retype new password: ***
+</programlisting>
+        <note>
+          <para>
+            For unattended installations, it is possible to use
+            <literal>nixos-install --no-root-passwd</literal> in order
+            to disable the password prompt entirely.
+          </para>
+        </note>
+      </listitem>
+      <listitem>
+        <para>
+          If everything went well:
+        </para>
+        <programlisting>
+# reboot
+</programlisting>
+      </listitem>
+      <listitem>
+        <para>
+          You should now be able to boot into the installed NixOS. The
+          GRUB boot menu shows a list of <emphasis>available
+          configurations</emphasis> (initially just one). Every time you
+          change the NixOS configuration (see
+          <link linkend="sec-changing-config">Changing
+          Configuration</link>), a new item is added to the menu. This
+          allows you to easily roll back to a previous configuration if
+          something goes wrong.
+        </para>
+        <para>
+          You should log in and change the <literal>root</literal>
+          password with <literal>passwd</literal>.
+        </para>
+        <para>
+          You’ll probably want to create some user accounts as well,
+          which can be done with <literal>useradd</literal>:
+        </para>
+        <programlisting>
+$ useradd -c 'Eelco Dolstra' -m eelco
+$ passwd eelco
+</programlisting>
+        <para>
+          You may also want to install some software. This will be
+          covered in <xref linkend="sec-package-management" />.
+        </para>
+      </listitem>
+    </orderedlist>
+  </section>
+  <section xml:id="sec-installation-summary">
+    <title>Installation summary</title>
+    <para>
+      To summarise, <link linkend="ex-install-sequence">Example:
+      Commands for Installing NixOS on
+      <literal>/dev/sda</literal></link> shows a typical sequence of
+      commands for installing NixOS on an empty hard drive (here
+      <literal>/dev/sda</literal>). <link linkend="ex-config">Example:
+      NixOS Configuration</link> shows a corresponding configuration Nix
+      expression.
+    </para>
+    <anchor xml:id="ex-partition-scheme-MBR" />
+    <para>
+      <emphasis role="strong">Example: Example partition schemes for
+      NixOS on <literal>/dev/sda</literal> (MBR)</emphasis>
+    </para>
+    <programlisting>
+# parted /dev/sda -- mklabel msdos
+# parted /dev/sda -- mkpart primary 1MiB -8GiB
+# parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+</programlisting>
+    <anchor xml:id="ex-partition-scheme-UEFI" />
+    <para>
+      <emphasis role="strong">Example: Example partition schemes for
+      NixOS on <literal>/dev/sda</literal> (UEFI)</emphasis>
+    </para>
+    <programlisting>
+# parted /dev/sda -- mklabel gpt
+# parted /dev/sda -- mkpart primary 512MiB -8GiB
+# parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+# parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
+# parted /dev/sda -- set 3 esp on
+</programlisting>
+    <anchor xml:id="ex-install-sequence" />
+    <para>
+      <emphasis role="strong">Example: Commands for Installing NixOS on
+      <literal>/dev/sda</literal></emphasis>
+    </para>
+    <para>
+      With a partitioned disk.
+    </para>
+    <programlisting>
+# mkfs.ext4 -L nixos /dev/sda1
+# mkswap -L swap /dev/sda2
+# swapon /dev/sda2
+# mkfs.fat -F 32 -n boot /dev/sda3        # (for UEFI systems only)
+# mount /dev/disk/by-label/nixos /mnt
+# mkdir -p /mnt/boot                      # (for UEFI systems only)
+# mount /dev/disk/by-label/boot /mnt/boot # (for UEFI systems only)
+# nixos-generate-config --root /mnt
+# nano /mnt/etc/nixos/configuration.nix
+# nixos-install
+# reboot
+</programlisting>
+    <anchor xml:id="ex-config" />
+    <para>
+      <emphasis role="strong">Example: NixOS Configuration</emphasis>
+    </para>
+    <programlisting>
+{ config, pkgs, ... }: {
+  imports = [
+    # Include the results of the hardware scan.
+    ./hardware-configuration.nix
+  ];
+
+  boot.loader.grub.device = &quot;/dev/sda&quot;;   # (for BIOS systems only)
+  boot.loader.systemd-boot.enable = true; # (for UEFI systems only)
+
+  # Note: setting fileSystems is generally not
+  # necessary, since nixos-generate-config figures them out
+  # automatically in hardware-configuration.nix.
+  #fileSystems.&quot;/&quot;.device = &quot;/dev/disk/by-label/nixos&quot;;
+
+  # Enable the OpenSSH server.
+  services.sshd.enable = true;
+}
+</programlisting>
+  </section>
+  <section xml:id="sec-installation-additional-notes">
+    <title>Additional installation notes</title>
+    <xi:include href="installing-usb.section.xml" />
+    <xi:include href="installing-pxe.section.xml" />
+    <xi:include href="installing-virtualbox-guest.section.xml" />
+    <xi:include href="installing-from-other-distro.section.xml" />
+    <xi:include href="installing-behind-a-proxy.section.xml" />
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/obtaining.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/installation/obtaining.chapter.xml
new file mode 100644
index 000000000000..a922feda2536
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/obtaining.chapter.xml
@@ -0,0 +1,48 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-obtaining">
+  <title>Obtaining NixOS</title>
+  <para>
+    NixOS ISO images can be downloaded from the
+    <link xlink:href="https://nixos.org/nixos/download.html">NixOS
+    download page</link>. There are a number of installation options. If
+    you happen to have an optical drive and a spare CD, burning the
+    image to CD and booting from that is probably the easiest option.
+    Most people will need to prepare a USB stick to boot from.
+    <xref linkend="sec-booting-from-usb" /> describes the preferred
+    method to prepare a USB stick. A number of alternative methods are
+    presented in the
+    <link xlink:href="https://nixos.wiki/wiki/NixOS_Installation_Guide#Making_the_installation_media">NixOS
+    Wiki</link>.
+  </para>
+  <para>
+    As an alternative to installing NixOS yourself, you can get a
+    running NixOS system through several other means:
+  </para>
+  <itemizedlist>
+    <listitem>
+      <para>
+        Using virtual appliances in Open Virtualization Format (OVF)
+        that can be imported into VirtualBox. These are available from
+        the
+        <link xlink:href="https://nixos.org/nixos/download.html">NixOS
+        download page</link>.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Using AMIs for Amazon’s EC2. To find one for your region and
+        instance type, please refer to the
+        <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/ec2-amis.nix">list
+        of most recent AMIs</link>.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        Using NixOps, the NixOS-based cloud deployment tool, which
+        allows you to provision VirtualBox and EC2 NixOS instances from
+        declarative specifications. Check out the
+        <link xlink:href="https://nixos.org/nixops">NixOps
+        homepage</link> for details.
+      </para>
+    </listitem>
+  </itemizedlist>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/installation/upgrading.chapter.xml b/nixpkgs/nixos/doc/manual/from_md/installation/upgrading.chapter.xml
new file mode 100644
index 000000000000..c0c5a2190fb2
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/from_md/installation/upgrading.chapter.xml
@@ -0,0 +1,152 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-upgrading">
+  <title>Upgrading NixOS</title>
+  <para>
+    The best way to keep your NixOS installation up to date is to use
+    one of the NixOS <emphasis>channels</emphasis>. A channel is a Nix
+    mechanism for distributing Nix expressions and associated binaries.
+    The NixOS channels are updated automatically from NixOS’s Git
+    repository after certain tests have passed and all packages have
+    been built. These channels are:
+  </para>
+  <itemizedlist>
+    <listitem>
+      <para>
+        <emphasis>Stable channels</emphasis>, such as
+        <link xlink:href="https://nixos.org/channels/nixos-21.05"><literal>nixos-21.05</literal></link>.
+        These only get conservative bug fixes and package upgrades. For
+        instance, a channel update may cause the Linux kernel on your
+        system to be upgraded from 4.19.34 to 4.19.38 (a minor bug fix),
+        but not from 4.19.x to 4.20.x (a major change that has the
+        potential to break things). Stable channels are generally
+        maintained until the next stable branch is created.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        The <emphasis>unstable channel</emphasis>,
+        <link xlink:href="https://nixos.org/channels/nixos-unstable"><literal>nixos-unstable</literal></link>.
+        This corresponds to NixOS’s main development branch, and may
+        thus see radical changes between channel updates. It’s not
+        recommended for production systems.
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        <emphasis>Small channels</emphasis>, such as
+        <link xlink:href="https://nixos.org/channels/nixos-21.05-small"><literal>nixos-21.05-small</literal></link>
+        or
+        <link xlink:href="https://nixos.org/channels/nixos-unstable-small"><literal>nixos-unstable-small</literal></link>.
+        These are identical to the stable and unstable channels
+        described above, except that they contain fewer binary packages.
+        This means they get updated faster than the regular channels
+        (for instance, when a critical security patch is committed to
+        NixOS’s source tree), but may require more packages to be built
+        from source than usual. They’re mostly intended for server
+        environments and as such contain few GUI applications.
+      </para>
+    </listitem>
+  </itemizedlist>
+  <para>
+    To see what channels are available, go to
+    <link xlink:href="https://nixos.org/channels">https://nixos.org/channels</link>.
+    (Note that the URIs of the various channels redirect to a directory
+    that contains the channel’s latest version and includes ISO images
+    and VirtualBox appliances.) Please note that during the release
+    process, channels that are not yet released will be present here as
+    well. See the Getting NixOS page
+    <link xlink:href="https://nixos.org/nixos/download.html">https://nixos.org/nixos/download.html</link>
+    to find the newest supported stable release.
+  </para>
+  <para>
+    When you first install NixOS, you’re automatically subscribed to the
+    NixOS channel that corresponds to your installation source. For
+    instance, if you installed from a 21.05 ISO, you will be subscribed
+    to the <literal>nixos-21.05</literal> channel. To see which NixOS
+    channel you’re subscribed to, run the following as root:
+  </para>
+  <programlisting>
+# nix-channel --list | grep nixos
+nixos https://nixos.org/channels/nixos-unstable
+</programlisting>
+  <para>
+    To switch to a different NixOS channel, do
+  </para>
+  <programlisting>
+# nix-channel --add https://nixos.org/channels/channel-name nixos
+</programlisting>
+  <para>
+    (Be sure to include the <literal>nixos</literal> parameter at the
+    end.) For instance, to use the NixOS 21.05 stable channel:
+  </para>
+  <programlisting>
+# nix-channel --add https://nixos.org/channels/nixos-21.05 nixos
+</programlisting>
+  <para>
+    If you have a server, you may want to use the <quote>small</quote>
+    channel instead:
+  </para>
+  <programlisting>
+# nix-channel --add https://nixos.org/channels/nixos-21.05-small nixos
+</programlisting>
+  <para>
+    And if you want to live on the bleeding edge:
+  </para>
+  <programlisting>
+# nix-channel --add https://nixos.org/channels/nixos-unstable nixos
+</programlisting>
+  <para>
+    You can then upgrade NixOS to the latest version in your chosen
+    channel by running
+  </para>
+  <programlisting>
+# nixos-rebuild switch --upgrade
+</programlisting>
+  <para>
+    which is equivalent to the more verbose
+    <literal>nix-channel --update nixos; nixos-rebuild switch</literal>.
+  </para>
+  <note>
+    <para>
+      Channels are set per user. This means that running
+      <literal>nix-channel --add</literal> as a non root user (or
+      without sudo) will not affect configuration in
+      <literal>/etc/nixos/configuration.nix</literal>
+    </para>
+  </note>
+  <warning>
+    <para>
+      It is generally safe to switch back and forth between channels.
+      The only exception is that a newer NixOS may also have a newer Nix
+      version, which may involve an upgrade of Nix’s database schema.
+      This cannot be undone easily, so in that case you will not be able
+      to go back to your original channel.
+    </para>
+  </warning>
+  <section xml:id="sec-upgrading-automatic">
+    <title>Automatic Upgrades</title>
+    <para>
+      You can keep a NixOS system up-to-date automatically by adding the
+      following to <literal>configuration.nix</literal>:
+    </para>
+    <programlisting language="bash">
+system.autoUpgrade.enable = true;
+system.autoUpgrade.allowReboot = true;
+</programlisting>
+    <para>
+      This enables a periodically executed systemd service named
+      <literal>nixos-upgrade.service</literal>. If the
+      <literal>allowReboot</literal> option is <literal>false</literal>,
+      it runs <literal>nixos-rebuild switch --upgrade</literal> to
+      upgrade NixOS to the latest version in the current channel. (To
+      see when the service runs, see
+      <literal>systemctl list-timers</literal>.) If
+      <literal>allowReboot</literal> is <literal>true</literal>, then
+      the system will automatically reboot if the new generation
+      contains a different kernel, initrd or kernel modules. You can
+      also specify a channel explicitly, e.g.
+    </para>
+    <programlisting language="bash">
+system.autoUpgrade.channel = https://nixos.org/channels/nixos-21.05;
+</programlisting>
+  </section>
+</chapter>
diff --git a/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2009.section.xml b/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2009.section.xml
index c74d850b2c62..edebd92b327a 100644
--- a/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2009.section.xml
+++ b/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2009.section.xml
@@ -1684,13 +1684,17 @@ CREATE ROLE postgres LOGIN SUPERUSER;
       </listitem>
       <listitem>
         <para>
-          The notmuch package move its emacs-related binaries and emacs
+          The notmuch package moves its emacs-related binaries and emacs
           lisp files to a separate output. They're not part of the
           default <literal>out</literal> output anymore - if you relied
           on the <literal>notmuch-emacs-mua</literal> binary or the
           emacs lisp files, access them via the
-          <literal>notmuch.emacs</literal> output. Device tree overlay
-          support was improved in
+          <literal>notmuch.emacs</literal> output.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          Device tree overlay support was improved in
           <link xlink:href="https://github.com/NixOS/nixpkgs/pull/79370">#79370</link>
           and now uses
           <link xlink:href="options.html#opt-hardware.deviceTree.kernelPackage">hardware.deviceTree.kernelPackage</link>
diff --git a/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
index 1b0371a0179a..b18e29191470 100644
--- a/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
+++ b/nixpkgs/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
@@ -37,6 +37,17 @@
           PostgreSQL now defaults to major version 13.
         </para>
       </listitem>
+      <listitem>
+        <para>
+          Activation scripts can now opt int to be run when running
+          <literal>nixos-rebuild dry-activate</literal> and detect the
+          dry activation by reading <literal>$NIXOS_ACTION</literal>.
+          This allows activation scripts to output what they would
+          change if the activation was really run. The users/modules
+          activation script supports this and outputs some of is
+          actions.
+        </para>
+      </listitem>
     </itemizedlist>
   </section>
   <section xml:id="sec-release-21.11-new-services">
@@ -221,6 +232,13 @@
           <link linkend="opt-services.nats.enable">services.nats</link>.
         </para>
       </listitem>
+      <listitem>
+        <para>
+          <link xlink:href="https://git-scm.com">git</link>, a
+          distributed version control system. Available as
+          <link xlink:href="options.html#opt-programs.git.enable">programs.git</link>.
+        </para>
+      </listitem>
     </itemizedlist>
   </section>
   <section xml:id="sec-release-21.11-incompatibilities">
@@ -1121,6 +1139,24 @@ Superuser created successfully.
           rofi’s changelog</link>.
         </para>
       </listitem>
+      <listitem>
+        <para>
+          ipfs now defaults to not listening on you local network. This
+          setting was change as server providers won’t accept port
+          scanning on their private network. If you have several ipfs
+          instances running on a network you own, feel free to change
+          the setting <literal>ipfs.localDiscovery = true;</literal>.
+          localDiscovery enables different instances to discover each
+          other and share data.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          <literal>lua</literal> and <literal>luajit</literal>
+          interpreters have been patched to avoid looking into /usr/lib
+          directories, thus increasing the purity of the build.
+        </para>
+      </listitem>
     </itemizedlist>
   </section>
 </section>
diff --git a/nixpkgs/nixos/doc/manual/installation/changing-config.chapter.md b/nixpkgs/nixos/doc/manual/installation/changing-config.chapter.md
new file mode 100644
index 000000000000..8a404f085d7c
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/changing-config.chapter.md
@@ -0,0 +1,100 @@
+# Changing the Configuration {#sec-changing-config}
+
+The file `/etc/nixos/configuration.nix` contains the current
+configuration of your machine. Whenever you've [changed
+something](#ch-configuration) in that file, you should do
+
+```ShellSession
+# nixos-rebuild switch
+```
+
+to build the new configuration, make it the default configuration for
+booting, and try to realise the configuration in the running system
+(e.g., by restarting system services).
+
+::: {.warning}
+This command doesn\'t start/stop [user services](#opt-systemd.user.services)
+automatically. `nixos-rebuild` only runs a `daemon-reload` for each user with running
+user services.
+:::
+
+::: {.warning}
+These commands must be executed as root, so you should either run them
+from a root shell or by prefixing them with `sudo -i`.
+:::
+
+You can also do
+
+```ShellSession
+# nixos-rebuild test
+```
+
+to build the configuration and switch the running system to it, but
+without making it the boot default. So if (say) the configuration locks
+up your machine, you can just reboot to get back to a working
+configuration.
+
+There is also
+
+```ShellSession
+# nixos-rebuild boot
+```
+
+to build the configuration and make it the boot default, but not switch
+to it now (so it will only take effect after the next reboot).
+
+You can make your configuration show up in a different submenu of the
+GRUB 2 boot screen by giving it a different *profile name*, e.g.
+
+```ShellSession
+# nixos-rebuild switch -p test
+```
+
+which causes the new configuration (and previous ones created using
+`-p test`) to show up in the GRUB submenu "NixOS - Profile \'test\'".
+This can be useful to separate test configurations from "stable"
+configurations.
+
+Finally, you can do
+
+```ShellSession
+$ nixos-rebuild build
+```
+
+to build the configuration but nothing more. This is useful to see
+whether everything compiles cleanly.
+
+If you have a machine that supports hardware virtualisation, you can
+also test the new configuration in a sandbox by building and running a
+QEMU *virtual machine* that contains the desired configuration. Just do
+
+```ShellSession
+$ nixos-rebuild build-vm
+$ ./result/bin/run-*-vm
+```
+
+The VM does not have any data from your host system, so your existing
+user accounts and home directories will not be available unless you have
+set `mutableUsers = false`. Another way is to temporarily add the
+following to your configuration:
+
+```nix
+users.users.your-user.initialHashedPassword = "test";
+```
+
+*Important:* delete the \$hostname.qcow2 file if you have started the
+virtual machine at least once without the right users, otherwise the
+changes will not get picked up. You can forward ports on the host to the
+guest. For instance, the following will forward host port 2222 to guest
+port 22 (SSH):
+
+```ShellSession
+$ QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm
+```
+
+allowing you to log in via SSH (assuming you have set the appropriate
+passwords or SSH authorized keys):
+
+```ShellSession
+$ ssh -p 2222 localhost
+```
diff --git a/nixpkgs/nixos/doc/manual/installation/changing-config.xml b/nixpkgs/nixos/doc/manual/installation/changing-config.xml
deleted file mode 100644
index 4288806d5eb2..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/changing-config.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         version="5.0"
-         xml:id="sec-changing-config">
- <title>Changing the Configuration</title>
- <para>
-  The file <filename>/etc/nixos/configuration.nix</filename> contains the
-  current configuration of your machine. Whenever you’ve
-  <link linkend="ch-configuration">changed something</link> in that file, you
-  should do
-<screen>
-<prompt># </prompt>nixos-rebuild switch
-</screen>
-  to build the new configuration, make it the default configuration for
-  booting, and try to realise the configuration in the running system (e.g., by
-  restarting system services).
-  <warning>
-   <para>
-    This command doesn't start/stop <link linkend="opt-systemd.user.services">user
-    services</link> automatically. <command>nixos-rebuild</command> only runs a
-    <literal>daemon-reload</literal> for each user with running user services.
-   </para>
-  </warning>
- </para>
- <warning>
-  <para>
-   These commands must be executed as root, so you should either run them from
-   a root shell or by prefixing them with <literal>sudo -i</literal>.
-  </para>
- </warning>
- <para>
-  You can also do
-<screen>
-<prompt># </prompt>nixos-rebuild test
-</screen>
-  to build the configuration and switch the running system to it, but without
-  making it the boot default. So if (say) the configuration locks up your
-  machine, you can just reboot to get back to a working configuration.
- </para>
- <para>
-  There is also
-<screen>
-<prompt># </prompt>nixos-rebuild boot
-</screen>
-  to build the configuration and make it the boot default, but not switch to it
-  now (so it will only take effect after the next reboot).
- </para>
- <para>
-  You can make your configuration show up in a different submenu of the GRUB 2
-  boot screen by giving it a different <emphasis>profile name</emphasis>, e.g.
-<screen>
-<prompt># </prompt>nixos-rebuild switch -p test
-</screen>
-  which causes the new configuration (and previous ones created using
-  <literal>-p test</literal>) to show up in the GRUB submenu “NixOS - Profile
-  'test'”. This can be useful to separate test configurations from
-  “stable” configurations.
- </para>
- <para>
-  Finally, you can do
-<screen>
-<prompt>$ </prompt>nixos-rebuild build
-</screen>
-  to build the configuration but nothing more. This is useful to see whether
-  everything compiles cleanly.
- </para>
- <para>
-  If you have a machine that supports hardware virtualisation, you can also
-  test the new configuration in a sandbox by building and running a QEMU
-  <emphasis>virtual machine</emphasis> that contains the desired configuration.
-  Just do
-<screen>
-<prompt>$ </prompt>nixos-rebuild build-vm
-<prompt>$ </prompt>./result/bin/run-*-vm
-</screen>
-  The VM does not have any data from your host system, so your existing user
-  accounts and home directories will not be available unless you have set
-  <literal>mutableUsers = false</literal>. Another way is to temporarily add
-  the following to your configuration:
-<screen>
-<link linkend="opt-users.users._name_.initialHashedPassword">users.users.your-user.initialHashedPassword</link> = "test";
-</screen>
-  <emphasis>Important:</emphasis> delete the $hostname.qcow2 file if you have
-  started the virtual machine at least once without the right users, otherwise
-  the changes will not get picked up. You can forward ports on the host to the
-  guest. For instance, the following will forward host port 2222 to guest port
-  22 (SSH):
-<screen>
-<prompt>$ </prompt>QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm
-</screen>
-  allowing you to log in via SSH (assuming you have set the appropriate
-  passwords or SSH authorized keys):
-<screen>
-<prompt>$ </prompt>ssh -p 2222 localhost
-</screen>
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/installation/installation.xml b/nixpkgs/nixos/doc/manual/installation/installation.xml
index 2901f462dee0..1d443bbd0ee1 100644
--- a/nixpkgs/nixos/doc/manual/installation/installation.xml
+++ b/nixpkgs/nixos/doc/manual/installation/installation.xml
@@ -10,8 +10,8 @@
    first-time use.
   </para>
  </partintro>
- <xi:include href="obtaining.xml" />
- <xi:include href="installing.xml" />
- <xi:include href="changing-config.xml" />
- <xi:include href="upgrading.xml" />
+ <xi:include href="../from_md/installation/obtaining.chapter.xml" />
+ <xi:include href="../from_md/installation/installing.chapter.xml" />
+ <xi:include href="../from_md/installation/changing-config.chapter.xml" />
+ <xi:include href="../from_md/installation/upgrading.chapter.xml" />
 </part>
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.section.md b/nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.section.md
new file mode 100644
index 000000000000..aca151531d0f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.section.md
@@ -0,0 +1,29 @@
+# Installing behind a proxy {#sec-installing-behind-proxy}
+
+To install NixOS behind a proxy, do the following before running
+`nixos-install`.
+
+1.  Update proxy configuration in `/mnt/etc/nixos/configuration.nix` to
+    keep the internet accessible after reboot.
+
+    ```nix
+    networking.proxy.default = "http://user:password@proxy:port/";
+    networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
+    ```
+
+1.  Setup the proxy environment variables in the shell where you are
+    running `nixos-install`.
+
+    ```ShellSession
+    # proxy_url="http://user:password@proxy:port/"
+    # export http_proxy="$proxy_url"
+    # export HTTP_PROXY="$proxy_url"
+    # export https_proxy="$proxy_url"
+    # export HTTPS_PROXY="$proxy_url"
+    ```
+
+::: {.note}
+If you are switching networks with different proxy configurations, use
+the `specialisation` option in `configuration.nix` to switch proxies at
+runtime. Refer to [](#ch-options) for more information.
+:::
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.xml b/nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.xml
deleted file mode 100644
index 6788882aa8c0..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/installing-behind-a-proxy.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-installing-behind-proxy">
- <title>Installing behind a proxy</title>
-
- <para>
-  To install NixOS behind a proxy, do the following before running
-  <literal>nixos-install</literal>.
- </para>
-
- <orderedlist numeration="arabic">
-  <listitem>
-   <para>
-    Update proxy configuration in
-    <literal>/mnt/etc/nixos/configuration.nix</literal> to keep the internet
-    accessible after reboot.
-   </para>
-<programlisting>
-networking.proxy.default = &quot;http://user:password@proxy:port/&quot;;
-networking.proxy.noProxy = &quot;127.0.0.1,localhost,internal.domain&quot;;
-</programlisting>
-  </listitem>
-  <listitem>
-   <para>
-    Setup the proxy environment variables in the shell where you are running
-    <literal>nixos-install</literal>.
-   </para>
-<screen>
-<prompt># </prompt>proxy_url=&quot;http://user:password@proxy:port/&quot;
-<prompt># </prompt>export http_proxy=&quot;$proxy_url&quot;
-<prompt># </prompt>export HTTP_PROXY=&quot;$proxy_url&quot;
-<prompt># </prompt>export https_proxy=&quot;$proxy_url&quot;
-<prompt># </prompt>export HTTPS_PROXY=&quot;$proxy_url&quot;
-</screen>
-  </listitem>
- </orderedlist>
-
- <note>
-  <para>
-   If you are switching networks with different proxy configurations, use the
-   <literal>specialisation</literal> option in
-   <literal>configuration.nix</literal> to switch proxies at runtime. Refer to
-   <xref linkend="ch-options" /> for more information.
-  </para>
- </note>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.section.md b/nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.section.md
new file mode 100644
index 000000000000..d9060eb89c37
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.section.md
@@ -0,0 +1,279 @@
+# Installing from another Linux distribution {#sec-installing-from-other-distro}
+
+Because Nix (the package manager) & Nixpkgs (the Nix packages
+collection) can both be installed on any (most?) Linux distributions,
+they can be used to install NixOS in various creative ways. You can, for
+instance:
+
+1.  Install NixOS on another partition, from your existing Linux
+    distribution (without the use of a USB or optical device!)
+
+1.  Install NixOS on the same partition (in place!), from your existing
+    non-NixOS Linux distribution using `NIXOS_LUSTRATE`.
+
+1.  Install NixOS on your hard drive from the Live CD of any Linux
+    distribution.
+
+The first steps to all these are the same:
+
+1.  Install the Nix package manager:
+
+    Short version:
+
+    ```ShellSession
+    $ curl -L https://nixos.org/nix/install | sh
+    $ . $HOME/.nix-profile/etc/profile.d/nix.sh # …or open a fresh shell
+    ```
+
+    More details in the [ Nix
+    manual](https://nixos.org/nix/manual/#chap-quick-start)
+
+1.  Switch to the NixOS channel:
+
+    If you\'ve just installed Nix on a non-NixOS distribution, you will
+    be on the `nixpkgs` channel by default.
+
+    ```ShellSession
+    $ nix-channel --list
+    nixpkgs https://nixos.org/channels/nixpkgs-unstable
+    ```
+
+    As that channel gets released without running the NixOS tests, it
+    will be safer to use the `nixos-*` channels instead:
+
+    ```ShellSession
+    $ nix-channel --add https://nixos.org/channels/nixos-version nixpkgs
+    ```
+
+    You may want to throw in a `nix-channel --update` for good measure.
+
+1.  Install the NixOS installation tools:
+
+    You\'ll need `nixos-generate-config` and `nixos-install`, but this
+    also makes some man pages and `nixos-enter` available, just in case
+    you want to chroot into your NixOS partition. NixOS installs these
+    by default, but you don\'t have NixOS yet..
+
+    ```ShellSession
+    $ nix-env -f '<nixpkgs>' -iA nixos-install-tools
+    ```
+
+1.  ::: {.note}
+    The following 5 steps are only for installing NixOS to another
+    partition. For installing NixOS in place using `NIXOS_LUSTRATE`,
+    skip ahead.
+    :::
+
+    Prepare your target partition:
+
+    At this point it is time to prepare your target partition. Please
+    refer to the partitioning, file-system creation, and mounting steps
+    of [](#sec-installation)
+
+    If you\'re about to install NixOS in place using `NIXOS_LUSTRATE`
+    there is nothing to do for this step.
+
+1.  Generate your NixOS configuration:
+
+    ```ShellSession
+    $ sudo `which nixos-generate-config` --root /mnt
+    ```
+
+    You\'ll probably want to edit the configuration files. Refer to the
+    `nixos-generate-config` step in [](#sec-installation) for more
+    information.
+
+    Consider setting up the NixOS bootloader to give you the ability to
+    boot on your existing Linux partition. For instance, if you\'re
+    using GRUB and your existing distribution is running Ubuntu, you may
+    want to add something like this to your `configuration.nix`:
+
+    ```nix
+    boot.loader.grub.extraEntries = ''
+      menuentry "Ubuntu" {
+        search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e
+        configfile "($ubuntu)/boot/grub/grub.cfg"
+      }
+    '';
+    ```
+
+    (You can find the appropriate UUID for your partition in
+    `/dev/disk/by-uuid`)
+
+1.  Create the `nixbld` group and user on your original distribution:
+
+    ```ShellSession
+    $ sudo groupadd -g 30000 nixbld
+    $ sudo useradd -u 30000 -g nixbld -G nixbld nixbld
+    ```
+
+1.  Download/build/install NixOS:
+
+    ::: {.warning}
+    Once you complete this step, you might no longer be able to boot on
+    existing systems without the help of a rescue USB drive or similar.
+    :::
+
+    ::: {.note}
+    On some distributions there are separate PATHS for programs intended
+    only for root. In order for the installation to succeed, you might
+    have to use `PATH="$PATH:/usr/sbin:/sbin"` in the following command.
+    :::
+
+    ```ShellSession
+    $ sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --root /mnt
+    ```
+
+    Again, please refer to the `nixos-install` step in
+    [](#sec-installation) for more information.
+
+    That should be it for installation to another partition!
+
+1.  Optionally, you may want to clean up your non-NixOS distribution:
+
+    ```ShellSession
+    $ sudo userdel nixbld
+    $ sudo groupdel nixbld
+    ```
+
+    If you do not wish to keep the Nix package manager installed either,
+    run something like `sudo rm -rv ~/.nix-* /nix` and remove the line
+    that the Nix installer added to your `~/.profile`.
+
+1.  ::: {.note}
+    The following steps are only for installing NixOS in place using
+    `NIXOS_LUSTRATE`:
+    :::
+
+    Generate your NixOS configuration:
+
+    ```ShellSession
+    $ sudo `which nixos-generate-config` --root /
+    ```
+
+    Note that this will place the generated configuration files in
+    `/etc/nixos`. You\'ll probably want to edit the configuration files.
+    Refer to the `nixos-generate-config` step in
+    [](#sec-installation) for more information.
+
+    You\'ll likely want to set a root password for your first boot using
+    the configuration files because you won\'t have a chance to enter a
+    password until after you reboot. You can initalize the root password
+    to an empty one with this line: (and of course don\'t forget to set
+    one once you\'ve rebooted or to lock the account with
+    `sudo passwd -l root` if you use `sudo`)
+
+    ```nix
+    users.users.root.initialHashedPassword = "";
+    ```
+
+1.  Build the NixOS closure and install it in the `system` profile:
+
+    ```ShellSession
+    $ nix-env -p /nix/var/nix/profiles/system -f '<nixpkgs/nixos>' -I nixos-config=/etc/nixos/configuration.nix -iA system
+    ```
+
+1.  Change ownership of the `/nix` tree to root (since your Nix install
+    was probably single user):
+
+    ```ShellSession
+    $ sudo chown -R 0.0 /nix
+    ```
+
+1.  Set up the `/etc/NIXOS` and `/etc/NIXOS_LUSTRATE` files:
+
+    `/etc/NIXOS` officializes that this is now a NixOS partition (the
+    bootup scripts require its presence).
+
+    `/etc/NIXOS_LUSTRATE` tells the NixOS bootup scripts to move
+    *everything* that\'s in the root partition to `/old-root`. This will
+    move your existing distribution out of the way in the very early
+    stages of the NixOS bootup. There are exceptions (we do need to keep
+    NixOS there after all), so the NixOS lustrate process will not
+    touch:
+
+    -   The `/nix` directory
+
+    -   The `/boot` directory
+
+    -   Any file or directory listed in `/etc/NIXOS_LUSTRATE` (one per
+        line)
+
+    ::: {.note}
+    Support for `NIXOS_LUSTRATE` was added in NixOS 16.09. The act of
+    \"lustrating\" refers to the wiping of the existing distribution.
+    Creating `/etc/NIXOS_LUSTRATE` can also be used on NixOS to remove
+    all mutable files from your root partition (anything that\'s not in
+    `/nix` or `/boot` gets \"lustrated\" on the next boot.
+
+    lustrate /ˈlʌstreɪt/ verb.
+
+    purify by expiatory sacrifice, ceremonial washing, or some other
+    ritual action.
+    :::
+
+    Let\'s create the files:
+
+    ```ShellSession
+    $ sudo touch /etc/NIXOS
+    $ sudo touch /etc/NIXOS_LUSTRATE
+    ```
+
+    Let\'s also make sure the NixOS configuration files are kept once we
+    reboot on NixOS:
+
+    ```ShellSession
+    $ echo etc/nixos | sudo tee -a /etc/NIXOS_LUSTRATE
+    ```
+
+1.  Finally, move the `/boot` directory of your current distribution out
+    of the way (the lustrate process will take care of the rest once you
+    reboot, but this one must be moved out now because NixOS needs to
+    install its own boot files:
+
+    ::: {.warning}
+    Once you complete this step, your current distribution will no
+    longer be bootable! If you didn\'t get all the NixOS configuration
+    right, especially those settings pertaining to boot loading and root
+    partition, NixOS may not be bootable either. Have a USB rescue
+    device ready in case this happens.
+    :::
+
+    ```ShellSession
+    $ sudo mv -v /boot /boot.bak &&
+    sudo /nix/var/nix/profiles/system/bin/switch-to-configuration boot
+    ```
+
+    Cross your fingers, reboot, hopefully you should get a NixOS prompt!
+
+1.  If for some reason you want to revert to the old distribution,
+    you\'ll need to boot on a USB rescue disk and do something along
+    these lines:
+
+    ```ShellSession
+    # mkdir root
+    # mount /dev/sdaX root
+    # mkdir root/nixos-root
+    # mv -v root/* root/nixos-root/
+    # mv -v root/nixos-root/old-root/* root/
+    # mv -v root/boot.bak root/boot  # We had renamed this by hand earlier
+    # umount root
+    # reboot
+    ```
+
+    This may work as is or you might also need to reinstall the boot
+    loader.
+
+    And of course, if you\'re happy with NixOS and no longer need the
+    old distribution:
+
+    ```ShellSession
+    sudo rm -rf /old-root
+    ```
+
+1.  It\'s also worth noting that this whole process can be automated.
+    This is especially useful for Cloud VMs, where provider do not
+    provide NixOS. For instance,
+    [nixos-infect](https://github.com/elitak/nixos-infect) uses the
+    lustrate process to convert Digital Ocean droplets to NixOS from
+    other distributions automatically.
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.xml b/nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.xml
deleted file mode 100644
index 63d1d52b01b2..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/installing-from-other-distro.xml
+++ /dev/null
@@ -1,364 +0,0 @@
-<!-- vim: set expandtab ts=2 softtabstop=2 shiftwidth=2 smarttab textwidth=80 wrapmargin=2 -->
-<section
-    xmlns="http://docbook.org/ns/docbook"
-    xmlns:xlink="http://www.w3.org/1999/xlink"
-    xmlns:xi="http://www.w3.org/2001/XInclude"
-    version="5.0"
-    xml:id="sec-installing-from-other-distro">
- <title>Installing from another Linux distribution</title>
-
- <para>
-  Because Nix (the package manager) &amp; Nixpkgs (the Nix packages collection)
-  can both be installed on any (most?) Linux distributions, they can be used to
-  install NixOS in various creative ways. You can, for instance:
- </para>
-
- <orderedlist>
-  <listitem>
-   <para>
-    Install NixOS on another partition, from your existing Linux distribution
-    (without the use of a USB or optical device!)
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Install NixOS on the same partition (in place!), from your existing
-    non-NixOS Linux distribution using <literal>NIXOS_LUSTRATE</literal>.
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Install NixOS on your hard drive from the Live CD of any Linux
-    distribution.
-   </para>
-  </listitem>
- </orderedlist>
-
- <para>
-  The first steps to all these are the same:
- </para>
-
- <orderedlist>
-  <listitem>
-   <para>
-    Install the Nix package manager:
-   </para>
-   <para>
-    Short version:
-   </para>
-<screen>
-<prompt>$ </prompt>curl -L https://nixos.org/nix/install | sh
-<prompt>$ </prompt>. $HOME/.nix-profile/etc/profile.d/nix.sh # …or open a fresh shell</screen>
-   <para>
-    More details in the
-    <link
-                    xlink:href="https://nixos.org/nix/manual/#chap-quick-start">
-    Nix manual</link>
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Switch to the NixOS channel:
-   </para>
-   <para>
-    If you've just installed Nix on a non-NixOS distribution, you will be on
-    the <literal>nixpkgs</literal> channel by default.
-   </para>
-<screen>
-<prompt>$ </prompt>nix-channel --list
-nixpkgs https://nixos.org/channels/nixpkgs-unstable</screen>
-   <para>
-    As that channel gets released without running the NixOS tests, it will be
-    safer to use the <literal>nixos-*</literal> channels instead:
-   </para>
-<screen>
-<prompt>$ </prompt>nix-channel --add https://nixos.org/channels/nixos-<replaceable>version</replaceable> nixpkgs</screen>
-   <para>
-    You may want to throw in a <literal>nix-channel --update</literal> for good
-    measure.
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Install the NixOS installation tools:
-   </para>
-   <para>
-    You'll need <literal>nixos-generate-config</literal> and
-    <literal>nixos-install</literal>, but this also makes some man pages
-    and <literal>nixos-enter</literal> available, just in case you want to chroot into your
-    NixOS partition. NixOS installs these by default, but you don't have
-    NixOS yet..
-   </para>
-   <screen><prompt>$ </prompt>nix-env -f '&lt;nixpkgs>' -iA nixos-install-tools</screen>
-  </listitem>
-  <listitem>
-   <note>
-    <para>
-     The following 5 steps are only for installing NixOS to another partition.
-     For installing NixOS in place using <literal>NIXOS_LUSTRATE</literal>,
-     skip ahead.
-    </para>
-   </note>
-   <para>
-    Prepare your target partition:
-   </para>
-   <para>
-    At this point it is time to prepare your target partition. Please refer to
-    the partitioning, file-system creation, and mounting steps of
-    <xref linkend="sec-installation" />
-   </para>
-   <para>
-    If you're about to install NixOS in place using
-    <literal>NIXOS_LUSTRATE</literal> there is nothing to do for this step.
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Generate your NixOS configuration:
-   </para>
-<screen><prompt>$ </prompt>sudo `which nixos-generate-config` --root /mnt</screen>
-   <para>
-    You'll probably want to edit the configuration files. Refer to the
-    <literal>nixos-generate-config</literal> step in
-    <xref
-                    linkend="sec-installation" /> for more
-    information.
-   </para>
-   <para>
-    Consider setting up the NixOS bootloader to give you the ability to boot on
-    your existing Linux partition. For instance, if you're using GRUB and your
-    existing distribution is running Ubuntu, you may want to add something like
-    this to your <literal>configuration.nix</literal>:
-   </para>
-<programlisting>
-<xref linkend="opt-boot.loader.grub.extraEntries"/> = ''
-  menuentry "Ubuntu" {
-    search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e
-    configfile "($ubuntu)/boot/grub/grub.cfg"
-  }
-'';</programlisting>
-   <para>
-    (You can find the appropriate UUID for your partition in
-    <literal>/dev/disk/by-uuid</literal>)
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Create the <literal>nixbld</literal> group and user on your original
-    distribution:
-   </para>
-<screen>
-<prompt>$ </prompt>sudo groupadd -g 30000 nixbld
-<prompt>$ </prompt>sudo useradd -u 30000 -g nixbld -G nixbld nixbld</screen>
-  </listitem>
-  <listitem>
-   <para>
-    Download/build/install NixOS:
-   </para>
-   <warning>
-    <para>
-     Once you complete this step, you might no longer be able to boot on
-     existing systems without the help of a rescue USB drive or similar.
-    </para>
-   </warning>
-   <note>
-    <para>
-     On some distributions there are separate PATHS for programs intended only for root.
-     In order for the installation to succeed, you might have to use <literal>PATH="$PATH:/usr/sbin:/sbin"</literal>
-     in the following command.
-    </para>
-   </note>
-<screen><prompt>$ </prompt>sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --root /mnt</screen>
-   <para>
-    Again, please refer to the <literal>nixos-install</literal> step in
-    <xref linkend="sec-installation" /> for more information.
-   </para>
-   <para>
-    That should be it for installation to another partition!
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Optionally, you may want to clean up your non-NixOS distribution:
-   </para>
-<screen>
-<prompt>$ </prompt>sudo userdel nixbld
-<prompt>$ </prompt>sudo groupdel nixbld</screen>
-   <para>
-    If you do not wish to keep the Nix package manager installed either, run
-    something like <literal>sudo rm -rv ~/.nix-* /nix</literal> and remove the
-    line that the Nix installer added to your <literal>~/.profile</literal>.
-   </para>
-  </listitem>
-  <listitem>
-   <note>
-    <para>
-     The following steps are only for installing NixOS in place using
-     <literal>NIXOS_LUSTRATE</literal>:
-    </para>
-   </note>
-   <para>
-    Generate your NixOS configuration:
-   </para>
-<screen><prompt>$ </prompt>sudo `which nixos-generate-config` --root /</screen>
-   <para>
-    Note that this will place the generated configuration files in
-    <literal>/etc/nixos</literal>. You'll probably want to edit the
-    configuration files. Refer to the <literal>nixos-generate-config</literal>
-    step in <xref
-                    linkend="sec-installation" /> for more
-    information.
-   </para>
-   <para>
-    You'll likely want to set a root password for your first boot using the
-    configuration files because you won't have a chance to enter a password
-    until after you reboot. You can initalize the root password to an empty one
-    with this line: (and of course don't forget to set one once you've rebooted
-    or to lock the account with <literal>sudo passwd -l root</literal> if you
-    use <literal>sudo</literal>)
-   </para>
-<programlisting>
-<link linkend="opt-users.users._name_.initialHashedPassword">users.users.root.initialHashedPassword</link> = "";
-</programlisting>
-  </listitem>
-  <listitem>
-   <para>
-    Build the NixOS closure and install it in the <literal>system</literal>
-    profile:
-   </para>
-<screen><prompt>$ </prompt>nix-env -p /nix/var/nix/profiles/system -f '&lt;nixpkgs/nixos&gt;' -I nixos-config=/etc/nixos/configuration.nix -iA system</screen>
-  </listitem>
-  <listitem>
-   <para>
-    Change ownership of the <literal>/nix</literal> tree to root (since your
-    Nix install was probably single user):
-   </para>
-<screen><prompt>$ </prompt>sudo chown -R 0.0 /nix</screen>
-  </listitem>
-  <listitem>
-   <para>
-    Set up the <literal>/etc/NIXOS</literal> and
-    <literal>/etc/NIXOS_LUSTRATE</literal> files:
-   </para>
-   <para>
-    <literal>/etc/NIXOS</literal> officializes that this is now a NixOS
-    partition (the bootup scripts require its presence).
-   </para>
-   <para>
-    <literal>/etc/NIXOS_LUSTRATE</literal> tells the NixOS bootup scripts to
-    move <emphasis>everything</emphasis> that's in the root partition to
-    <literal>/old-root</literal>. This will move your existing distribution out
-    of the way in the very early stages of the NixOS bootup. There are
-    exceptions (we do need to keep NixOS there after all), so the NixOS
-    lustrate process will not touch:
-   </para>
-   <itemizedlist>
-    <listitem>
-     <para>
-      The <literal>/nix</literal> directory
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      The <literal>/boot</literal> directory
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Any file or directory listed in <literal>/etc/NIXOS_LUSTRATE</literal>
-      (one per line)
-     </para>
-    </listitem>
-   </itemizedlist>
-   <note>
-    <para>
-     Support for <literal>NIXOS_LUSTRATE</literal> was added in NixOS 16.09.
-     The act of "lustrating" refers to the wiping of the existing distribution.
-     Creating <literal>/etc/NIXOS_LUSTRATE</literal> can also be used on NixOS
-     to remove all mutable files from your root partition (anything that's not
-     in <literal>/nix</literal> or <literal>/boot</literal> gets "lustrated" on
-     the next boot.
-    </para>
-    <para>
-     lustrate /ˈlʌstreɪt/ verb.
-    </para>
-    <para>
-     purify by expiatory sacrifice, ceremonial washing, or some other ritual
-     action.
-    </para>
-   </note>
-   <para>
-    Let's create the files:
-   </para>
-<screen>
-<prompt>$ </prompt>sudo touch /etc/NIXOS
-<prompt>$ </prompt>sudo touch /etc/NIXOS_LUSTRATE
-</screen>
-   <para>
-    Let's also make sure the NixOS configuration files are kept once we reboot
-    on NixOS:
-   </para>
-<screen>
-<prompt>$ </prompt>echo etc/nixos | sudo tee -a /etc/NIXOS_LUSTRATE
-</screen>
-  </listitem>
-  <listitem>
-   <para>
-    Finally, move the <literal>/boot</literal> directory of your current
-    distribution out of the way (the lustrate process will take care of the
-    rest once you reboot, but this one must be moved out now because NixOS
-    needs to install its own boot files:
-   </para>
-   <warning>
-    <para>
-     Once you complete this step, your current distribution will no longer be
-     bootable! If you didn't get all the NixOS configuration right, especially
-     those settings pertaining to boot loading and root partition, NixOS may
-     not be bootable either. Have a USB rescue device ready in case this
-     happens.
-    </para>
-   </warning>
-<screen>
-<prompt>$ </prompt>sudo mv -v /boot /boot.bak &amp;&amp;
-sudo /nix/var/nix/profiles/system/bin/switch-to-configuration boot
-</screen>
-   <para>
-    Cross your fingers, reboot, hopefully you should get a NixOS prompt!
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    If for some reason you want to revert to the old distribution, you'll need
-    to boot on a USB rescue disk and do something along these lines:
-   </para>
-<screen>
-<prompt># </prompt>mkdir root
-<prompt># </prompt>mount /dev/sdaX root
-<prompt># </prompt>mkdir root/nixos-root
-<prompt># </prompt>mv -v root/* root/nixos-root/
-<prompt># </prompt>mv -v root/nixos-root/old-root/* root/
-<prompt># </prompt>mv -v root/boot.bak root/boot  # We had renamed this by hand earlier
-<prompt># </prompt>umount root
-<prompt># </prompt>reboot</screen>
-   <para>
-    This may work as is or you might also need to reinstall the boot loader
-   </para>
-   <para>
-    And of course, if you're happy with NixOS and no longer need the old
-    distribution:
-   </para>
-<screen>sudo rm -rf /old-root</screen>
-  </listitem>
-  <listitem>
-   <para>
-    It's also worth noting that this whole process can be automated. This is
-    especially useful for Cloud VMs, where provider do not provide NixOS. For
-    instance,
-    <link
-                    xlink:href="https://github.com/elitak/nixos-infect">nixos-infect</link>
-    uses the lustrate process to convert Digital Ocean droplets to NixOS from
-    other distributions automatically.
-   </para>
-  </listitem>
- </orderedlist>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-pxe.section.md b/nixpkgs/nixos/doc/manual/installation/installing-pxe.section.md
new file mode 100644
index 000000000000..2016a258251f
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/installing-pxe.section.md
@@ -0,0 +1,32 @@
+# Booting from the "netboot" media (PXE) {#sec-booting-from-pxe}
+
+Advanced users may wish to install NixOS using an existing PXE or iPXE
+setup.
+
+These instructions assume that you have an existing PXE or iPXE
+infrastructure and simply want to add the NixOS installer as another
+option. To build the necessary files from a recent version of nixpkgs,
+you can run:
+
+```ShellSession
+nix-build -A netboot.x86_64-linux nixos/release.nix
+```
+
+This will create a `result` directory containing: \* `bzImage` -- the
+Linux kernel \* `initrd` -- the initrd file \* `netboot.ipxe` -- an
+example ipxe script demonstrating the appropriate kernel command line
+arguments for this image
+
+If you're using plain PXE, configure your boot loader to use the
+`bzImage` and `initrd` files and have it provide the same kernel command
+line arguments found in `netboot.ipxe`.
+
+If you're using iPXE, depending on how your HTTP/FTP/etc. server is
+configured you may be able to use `netboot.ipxe` unmodified, or you may
+need to update the paths to the files to match your server's directory
+layout.
+
+In the future we may begin making these files available as build
+products from hydra at which point we will update this documentation
+with instructions on how to obtain them either for placing on a
+dedicated TFTP server or to boot them directly over the internet.
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-pxe.xml b/nixpkgs/nixos/doc/manual/installation/installing-pxe.xml
deleted file mode 100644
index ea88fbdad7e2..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/installing-pxe.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-booting-from-pxe">
- <title>Booting from the <quote>netboot</quote> media (PXE)</title>
-
- <para>
-  Advanced users may wish to install NixOS using an existing PXE or iPXE setup.
- </para>
-
- <para>
-  These instructions assume that you have an existing PXE or iPXE
-  infrastructure and simply want to add the NixOS installer as another option.
-  To build the necessary files from a recent version of nixpkgs, you can run:
- </para>
-
-<programlisting>
-nix-build -A netboot.x86_64-linux nixos/release.nix
-</programlisting>
-
- <para>
-  This will create a <literal>result</literal> directory containing: *
-  <literal>bzImage</literal> – the Linux kernel * <literal>initrd</literal>
-  – the initrd file * <literal>netboot.ipxe</literal> – an example ipxe
-  script demonstrating the appropriate kernel command line arguments for this
-  image
- </para>
-
- <para>
-  If you’re using plain PXE, configure your boot loader to use the
-  <literal>bzImage</literal> and <literal>initrd</literal> files and have it
-  provide the same kernel command line arguments found in
-  <literal>netboot.ipxe</literal>.
- </para>
-
- <para>
-  If you’re using iPXE, depending on how your HTTP/FTP/etc. server is
-  configured you may be able to use <literal>netboot.ipxe</literal> unmodified,
-  or you may need to update the paths to the files to match your server’s
-  directory layout
- </para>
-
- <para>
-  In the future we may begin making these files available as build products
-  from hydra at which point we will update this documentation with instructions
-  on how to obtain them either for placing on a dedicated TFTP server or to
-  boot them directly over the internet.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-usb.section.md b/nixpkgs/nixos/doc/manual/installation/installing-usb.section.md
new file mode 100644
index 000000000000..ae58c08e5237
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/installing-usb.section.md
@@ -0,0 +1,31 @@
+# Booting from a USB Drive {#sec-booting-from-usb}
+
+For systems without CD drive, the NixOS live CD can be booted from a USB
+stick. You can use the `dd` utility to write the image:
+`dd if=path-to-image of=/dev/sdX`. Be careful about specifying the correct
+drive; you can use the `lsblk` command to get a list of block devices.
+
+::: {.note}
+::: {.title}
+On macOS
+:::
+
+```ShellSession
+$ diskutil list
+[..]
+/dev/diskN (external, physical):
+   #:                       TYPE NAME                    SIZE       IDENTIFIER
+[..]
+$ diskutil unmountDisk diskN
+Unmount of all volumes on diskN was successful
+$ sudo dd if=nix.iso of=/dev/rdiskN
+```
+
+Using the \'raw\' `rdiskN` device instead of `diskN` completes in
+minutes instead of hours. After `dd` completes, a GUI dialog \"The disk
+you inserted was not readable by this computer\" will pop up, which can
+be ignored.
+:::
+
+The `dd` utility will write the image verbatim to the drive, making it
+the recommended option for both UEFI and non-UEFI installations.
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-usb.xml b/nixpkgs/nixos/doc/manual/installation/installing-usb.xml
deleted file mode 100644
index 83598635acca..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/installing-usb.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-booting-from-usb">
- <title>Booting from a USB Drive</title>
-
- <para>
-  For systems without CD drive, the NixOS live CD can be booted from a USB
-  stick. You can use the <command>dd</command> utility to write the image:
-  <command>dd if=<replaceable>path-to-image</replaceable>
-  of=<replaceable>/dev/sdX</replaceable></command>. Be careful about specifying
-  the correct drive; you can use the <command>lsblk</command> command to get a
-  list of block devices.
-  <note>
-   <title>On macOS</title>
-   <para>
-<screen>
-<prompt>$ </prompt>diskutil list
-[..]
-/dev/diskN (external, physical):
-   #:                       TYPE NAME                    SIZE       IDENTIFIER
-[..]
-<prompt>$ </prompt>diskutil unmountDisk diskN
-Unmount of all volumes on diskN was successful
-<prompt>$ </prompt>sudo dd if=nix.iso of=/dev/rdiskN
-</screen>
-    Using the 'raw' <command>rdiskN</command> device instead of
-    <command>diskN</command> completes in minutes instead of hours. After
-    <command>dd</command> completes, a GUI dialog "The disk you inserted was
-    not readable by this computer" will pop up, which can be ignored.
-   </para>
-  </note>
- </para>
-
- <para>
-  The <command>dd</command> utility will write the image verbatim to the drive,
-  making it the recommended option for both UEFI and non-UEFI installations.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.section.md b/nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.section.md
new file mode 100644
index 000000000000..e9c2a621c1bb
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.section.md
@@ -0,0 +1,59 @@
+# Installing in a VirtualBox guest {#sec-instaling-virtualbox-guest}
+
+Installing NixOS into a VirtualBox guest is convenient for users who
+want to try NixOS without installing it on bare metal. If you want to
+use a pre-made VirtualBox appliance, it is available at [the downloads
+page](https://nixos.org/nixos/download.html). If you want to set up a
+VirtualBox guest manually, follow these instructions:
+
+1.  Add a New Machine in VirtualBox with OS Type \"Linux / Other Linux\"
+
+1.  Base Memory Size: 768 MB or higher.
+
+1.  New Hard Disk of 8 GB or higher.
+
+1.  Mount the CD-ROM with the NixOS ISO (by clicking on CD/DVD-ROM)
+
+1.  Click on Settings / System / Processor and enable PAE/NX
+
+1.  Click on Settings / System / Acceleration and enable \"VT-x/AMD-V\"
+    acceleration
+
+1.  Click on Settings / Display / Screen and select VMSVGA as Graphics
+    Controller
+
+1.  Save the settings, start the virtual machine, and continue
+    installation like normal
+
+There are a few modifications you should make in configuration.nix.
+Enable booting:
+
+```nix
+boot.loader.grub.device = "/dev/sda";
+```
+
+Also remove the fsck that runs at startup. It will always fail to run,
+stopping your boot until you press `*`.
+
+```nix
+boot.initrd.checkJournalingFS = false;
+```
+
+Shared folders can be given a name and a path in the host system in the
+VirtualBox settings (Machine / Settings / Shared Folders, then click on
+the \"Add\" icon). Add the following to the
+`/etc/nixos/configuration.nix` to auto-mount them. If you do not add
+`"nofail"`, the system will not boot properly.
+
+```nix
+{ config, pkgs, ...} :
+{
+  fileSystems."/virtualboxshare" = {
+    fsType = "vboxsf";
+    device = "nameofthesharedfolder";
+    options = [ "rw" "nofail" ];
+  };
+}
+```
+
+The folder will be available directly under the root directory.
diff --git a/nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.xml b/nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.xml
deleted file mode 100644
index 019e5098a8e2..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/installing-virtualbox-guest.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-instaling-virtualbox-guest">
- <title>Installing in a VirtualBox guest</title>
-
- <para>
-  Installing NixOS into a VirtualBox guest is convenient for users who want to
-  try NixOS without installing it on bare metal. If you want to use a pre-made
-  VirtualBox appliance, it is available at
-  <link
-  xlink:href="https://nixos.org/nixos/download.html">the downloads
-  page</link>. If you want to set up a VirtualBox guest manually, follow these
-  instructions:
- </para>
-
- <orderedlist>
-  <listitem>
-   <para>
-    Add a New Machine in VirtualBox with OS Type "Linux / Other Linux"
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Base Memory Size: 768 MB or higher.
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    New Hard Disk of 8 GB or higher.
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Mount the CD-ROM with the NixOS ISO (by clicking on CD/DVD-ROM)
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Click on Settings / System / Processor and enable PAE/NX
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Click on Settings / System / Acceleration and enable "VT-x/AMD-V"
-    acceleration
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Click on Settings / Display / Screen and select VMSVGA as Graphics Controller
-   </para>
-  </listitem>
-  <listitem>
-   <para>
-    Save the settings, start the virtual machine, and continue installation
-    like normal
-   </para>
-  </listitem>
- </orderedlist>
-
- <para>
-  There are a few modifications you should make in configuration.nix. Enable
-  booting:
- </para>
-
-<programlisting>
-<xref linkend="opt-boot.loader.grub.device"/> = "/dev/sda";
-</programlisting>
-
- <para>
-  Also remove the fsck that runs at startup. It will always fail to run,
-  stopping your boot until you press <literal>*</literal>.
- </para>
-
-<programlisting>
-<xref linkend="opt-boot.initrd.checkJournalingFS"/> = false;
-</programlisting>
-
- <para>
-  Shared folders can be given a name and a path in the host system in the
-  VirtualBox settings (Machine / Settings / Shared Folders, then click on the
-  "Add" icon). Add the following to the
-  <literal>/etc/nixos/configuration.nix</literal> to auto-mount them. If you do
-  not add <literal>"nofail"</literal>, the system will not boot properly.
- </para>
-
-<programlisting>
-{ config, pkgs, ...} :
-{
-  fileSystems."/virtualboxshare" = {
-    fsType = "vboxsf";
-    device = "nameofthesharedfolder";
-    options = [ "rw" "nofail" ];
-  };
-}
-</programlisting>
-
- <para>
-  The folder will be available directly under the root directory.
- </para>
-</section>
diff --git a/nixpkgs/nixos/doc/manual/installation/installing.chapter.md b/nixpkgs/nixos/doc/manual/installation/installing.chapter.md
new file mode 100644
index 000000000000..a0823b51e9cb
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/installing.chapter.md
@@ -0,0 +1,479 @@
+# Installing NixOS {#sec-installation}
+
+## Booting the system {#sec-installation-booting}
+
+NixOS can be installed on BIOS or UEFI systems. The procedure for a UEFI
+installation is by and large the same as a BIOS installation. The
+differences are mentioned in the steps that follow.
+
+The installation media can be burned to a CD, or now more commonly,
+"burned" to a USB drive (see [](#sec-booting-from-usb)).
+
+The installation media contains a basic NixOS installation. When it's
+finished booting, it should have detected most of your hardware.
+
+The NixOS manual is available by running `nixos-help`.
+
+You are logged-in automatically as `nixos`. The `nixos` user account has
+an empty password so you can use `sudo` without a password.
+
+If you downloaded the graphical ISO image, you can run `systemctl
+start display-manager` to start the desktop environment. If you want
+to continue on the terminal, you can use `loadkeys` to switch to your
+preferred keyboard layout. (We even provide neo2 via `loadkeys de
+neo`!)
+
+If the text is too small to be legible, try `setfont ter-v32n` to
+increase the font size.
+
+To install over a serial port connect with `115200n8` (e.g.
+`picocom -b 115200 /dev/ttyUSB0`). When the bootloader lists boot
+entries, select the serial console boot entry.
+
+### Networking in the installer {#sec-installation-booting-networking}
+
+The boot process should have brought up networking (check `ip
+a`). Networking is necessary for the installer, since it will
+download lots of stuff (such as source tarballs or Nixpkgs channel
+binaries). It's best if you have a DHCP server on your network.
+Otherwise configure networking manually using `ifconfig`.
+
+On the graphical installer, you can configure the network, wifi
+included, through NetworkManager. Using the `nmtui` program, you can do
+so even in a non-graphical session. If you prefer to configure the
+network manually, disable NetworkManager with
+`systemctl stop NetworkManager`.
+
+On the minimal installer, NetworkManager is not available, so
+configuration must be perfomed manually. To configure the wifi, first
+start wpa_supplicant with `sudo systemctl start wpa_supplicant`, then
+run `wpa_cli`. For most home networks, you need to type in the following
+commands:
+
+```plain
+> add_network
+0
+> set_network 0 ssid "myhomenetwork"
+OK
+> set_network 0 psk "mypassword"
+OK
+> set_network 0 key_mgmt WPA-PSK
+OK
+> enable_network 0
+OK
+```
+
+For enterprise networks, for example *eduroam*, instead do:
+
+```plain
+> add_network
+0
+> set_network 0 ssid "eduroam"
+OK
+> set_network 0 identity "myname@example.com"
+OK
+> set_network 0 password "mypassword"
+OK
+> set_network 0 key_mgmt WPA-EAP
+OK
+> enable_network 0
+OK
+```
+
+When successfully connected, you should see a line such as this one
+
+```plain
+<3>CTRL-EVENT-CONNECTED - Connection to 32:85:ab:ef:24:5c completed [id=0 id_str=]
+```
+
+you can now leave `wpa_cli` by typing `quit`.
+
+If you would like to continue the installation from a different machine
+you can use activated SSH daemon. You need to copy your ssh key to
+either `/home/nixos/.ssh/authorized_keys` or
+`/root/.ssh/authorized_keys` (Tip: For installers with a modifiable
+filesystem such as the sd-card installer image a key can be manually
+placed by mounting the image on a different machine). Alternatively you
+must set a password for either `root` or `nixos` with `passwd` to be
+able to login.
+
+## Partitioning and formatting {#sec-installation-partitioning}
+
+The NixOS installer doesn't do any partitioning or formatting, so you
+need to do that yourself.
+
+The NixOS installer ships with multiple partitioning tools. The examples
+below use `parted`, but also provides `fdisk`, `gdisk`, `cfdisk`, and
+`cgdisk`.
+
+The recommended partition scheme differs depending if the computer uses
+*Legacy Boot* or *UEFI*.
+
+### UEFI (GPT) {#sec-installation-partitioning-UEFI}
+
+Here\'s an example partition scheme for UEFI, using `/dev/sda` as the
+device.
+
+::: {.note}
+You can safely ignore `parted`\'s informational message about needing to
+update /etc/fstab.
+:::
+
+1.  Create a *GPT* partition table.
+
+    ```ShellSession
+    # parted /dev/sda -- mklabel gpt
+    ```
+
+2.  Add the *root* partition. This will fill the disk except for the end
+    part, where the swap will live, and the space left in front (512MiB)
+    which will be used by the boot partition.
+
+    ```ShellSession
+    # parted /dev/sda -- mkpart primary 512MiB -8GiB
+    ```
+
+3.  Next, add a *swap* partition. The size required will vary according
+    to needs, here a 8GiB one is created.
+
+    ```ShellSession
+    # parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+    ```
+
+    ::: {.note}
+    The swap partition size rules are no different than for other Linux
+    distributions.
+    :::
+
+4.  Finally, the *boot* partition. NixOS by default uses the ESP (EFI
+    system partition) as its */boot* partition. It uses the initially
+    reserved 512MiB at the start of the disk.
+
+    ```ShellSession
+    # parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
+    # parted /dev/sda -- set 3 esp on
+    ```
+
+Once complete, you can follow with
+[](#sec-installation-partitioning-formatting).
+
+### Legacy Boot (MBR) {#sec-installation-partitioning-MBR}
+
+Here\'s an example partition scheme for Legacy Boot, using `/dev/sda` as
+the device.
+
+::: {.note}
+You can safely ignore `parted`\'s informational message about needing to
+update /etc/fstab.
+:::
+
+1.  Create a *MBR* partition table.
+
+    ```ShellSession
+    # parted /dev/sda -- mklabel msdos
+    ```
+
+2.  Add the *root* partition. This will fill the the disk except for the
+    end part, where the swap will live.
+
+    ```ShellSession
+    # parted /dev/sda -- mkpart primary 1MiB -8GiB
+    ```
+
+3.  Finally, add a *swap* partition. The size required will vary
+    according to needs, here a 8GiB one is created.
+
+    ```ShellSession
+    # parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+    ```
+
+    ::: {.note}
+    The swap partition size rules are no different than for other Linux
+    distributions.
+    :::
+
+Once complete, you can follow with
+[](#sec-installation-partitioning-formatting).
+
+### Formatting {#sec-installation-partitioning-formatting}
+
+Use the following commands:
+
+-   For initialising Ext4 partitions: `mkfs.ext4`. It is recommended
+    that you assign a unique symbolic label to the file system using the
+    option `-L label`, since this makes the file system configuration
+    independent from device changes. For example:
+
+    ```ShellSession
+    # mkfs.ext4 -L nixos /dev/sda1
+    ```
+
+-   For creating swap partitions: `mkswap`. Again it's recommended to
+    assign a label to the swap partition: `-L label`. For example:
+
+    ```ShellSession
+    # mkswap -L swap /dev/sda2
+    ```
+
+-   **UEFI systems**
+
+    For creating boot partitions: `mkfs.fat`. Again it's recommended
+    to assign a label to the boot partition: `-n label`. For
+    example:
+
+    ```ShellSession
+    # mkfs.fat -F 32 -n boot /dev/sda3
+    ```
+
+-   For creating LVM volumes, the LVM commands, e.g., `pvcreate`,
+    `vgcreate`, and `lvcreate`.
+
+-   For creating software RAID devices, use `mdadm`.
+
+## Installing {#sec-installation-installing}
+
+1.  Mount the target file system on which NixOS should be installed on
+    `/mnt`, e.g.
+
+    ```ShellSession
+    # mount /dev/disk/by-label/nixos /mnt
+    ```
+
+2.  **UEFI systems**
+
+    Mount the boot file system on `/mnt/boot`, e.g.
+
+    ```ShellSession
+    # mkdir -p /mnt/boot
+    # mount /dev/disk/by-label/boot /mnt/boot
+    ```
+
+3.  If your machine has a limited amount of memory, you may want to
+    activate swap devices now (`swapon device`).
+    The installer (or rather, the build actions that it
+    may spawn) may need quite a bit of RAM, depending on your
+    configuration.
+
+    ```ShellSession
+    # swapon /dev/sda2
+    ```
+
+4.  You now need to create a file `/mnt/etc/nixos/configuration.nix`
+    that specifies the intended configuration of the system. This is
+    because NixOS has a *declarative* configuration model: you create or
+    edit a description of the desired configuration of your system, and
+    then NixOS takes care of making it happen. The syntax of the NixOS
+    configuration file is described in [](#sec-configuration-syntax),
+    while a list of available configuration options appears in
+    [](#ch-options). A minimal example is shown in
+    [Example: NixOS Configuration](#ex-config).
+
+    The command `nixos-generate-config` can generate an initial
+    configuration file for you:
+
+    ```ShellSession
+    # nixos-generate-config --root /mnt
+    ```
+
+    You should then edit `/mnt/etc/nixos/configuration.nix` to suit your
+    needs:
+
+    ```ShellSession
+    # nano /mnt/etc/nixos/configuration.nix
+    ```
+
+    If you're using the graphical ISO image, other editors may be
+    available (such as `vim`). If you have network access, you can also
+    install other editors -- for instance, you can install Emacs by
+    running `nix-env -f '<nixpkgs>' -iA emacs`.
+
+    BIOS systems
+
+    :   You *must* set the option [](#opt-boot.loader.grub.device) to
+        specify on which disk the GRUB boot loader is to be installed.
+        Without it, NixOS cannot boot.
+
+    UEFI systems
+
+    :   You *must* set the option [](#opt-boot.loader.systemd-boot.enable)
+        to `true`. `nixos-generate-config` should do this automatically
+        for new configurations when booted in UEFI mode.
+
+        You may want to look at the options starting with
+        [`boot.loader.efi`](#opt-boot.loader.efi.canTouchEfiVariables) and
+        [`boot.loader.systemd-boot`](#opt-boot.loader.systemd-boot.enable)
+        as well.
+
+    If there are other operating systems running on the machine before
+    installing NixOS, the [](#opt-boot.loader.grub.useOSProber)
+    option can be set to `true` to automatically add them to the grub
+    menu.
+
+    If you need to configure networking for your machine the
+    configuration options are described in [](#sec-networking). In
+    particular, while wifi is supported on the installation image, it is
+    not enabled by default in the configuration generated by
+    `nixos-generate-config`.
+
+    Another critical option is `fileSystems`, specifying the file
+    systems that need to be mounted by NixOS. However, you typically
+    don't need to set it yourself, because `nixos-generate-config` sets
+    it automatically in `/mnt/etc/nixos/hardware-configuration.nix` from
+    your currently mounted file systems. (The configuration file
+    `hardware-configuration.nix` is included from `configuration.nix`
+    and will be overwritten by future invocations of
+    `nixos-generate-config`; thus, you generally should not modify it.)
+    Additionally, you may want to look at [Hardware configuration for
+    known-hardware](https://github.com/NixOS/nixos-hardware) at this
+    point or after installation.
+
+    ::: {.note}
+    Depending on your hardware configuration or type of file system, you
+    may need to set the option `boot.initrd.kernelModules` to include
+    the kernel modules that are necessary for mounting the root file
+    system, otherwise the installed system will not be able to boot. (If
+    this happens, boot from the installation media again, mount the
+    target file system on `/mnt`, fix `/mnt/etc/nixos/configuration.nix`
+    and rerun `nixos-install`.) In most cases, `nixos-generate-config`
+    will figure out the required modules.
+    :::
+
+5.  Do the installation:
+
+    ```ShellSession
+    # nixos-install
+    ```
+
+    This will install your system based on the configuration you
+    provided. If anything fails due to a configuration problem or any
+    other issue (such as a network outage while downloading binaries
+    from the NixOS binary cache), you can re-run `nixos-install` after
+    fixing your `configuration.nix`.
+
+    As the last step, `nixos-install` will ask you to set the password
+    for the `root` user, e.g.
+
+    ```plain
+    setting root password...
+    New password: ***
+    Retype new password: ***
+    ```
+
+    ::: {.note}
+    For unattended installations, it is possible to use
+    `nixos-install --no-root-passwd` in order to disable the password
+    prompt entirely.
+    :::
+
+6.  If everything went well:
+
+    ```ShellSession
+    # reboot
+    ```
+
+7.  You should now be able to boot into the installed NixOS. The GRUB
+    boot menu shows a list of *available configurations* (initially just
+    one). Every time you change the NixOS configuration (see [Changing
+    Configuration](#sec-changing-config)), a new item is added to the
+    menu. This allows you to easily roll back to a previous
+    configuration if something goes wrong.
+
+    You should log in and change the `root` password with `passwd`.
+
+    You'll probably want to create some user accounts as well, which can
+    be done with `useradd`:
+
+    ```ShellSession
+    $ useradd -c 'Eelco Dolstra' -m eelco
+    $ passwd eelco
+    ```
+
+    You may also want to install some software. This will be covered in
+    [](#sec-package-management).
+
+## Installation summary {#sec-installation-summary}
+
+To summarise, [Example: Commands for Installing NixOS on `/dev/sda`](#ex-install-sequence)
+shows a typical sequence of commands for installing NixOS on an empty hard
+drive (here `/dev/sda`). [Example: NixOS Configuration](#ex-config) shows a
+corresponding configuration Nix expression.
+
+::: {#ex-partition-scheme-MBR .example}
+::: {.title}
+**Example: Example partition schemes for NixOS on `/dev/sda` (MBR)**
+:::
+```ShellSession
+# parted /dev/sda -- mklabel msdos
+# parted /dev/sda -- mkpart primary 1MiB -8GiB
+# parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+```
+:::
+
+::: {#ex-partition-scheme-UEFI .example}
+::: {.title}
+**Example: Example partition schemes for NixOS on `/dev/sda` (UEFI)**
+:::
+```ShellSession
+# parted /dev/sda -- mklabel gpt
+# parted /dev/sda -- mkpart primary 512MiB -8GiB
+# parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
+# parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
+# parted /dev/sda -- set 3 esp on
+```
+:::
+
+::: {#ex-install-sequence .example}
+::: {.title}
+**Example: Commands for Installing NixOS on `/dev/sda`**
+:::
+With a partitioned disk.
+
+```ShellSession
+# mkfs.ext4 -L nixos /dev/sda1
+# mkswap -L swap /dev/sda2
+# swapon /dev/sda2
+# mkfs.fat -F 32 -n boot /dev/sda3        # (for UEFI systems only)
+# mount /dev/disk/by-label/nixos /mnt
+# mkdir -p /mnt/boot                      # (for UEFI systems only)
+# mount /dev/disk/by-label/boot /mnt/boot # (for UEFI systems only)
+# nixos-generate-config --root /mnt
+# nano /mnt/etc/nixos/configuration.nix
+# nixos-install
+# reboot
+```
+:::
+
+::: {#ex-config .example}
+::: {.title}
+**Example: NixOS Configuration**
+:::
+```ShellSession
+{ config, pkgs, ... }: {
+  imports = [
+    # Include the results of the hardware scan.
+    ./hardware-configuration.nix
+  ];
+
+  boot.loader.grub.device = "/dev/sda";   # (for BIOS systems only)
+  boot.loader.systemd-boot.enable = true; # (for UEFI systems only)
+
+  # Note: setting fileSystems is generally not
+  # necessary, since nixos-generate-config figures them out
+  # automatically in hardware-configuration.nix.
+  #fileSystems."/".device = "/dev/disk/by-label/nixos";
+
+  # Enable the OpenSSH server.
+  services.sshd.enable = true;
+}
+```
+:::
+
+## Additional installation notes {#sec-installation-additional-notes}
+
+```{=docbook}
+<xi:include href="installing-usb.section.xml" />
+<xi:include href="installing-pxe.section.xml" />
+<xi:include href="installing-virtualbox-guest.section.xml" />
+<xi:include href="installing-from-other-distro.section.xml" />
+<xi:include href="installing-behind-a-proxy.section.xml" />
+```
diff --git a/nixpkgs/nixos/doc/manual/installation/installing.xml b/nixpkgs/nixos/doc/manual/installation/installing.xml
deleted file mode 100644
index ff2425e725e8..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/installing.xml
+++ /dev/null
@@ -1,616 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-            xmlns:xlink="http://www.w3.org/1999/xlink"
-            xmlns:xi="http://www.w3.org/2001/XInclude"
-            version="5.0"
-            xml:id="sec-installation">
- <title>Installing NixOS</title>
- <section xml:id="sec-installation-booting">
-  <title>Booting the system</title>
-
-  <para>
-   NixOS can be installed on BIOS or UEFI systems. The procedure for a UEFI
-   installation is by and large the same as a BIOS installation. The
-   differences are mentioned in the steps that follow.
-  </para>
-
-  <para>
-   The installation media can be burned to a CD, or now more commonly, "burned"
-   to a USB drive (see <xref linkend="sec-booting-from-usb"/>).
-  </para>
-
-  <para>
-   The installation media contains a basic NixOS installation. When it’s
-   finished booting, it should have detected most of your hardware.
-  </para>
-
-  <para>
-   The NixOS manual is available by running <command>nixos-help</command>.
-  </para>
-
-  <para>
-   You are logged-in automatically as <literal>nixos</literal>.
-   The <literal>nixos</literal> user account has an empty password so you
-   can use <command>sudo</command> without a password.
-  </para>
-
-  <para>
-   If you downloaded the graphical ISO image, you can run <command>systemctl
-   start display-manager</command> to start the desktop environment. If you want to continue on the
-   terminal, you can use <command>loadkeys</command> to switch to your
-   preferred keyboard layout. (We even provide neo2 via <command>loadkeys de
-   neo</command>!)
-  </para>
-
-  <para>
-   If the text is too small to be legible, try <command>setfont ter-v32n</command>
-   to increase the font size.
-  </para>
-
-  <para>
-    To install over a serial port connect with <literal>115200n8</literal>
-    (e.g. <command>picocom -b 115200 /dev/ttyUSB0</command>). When the
-    bootloader lists boot entries, select the serial console boot entry.
-  </para>
-
-  <section xml:id="sec-installation-booting-networking">
-   <title>Networking in the installer</title>
-
-   <para>
-    The boot process should have brought up networking (check <command>ip
-    a</command>). Networking is necessary for the installer, since it will
-    download lots of stuff (such as source tarballs or Nixpkgs channel
-    binaries). It’s best if you have a DHCP server on your network. Otherwise
-    configure networking manually using <command>ifconfig</command>.
-   </para>
-
-   <para>
-    On the graphical installer, you can configure the network, wifi included,
-    through NetworkManager. Using the <command>nmtui</command> program, you
-    can do so even in a non-graphical session. If you prefer to configure the
-    network manually, disable NetworkManager with
-    <command>systemctl stop NetworkManager</command>.
-   </para>
-
-   <para>
-    On the minimal installer, NetworkManager is not available, so configuration
-    must be perfomed manually. To configure the wifi, first start wpa_supplicant
-    with <command>sudo systemctl start wpa_supplicant</command>, then run
-    <command>wpa_cli</command>. For most home networks, you need to type
-    in the following commands:
-    <programlisting>
-<prompt>&gt; </prompt>add_network
-0
-<prompt>&gt; </prompt>set_network 0 ssid "myhomenetwork"
-OK
-<prompt>&gt; </prompt>set_network 0 psk "mypassword"
-OK
-<prompt>&gt; </prompt>set_network 0 key_mgmt WPA-PSK
-OK
-<prompt>&gt; </prompt>enable_network 0
-OK
-    </programlisting>
-    For enterprise networks, for example <emphasis>eduroam</emphasis>, instead do:
-    <programlisting>
-<prompt>&gt; </prompt>add_network
-0
-<prompt>&gt; </prompt>set_network 0 ssid "eduroam"
-OK
-<prompt>&gt; </prompt>set_network 0 identity "myname@example.com"
-OK
-<prompt>&gt; </prompt>set_network 0 password "mypassword"
-OK
-<prompt>&gt; </prompt>set_network 0 key_mgmt WPA-EAP
-OK
-<prompt>&gt; </prompt>enable_network 0
-OK
-    </programlisting>
-    When successfully connected, you should see a line such as this one
-    <programlisting>
-&lt;3&gt;CTRL-EVENT-CONNECTED - Connection to 32:85:ab:ef:24:5c completed [id=0 id_str=]
-    </programlisting>
-    you can now leave <command>wpa_cli</command> by typing <command>quit</command>.
-   </para>
-
-   <para>
-    If you would like to continue the installation from a different machine you
-    can use activated SSH daemon. You need to copy your ssh key to either
-    <literal>/home/nixos/.ssh/authorized_keys</literal> or
-    <literal>/root/.ssh/authorized_keys</literal> (Tip: For installers with a
-    modifiable filesystem such as the sd-card installer image a key can be manually
-    placed by mounting the image on a different machine). Alternatively you must set
-    a password for either <literal>root</literal> or <literal>nixos</literal> with
-    <command>passwd</command> to be able to login.
-   </para>
-  </section>
- </section>
- <section xml:id="sec-installation-partitioning">
-  <title>Partitioning and formatting</title>
-
-  <para>
-   The NixOS installer doesn’t do any partitioning or formatting, so you need
-   to do that yourself.
-  </para>
-
-  <para>
-   The NixOS installer ships with multiple partitioning tools. The examples
-   below use <command>parted</command>, but also provides
-   <command>fdisk</command>, <command>gdisk</command>,
-   <command>cfdisk</command>, and <command>cgdisk</command>.
-  </para>
-
-  <para>
-   The recommended partition scheme differs depending if the computer uses
-   <emphasis>Legacy Boot</emphasis> or <emphasis>UEFI</emphasis>.
-  </para>
-
-  <section xml:id="sec-installation-partitioning-UEFI">
-   <title>UEFI (GPT)</title>
-
-   <para>
-    Here's an example partition scheme for UEFI, using
-    <filename>/dev/sda</filename> as the device.
-    <note>
-     <para>
-      You can safely ignore <command>parted</command>'s informational message
-      about needing to update /etc/fstab.
-     </para>
-    </note>
-   </para>
-
-   <para>
-    <orderedlist>
-     <listitem>
-      <para>
-       Create a <emphasis>GPT</emphasis> partition table.
-<screen language="commands"><prompt># </prompt>parted /dev/sda -- mklabel gpt</screen>
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       Add the <emphasis>root</emphasis> partition. This will fill the disk
-       except for the end part, where the swap will live, and the space left in
-       front (512MiB) which will be used by the boot partition.
-<screen language="commands"><prompt># </prompt>parted /dev/sda -- mkpart primary 512MiB -8GiB</screen>
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       Next, add a <emphasis>swap</emphasis> partition. The size required will
-       vary according to needs, here a 8GiB one is created.
-<screen language="commands"><prompt># </prompt>parted /dev/sda -- mkpart primary linux-swap -8GiB 100%</screen>
-       <note>
-        <para>
-         The swap partition size rules are no different than for other Linux
-         distributions.
-        </para>
-       </note>
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       Finally, the <emphasis>boot</emphasis> partition. NixOS by default uses
-       the ESP (EFI system partition) as its <emphasis>/boot</emphasis>
-       partition. It uses the initially reserved 512MiB at the start of the
-       disk.
-<screen language="commands"><prompt># </prompt>parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
-<prompt># </prompt>parted /dev/sda -- set 3 esp on</screen>
-      </para>
-     </listitem>
-    </orderedlist>
-   </para>
-
-   <para>
-    Once complete, you can follow with
-    <xref linkend="sec-installation-partitioning-formatting"/>.
-   </para>
-  </section>
-
-  <section xml:id="sec-installation-partitioning-MBR">
-   <title>Legacy Boot (MBR)</title>
-
-   <para>
-    Here's an example partition scheme for Legacy Boot, using
-    <filename>/dev/sda</filename> as the device.
-    <note>
-     <para>
-      You can safely ignore <command>parted</command>'s informational message
-      about needing to update /etc/fstab.
-     </para>
-    </note>
-   </para>
-
-   <para>
-    <orderedlist>
-     <listitem>
-      <para>
-       Create a <emphasis>MBR</emphasis> partition table.
-<screen language="commands"><prompt># </prompt>parted /dev/sda -- mklabel msdos</screen>
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       Add the <emphasis>root</emphasis> partition. This will fill the the disk
-       except for the end part, where the swap will live.
-<screen language="commands"><prompt># </prompt>parted /dev/sda -- mkpart primary 1MiB -8GiB</screen>
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       Finally, add a <emphasis>swap</emphasis> partition. The size required
-       will vary according to needs, here a 8GiB one is created.
-<screen language="commands"><prompt># </prompt>parted /dev/sda -- mkpart primary linux-swap -8GiB 100%</screen>
-       <note>
-        <para>
-         The swap partition size rules are no different than for other Linux
-         distributions.
-        </para>
-       </note>
-      </para>
-     </listitem>
-    </orderedlist>
-   </para>
-
-   <para>
-    Once complete, you can follow with
-    <xref linkend="sec-installation-partitioning-formatting"/>.
-   </para>
-  </section>
-
-  <section xml:id="sec-installation-partitioning-formatting">
-   <title>Formatting</title>
-
-   <para>
-    Use the following commands:
-    <itemizedlist>
-     <listitem>
-      <para>
-       For initialising Ext4 partitions: <command>mkfs.ext4</command>. It is
-       recommended that you assign a unique symbolic label to the file system
-       using the option <option>-L <replaceable>label</replaceable></option>,
-       since this makes the file system configuration independent from device
-       changes. For example:
-<screen>
-<prompt># </prompt>mkfs.ext4 -L nixos /dev/sda1</screen>
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       For creating swap partitions: <command>mkswap</command>. Again it’s
-       recommended to assign a label to the swap partition: <option>-L
-       <replaceable>label</replaceable></option>. For example:
-<screen>
-<prompt># </prompt>mkswap -L swap /dev/sda2</screen>
-      </para>
-     </listitem>
-     <listitem>
-      <variablelist>
-       <varlistentry>
-        <term>
-         UEFI systems
-        </term>
-        <listitem>
-         <para>
-          For creating boot partitions: <command>mkfs.fat</command>. Again
-          it’s recommended to assign a label to the boot partition:
-          <option>-n <replaceable>label</replaceable></option>. For example:
-<screen>
-<prompt># </prompt>mkfs.fat -F 32 -n boot /dev/sda3</screen>
-         </para>
-        </listitem>
-       </varlistentry>
-      </variablelist>
-     </listitem>
-     <listitem>
-      <para>
-       For creating LVM volumes, the LVM commands, e.g.,
-       <command>pvcreate</command>, <command>vgcreate</command>, and
-       <command>lvcreate</command>.
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       For creating software RAID devices, use <command>mdadm</command>.
-      </para>
-     </listitem>
-    </itemizedlist>
-   </para>
-  </section>
- </section>
- <section xml:id="sec-installation-installing">
-  <title>Installing</title>
-
-  <orderedlist>
-   <listitem>
-    <para>
-     Mount the target file system on which NixOS should be installed on
-     <filename>/mnt</filename>, e.g.
-<screen>
-<prompt># </prompt>mount /dev/disk/by-label/nixos /mnt
-</screen>
-    </para>
-   </listitem>
-   <listitem>
-    <variablelist>
-     <varlistentry>
-      <term>
-       UEFI systems
-      </term>
-      <listitem>
-       <para>
-        Mount the boot file system on <filename>/mnt/boot</filename>, e.g.
-<screen>
-<prompt># </prompt>mkdir -p /mnt/boot
-<prompt># </prompt>mount /dev/disk/by-label/boot /mnt/boot
-</screen>
-       </para>
-      </listitem>
-     </varlistentry>
-    </variablelist>
-   </listitem>
-   <listitem>
-    <para>
-     If your machine has a limited amount of memory, you may want to activate
-     swap devices now (<command>swapon
-     <replaceable>device</replaceable></command>). The installer (or rather,
-     the build actions that it may spawn) may need quite a bit of RAM,
-     depending on your configuration.
-<screen>
-<prompt># </prompt>swapon /dev/sda2</screen>
-    </para>
-   </listitem>
-   <listitem>
-    <para>
-     You now need to create a file
-     <filename>/mnt/etc/nixos/configuration.nix</filename> that specifies the
-     intended configuration of the system. This is because NixOS has a
-     <emphasis>declarative</emphasis> configuration model: you create or edit a
-     description of the desired configuration of your system, and then NixOS
-     takes care of making it happen. The syntax of the NixOS configuration file
-     is described in <xref linkend="sec-configuration-syntax"/>, while a list
-     of available configuration options appears in
-     <xref
-    linkend="ch-options"/>. A minimal example is shown in
-     <xref
-    linkend="ex-config"/>.
-    </para>
-    <para>
-     The command <command>nixos-generate-config</command> can generate an
-     initial configuration file for you:
-<screen>
-<prompt># </prompt>nixos-generate-config --root /mnt</screen>
-     You should then edit <filename>/mnt/etc/nixos/configuration.nix</filename>
-     to suit your needs:
-<screen>
-<prompt># </prompt>nano /mnt/etc/nixos/configuration.nix
-</screen>
-     If you’re using the graphical ISO image, other editors may be available
-     (such as <command>vim</command>). If you have network access, you can also
-     install other editors — for instance, you can install Emacs by running
-     <literal>nix-env -f '&lt;nixpkgs&gt;' -iA emacs</literal>.
-    </para>
-    <variablelist>
-     <varlistentry>
-      <term>
-       BIOS systems
-      </term>
-      <listitem>
-       <para>
-        You <emphasis>must</emphasis> set the option
-        <xref linkend="opt-boot.loader.grub.device"/> to specify on which disk
-        the GRUB boot loader is to be installed. Without it, NixOS cannot boot.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry>
-      <term>
-       UEFI systems
-      </term>
-      <listitem>
-       <para>
-        You <emphasis>must</emphasis> set the option
-        <xref linkend="opt-boot.loader.systemd-boot.enable"/> to
-        <literal>true</literal>. <command>nixos-generate-config</command>
-        should do this automatically for new configurations when booted in UEFI
-        mode.
-       </para>
-       <para>
-        You may want to look at the options starting with
-        <option><link linkend="opt-boot.loader.efi.canTouchEfiVariables">boot.loader.efi</link></option>
-        and
-        <option><link linkend="opt-boot.loader.systemd-boot.enable">boot.loader.systemd-boot</link></option>
-        as well.
-       </para>
-      </listitem>
-     </varlistentry>
-    </variablelist>
-    <para>
-     If there are other operating systems running on the machine before
-     installing NixOS, the <xref linkend="opt-boot.loader.grub.useOSProber"/>
-     option can be set to <literal>true</literal> to automatically add them to
-     the grub menu.
-    </para>
-    <para>
-     If you need to configure networking for your machine the configuration
-     options are described in <xref linkend="sec-networking"/>. In particular,
-     while wifi is supported on the installation image, it is not enabled by
-     default in the configuration generated by
-     <command>nixos-generate-config</command>.
-    </para>
-    <para>
-     Another critical option is <option>fileSystems</option>, specifying the
-     file systems that need to be mounted by NixOS. However, you typically
-     don’t need to set it yourself, because
-     <command>nixos-generate-config</command> sets it automatically in
-     <filename>/mnt/etc/nixos/hardware-configuration.nix</filename> from your
-     currently mounted file systems. (The configuration file
-     <filename>hardware-configuration.nix</filename> is included from
-     <filename>configuration.nix</filename> and will be overwritten by future
-     invocations of <command>nixos-generate-config</command>; thus, you
-     generally should not modify it.) Additionally, you may want to look at
-     <link xlink:href="https://github.com/NixOS/nixos-hardware">Hardware
-     configuration for known-hardware</link> at this point or after
-     installation.
-
-    </para>
-    <note>
-     <para>
-      Depending on your hardware configuration or type of file system, you may
-      need to set the option <option>boot.initrd.kernelModules</option> to
-      include the kernel modules that are necessary for mounting the root file
-      system, otherwise the installed system will not be able to boot. (If this
-      happens, boot from the installation media again, mount the target file
-      system on <filename>/mnt</filename>, fix
-      <filename>/mnt/etc/nixos/configuration.nix</filename> and rerun
-      <filename>nixos-install</filename>.) In most cases,
-      <command>nixos-generate-config</command> will figure out the required
-      modules.
-     </para>
-    </note>
-   </listitem>
-   <listitem>
-    <para>
-     Do the installation:
-<screen>
-<prompt># </prompt>nixos-install</screen>
-     This will install your system based on the configuration you provided.
-     If anything fails due to a configuration problem or any other issue
-     (such as a network outage while downloading binaries from the NixOS
-     binary cache), you can re-run <command>nixos-install</command> after
-     fixing your <filename>configuration.nix</filename>.
-    </para>
-    <para>
-     As the last step, <command>nixos-install</command> will ask you to set the
-     password for the <literal>root</literal> user, e.g.
-<screen>
-setting root password...
-New password: ***
-Retype new password: ***</screen>
-     <note>
-      <para>
-       For unattended installations, it is possible to use
-       <command>nixos-install --no-root-passwd</command> in order to disable
-       the password prompt entirely.
-      </para>
-     </note>
-    </para>
-   </listitem>
-   <listitem>
-    <para>
-     If everything went well:
-<screen>
-<prompt># </prompt>reboot</screen>
-    </para>
-   </listitem>
-   <listitem>
-    <para>
-     You should now be able to boot into the installed NixOS. The GRUB boot
-     menu shows a list of <emphasis>available configurations</emphasis>
-     (initially just one). Every time you change the NixOS configuration (see
-     <link
-        linkend="sec-changing-config">Changing Configuration</link>
-     ), a new item is added to the menu. This allows you to easily roll back to
-     a previous configuration if something goes wrong.
-    </para>
-    <para>
-     You should log in and change the <literal>root</literal> password with
-     <command>passwd</command>.
-    </para>
-    <para>
-     You’ll probably want to create some user accounts as well, which can be
-     done with <command>useradd</command>:
-<screen>
-<prompt>$ </prompt>useradd -c 'Eelco Dolstra' -m eelco
-<prompt>$ </prompt>passwd eelco</screen>
-    </para>
-    <para>
-     You may also want to install some software. This will be covered
-     in <xref linkend="sec-package-management" />.
-    </para>
-   </listitem>
-  </orderedlist>
- </section>
- <section xml:id="sec-installation-summary">
-  <title>Installation summary</title>
-
-  <para>
-   To summarise, <xref linkend="ex-install-sequence" /> shows a typical
-   sequence of commands for installing NixOS on an empty hard drive (here
-   <filename>/dev/sda</filename>). <xref linkend="ex-config"
-/> shows a
-   corresponding configuration Nix expression.
-  </para>
-
-  <example xml:id="ex-partition-scheme-MBR">
-   <title>Example partition schemes for NixOS on <filename>/dev/sda</filename> (MBR)</title>
-<screen language="commands">
-<prompt># </prompt>parted /dev/sda -- mklabel msdos
-<prompt># </prompt>parted /dev/sda -- mkpart primary 1MiB -8GiB
-<prompt># </prompt>parted /dev/sda -- mkpart primary linux-swap -8GiB 100%</screen>
-  </example>
-
-  <example xml:id="ex-partition-scheme-UEFI">
-   <title>Example partition schemes for NixOS on <filename>/dev/sda</filename> (UEFI)</title>
-<screen language="commands">
-<prompt># </prompt>parted /dev/sda -- mklabel gpt
-<prompt># </prompt>parted /dev/sda -- mkpart primary 512MiB -8GiB
-<prompt># </prompt>parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
-<prompt># </prompt>parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
-<prompt># </prompt>parted /dev/sda -- set 3 esp on</screen>
-  </example>
-
-  <example xml:id="ex-install-sequence">
-   <title>Commands for Installing NixOS on <filename>/dev/sda</filename></title>
-   <para>
-    With a partitioned disk.
-<screen language="commands">
-<prompt># </prompt>mkfs.ext4 -L nixos /dev/sda1
-<prompt># </prompt>mkswap -L swap /dev/sda2
-<prompt># </prompt>swapon /dev/sda2
-<prompt># </prompt>mkfs.fat -F 32 -n boot /dev/sda3        # <lineannotation>(for UEFI systems only)</lineannotation>
-<prompt># </prompt>mount /dev/disk/by-label/nixos /mnt
-<prompt># </prompt>mkdir -p /mnt/boot                      # <lineannotation>(for UEFI systems only)</lineannotation>
-<prompt># </prompt>mount /dev/disk/by-label/boot /mnt/boot # <lineannotation>(for UEFI systems only)</lineannotation>
-<prompt># </prompt>nixos-generate-config --root /mnt
-<prompt># </prompt>nano /mnt/etc/nixos/configuration.nix
-<prompt># </prompt>nixos-install
-<prompt># </prompt>reboot</screen>
-   </para>
-  </example>
-
-  <example xml:id='ex-config'>
-   <title>NixOS Configuration</title>
-<programlisting>
-{ config, pkgs, ... }: {
-  imports = [
-    # Include the results of the hardware scan.
-    ./hardware-configuration.nix
-  ];
-
-  <xref linkend="opt-boot.loader.grub.device"/> = "/dev/sda";   # <lineannotation>(for BIOS systems only)</lineannotation>
-  <xref linkend="opt-boot.loader.systemd-boot.enable"/> = true; # <lineannotation>(for UEFI systems only)</lineannotation>
-
-  # Note: setting fileSystems is generally not
-  # necessary, since nixos-generate-config figures them out
-  # automatically in hardware-configuration.nix.
-  #<link linkend="opt-fileSystems._name_.device">fileSystems."/".device</link> = "/dev/disk/by-label/nixos";
-
-  # Enable the OpenSSH server.
-  services.sshd.enable = true;
-}
-</programlisting>
-  </example>
- </section>
- <section xml:id="sec-installation-additional-notes">
-  <title>Additional installation notes</title>
-
-  <xi:include href="installing-usb.xml" />
-
-  <xi:include href="installing-pxe.xml" />
-
-  <xi:include href="installing-virtualbox-guest.xml" />
-
-  <xi:include href="installing-from-other-distro.xml" />
-
-  <xi:include href="installing-behind-a-proxy.xml" />
- </section>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/installation/obtaining.chapter.md b/nixpkgs/nixos/doc/manual/installation/obtaining.chapter.md
new file mode 100644
index 000000000000..832ec6146a9d
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/obtaining.chapter.md
@@ -0,0 +1,26 @@
+# Obtaining NixOS {#sec-obtaining}
+
+NixOS ISO images can be downloaded from the [NixOS download
+page](https://nixos.org/nixos/download.html). There are a number of
+installation options. If you happen to have an optical drive and a spare
+CD, burning the image to CD and booting from that is probably the
+easiest option. Most people will need to prepare a USB stick to boot
+from. [](#sec-booting-from-usb) describes the preferred method to
+prepare a USB stick. A number of alternative methods are presented in
+the [NixOS Wiki](https://nixos.wiki/wiki/NixOS_Installation_Guide#Making_the_installation_media).
+
+As an alternative to installing NixOS yourself, you can get a running
+NixOS system through several other means:
+
+-   Using virtual appliances in Open Virtualization Format (OVF) that
+    can be imported into VirtualBox. These are available from the [NixOS
+    download page](https://nixos.org/nixos/download.html).
+
+-   Using AMIs for Amazon's EC2. To find one for your region and
+    instance type, please refer to the [list of most recent
+    AMIs](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/ec2-amis.nix).
+
+-   Using NixOps, the NixOS-based cloud deployment tool, which allows
+    you to provision VirtualBox and EC2 NixOS instances from declarative
+    specifications. Check out the [NixOps
+    homepage](https://nixos.org/nixops) for details.
diff --git a/nixpkgs/nixos/doc/manual/installation/obtaining.xml b/nixpkgs/nixos/doc/manual/installation/obtaining.xml
deleted file mode 100644
index 3b8671782ded..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/obtaining.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         version="5.0"
-         xml:id="sec-obtaining">
- <title>Obtaining NixOS</title>
- <para>
-  NixOS ISO images can be downloaded from the
-  <link
-xlink:href="https://nixos.org/nixos/download.html">NixOS download
-  page</link>. There are a number of installation options. If you happen to
-  have an optical drive and a spare CD, burning the image to CD and booting
-  from that is probably the easiest option. Most people will need to prepare a
-  USB stick to boot from. <xref linkend="sec-booting-from-usb"/> describes the
-  preferred method to prepare a USB stick. A number of alternative methods are
-  presented in the
-  <link
-xlink:href="https://nixos.wiki/wiki/NixOS_Installation_Guide#Making_the_installation_media">NixOS
-  Wiki</link>.
- </para>
- <para>
-  As an alternative to installing NixOS yourself, you can get a running NixOS
-  system through several other means:
-  <itemizedlist>
-   <listitem>
-    <para>
-     Using virtual appliances in Open Virtualization Format (OVF) that can be
-     imported into VirtualBox. These are available from the
-     <link xlink:href="https://nixos.org/nixos/download.html">NixOS download
-     page</link>.
-    </para>
-   </listitem>
-   <listitem>
-    <para>
-     Using AMIs for Amazon’s EC2. To find one for your region and instance
-     type, please refer to the
-     <link
-    xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/ec2-amis.nix">list
-     of most recent AMIs</link>.
-    </para>
-   </listitem>
-   <listitem>
-    <para>
-     Using NixOps, the NixOS-based cloud deployment tool, which allows you to
-     provision VirtualBox and EC2 NixOS instances from declarative
-     specifications. Check out the
-     <link
-    xlink:href="https://nixos.org/nixops">NixOps homepage</link> for
-     details.
-    </para>
-   </listitem>
-  </itemizedlist>
- </para>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/installation/upgrading.chapter.md b/nixpkgs/nixos/doc/manual/installation/upgrading.chapter.md
new file mode 100644
index 000000000000..b7903b9d3cbb
--- /dev/null
+++ b/nixpkgs/nixos/doc/manual/installation/upgrading.chapter.md
@@ -0,0 +1,118 @@
+# Upgrading NixOS {#sec-upgrading}
+
+The best way to keep your NixOS installation up to date is to use one of
+the NixOS *channels*. A channel is a Nix mechanism for distributing Nix
+expressions and associated binaries. The NixOS channels are updated
+automatically from NixOS's Git repository after certain tests have
+passed and all packages have been built. These channels are:
+
+-   *Stable channels*, such as [`nixos-21.05`](https://nixos.org/channels/nixos-21.05).
+    These only get conservative bug fixes and package upgrades. For
+    instance, a channel update may cause the Linux kernel on your system
+    to be upgraded from 4.19.34 to 4.19.38 (a minor bug fix), but not
+    from 4.19.x to 4.20.x (a major change that has the potential to break things).
+    Stable channels are generally maintained until the next stable
+    branch is created.
+
+-   The *unstable channel*, [`nixos-unstable`](https://nixos.org/channels/nixos-unstable).
+    This corresponds to NixOS's main development branch, and may thus see
+    radical changes between channel updates. It's not recommended for
+    production systems.
+
+-   *Small channels*, such as [`nixos-21.05-small`](https://nixos.org/channels/nixos-21.05-small)
+    or [`nixos-unstable-small`](https://nixos.org/channels/nixos-unstable-small).
+    These are identical to the stable and unstable channels described above,
+    except that they contain fewer binary packages. This means they get updated
+    faster than the regular channels (for instance, when a critical security patch
+    is committed to NixOS's source tree), but may require more packages to be
+    built from source than usual. They're mostly intended for server environments
+    and as such contain few GUI applications.
+
+To see what channels are available, go to <https://nixos.org/channels>.
+(Note that the URIs of the various channels redirect to a directory that
+contains the channel's latest version and includes ISO images and
+VirtualBox appliances.) Please note that during the release process,
+channels that are not yet released will be present here as well. See the
+Getting NixOS page <https://nixos.org/nixos/download.html> to find the
+newest supported stable release.
+
+When you first install NixOS, you're automatically subscribed to the
+NixOS channel that corresponds to your installation source. For
+instance, if you installed from a 21.05 ISO, you will be subscribed to
+the `nixos-21.05` channel. To see which NixOS channel you're subscribed
+to, run the following as root:
+
+```ShellSession
+# nix-channel --list | grep nixos
+nixos https://nixos.org/channels/nixos-unstable
+```
+
+To switch to a different NixOS channel, do
+
+```ShellSession
+# nix-channel --add https://nixos.org/channels/channel-name nixos
+```
+
+(Be sure to include the `nixos` parameter at the end.) For instance, to
+use the NixOS 21.05 stable channel:
+
+```ShellSession
+# nix-channel --add https://nixos.org/channels/nixos-21.05 nixos
+```
+
+If you have a server, you may want to use the "small" channel instead:
+
+```ShellSession
+# nix-channel --add https://nixos.org/channels/nixos-21.05-small nixos
+```
+
+And if you want to live on the bleeding edge:
+
+```ShellSession
+# nix-channel --add https://nixos.org/channels/nixos-unstable nixos
+```
+
+You can then upgrade NixOS to the latest version in your chosen channel
+by running
+
+```ShellSession
+# nixos-rebuild switch --upgrade
+```
+
+which is equivalent to the more verbose `nix-channel --update nixos; nixos-rebuild switch`.
+
+::: {.note}
+Channels are set per user. This means that running `nix-channel --add`
+as a non root user (or without sudo) will not affect
+configuration in `/etc/nixos/configuration.nix`
+:::
+
+::: {.warning}
+It is generally safe to switch back and forth between channels. The only
+exception is that a newer NixOS may also have a newer Nix version, which
+may involve an upgrade of Nix's database schema. This cannot be undone
+easily, so in that case you will not be able to go back to your original
+channel.
+:::
+
+## Automatic Upgrades {#sec-upgrading-automatic}
+
+You can keep a NixOS system up-to-date automatically by adding the
+following to `configuration.nix`:
+
+```nix
+system.autoUpgrade.enable = true;
+system.autoUpgrade.allowReboot = true;
+```
+
+This enables a periodically executed systemd service named
+`nixos-upgrade.service`. If the `allowReboot` option is `false`, it runs
+`nixos-rebuild switch --upgrade` to upgrade NixOS to the latest version
+in the current channel. (To see when the service runs, see `systemctl list-timers`.)
+If `allowReboot` is `true`, then the system will automatically reboot if
+the new generation contains a different kernel, initrd or kernel
+modules. You can also specify a channel explicitly, e.g.
+
+```nix
+system.autoUpgrade.channel = https://nixos.org/channels/nixos-21.05;
+```
diff --git a/nixpkgs/nixos/doc/manual/installation/upgrading.xml b/nixpkgs/nixos/doc/manual/installation/upgrading.xml
deleted file mode 100644
index 960d4fa9a436..000000000000
--- a/nixpkgs/nixos/doc/manual/installation/upgrading.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         version="5.0"
-         xml:id="sec-upgrading">
- <title>Upgrading NixOS</title>
- <para>
-  The best way to keep your NixOS installation up to date is to use one of the
-  NixOS <emphasis>channels</emphasis>. A channel is a Nix mechanism for
-  distributing Nix expressions and associated binaries. The NixOS channels are
-  updated automatically from NixOS’s Git repository after certain tests have
-  passed and all packages have been built. These channels are:
-  <itemizedlist>
-   <listitem>
-    <para>
-     <emphasis>Stable channels</emphasis>, such as
-     <literal
-    xlink:href="https://nixos.org/channels/nixos-21.05">nixos-21.05</literal>.
-     These only get conservative bug fixes and package upgrades. For instance,
-     a channel update may cause the Linux kernel on your system to be upgraded
-     from 4.19.34 to 4.19.38 (a minor bug fix), but not from
-     4.19.<replaceable>x</replaceable> to 4.20.<replaceable>x</replaceable> (a
-     major change that has the potential to break things). Stable channels are
-     generally maintained until the next stable branch is created.
-    </para>
-    <para></para>
-   </listitem>
-   <listitem>
-    <para>
-     The <emphasis>unstable channel</emphasis>,
-     <literal
-    xlink:href="https://nixos.org/channels/nixos-unstable">nixos-unstable</literal>.
-     This corresponds to NixOS’s main development branch, and may thus see
-     radical changes between channel updates. It’s not recommended for
-     production systems.
-    </para>
-   </listitem>
-   <listitem>
-    <para>
-     <emphasis>Small channels</emphasis>, such as
-     <literal
-    xlink:href="https://nixos.org/channels/nixos-21.05-small">nixos-21.05-small</literal>
-     or
-     <literal
-    xlink:href="https://nixos.org/channels/nixos-unstable-small">nixos-unstable-small</literal>.
-     These are identical to the stable and unstable channels described above,
-     except that they contain fewer binary packages. This means they get
-     updated faster than the regular channels (for instance, when a critical
-     security patch is committed to NixOS’s source tree), but may require
-     more packages to be built from source than usual. They’re mostly
-     intended for server environments and as such contain few GUI applications.
-    </para>
-   </listitem>
-  </itemizedlist>
-  To see what channels are available, go to
-  <link xlink:href="https://nixos.org/channels"/>. (Note that the URIs of the
-  various channels redirect to a directory that contains the channel’s latest
-  version and includes ISO images and VirtualBox appliances.) Please note that
-  during the release process, channels that are not yet released will be
-  present here as well. See the Getting NixOS page
-  <link xlink:href="https://nixos.org/nixos/download.html"/> to find the newest
-  supported stable release.
- </para>
- <para>
-  When you first install NixOS, you’re automatically subscribed to the NixOS
-  channel that corresponds to your installation source. For instance, if you
-  installed from a 21.05 ISO, you will be subscribed to the
-  <literal>nixos-21.05</literal> channel. To see which NixOS channel you’re
-  subscribed to, run the following as root:
-<screen>
-<prompt># </prompt>nix-channel --list | grep nixos
-nixos https://nixos.org/channels/nixos-unstable
-</screen>
-  To switch to a different NixOS channel, do
-<screen>
-<prompt># </prompt>nix-channel --add https://nixos.org/channels/<replaceable>channel-name</replaceable> nixos
-</screen>
-  (Be sure to include the <literal>nixos</literal> parameter at the end.) For
-  instance, to use the NixOS 21.05 stable channel:
-<screen>
-<prompt># </prompt>nix-channel --add https://nixos.org/channels/nixos-21.05 nixos
-</screen>
-  If you have a server, you may want to use the “small” channel instead:
-<screen>
-<prompt># </prompt>nix-channel --add https://nixos.org/channels/nixos-21.05-small nixos
-</screen>
-  And if you want to live on the bleeding edge:
-<screen>
-<prompt># </prompt>nix-channel --add https://nixos.org/channels/nixos-unstable nixos
-</screen>
- </para>
- <para>
-  You can then upgrade NixOS to the latest version in your chosen channel by
-  running
-<screen>
-<prompt># </prompt>nixos-rebuild switch --upgrade
-</screen>
-  which is equivalent to the more verbose <literal>nix-channel --update nixos;
-  nixos-rebuild switch</literal>.
- </para>
- <note>
-  <para>
-   Channels are set per user. This means that running <literal> nix-channel
-   --add</literal> as a non root user (or without sudo) will not affect
-   configuration in <literal>/etc/nixos/configuration.nix</literal>
-  </para>
- </note>
- <warning>
-  <para>
-   It is generally safe to switch back and forth between channels. The only
-   exception is that a newer NixOS may also have a newer Nix version, which may
-   involve an upgrade of Nix’s database schema. This cannot be undone easily,
-   so in that case you will not be able to go back to your original channel.
-  </para>
- </warning>
- <section xml:id="sec-upgrading-automatic">
-  <title>Automatic Upgrades</title>
-
-  <para>
-   You can keep a NixOS system up-to-date automatically by adding the following
-   to <filename>configuration.nix</filename>:
-<programlisting>
-<xref linkend="opt-system.autoUpgrade.enable"/> = true;
-<xref linkend="opt-system.autoUpgrade.allowReboot"/> = true;
-</programlisting>
-   This enables a periodically executed systemd service named
-   <literal>nixos-upgrade.service</literal>. If the <literal>allowReboot</literal>
-   option is <literal>false</literal>, it runs <command>nixos-rebuild switch
-   --upgrade</command> to upgrade NixOS to the latest version in the current
-   channel. (To see when the service runs, see <command>systemctl list-timers</command>.)
-   If <literal>allowReboot</literal> is <literal>true</literal>, then the
-   system will automatically reboot if the new generation contains a different
-   kernel, initrd or kernel modules.
-   You can also specify a channel explicitly, e.g.
-<programlisting>
-<xref linkend="opt-system.autoUpgrade.channel"/> = https://nixos.org/channels/nixos-21.05;
-</programlisting>
-  </para>
- </section>
-</chapter>
diff --git a/nixpkgs/nixos/doc/manual/man-nixos-rebuild.xml b/nixpkgs/nixos/doc/manual/man-nixos-rebuild.xml
index 8c34ea7458e6..0e0ea5d74b0b 100644
--- a/nixpkgs/nixos/doc/manual/man-nixos-rebuild.xml
+++ b/nixpkgs/nixos/doc/manual/man-nixos-rebuild.xml
@@ -553,6 +553,22 @@
 
    <varlistentry>
     <term>
+     <option>--use-substitutes</option>
+    </term>
+    <listitem>
+     <para>
+       When set, nixos-rebuild will add <option>--use-substitutes</option>
+       to each invocation of nix-copy-closure. This will only affect the
+       behavior of nixos-rebuild if <option>--target-host</option> or
+       <option>--build-host</option> is also set. This is useful when
+       the target-host connection to cache.nixos.org is faster than the
+       connection between hosts.
+     </para>
+    </listitem>
+   </varlistentry>
+
+   <varlistentry>
+    <term>
      <option>--use-remote-sudo</option>
     </term>
     <listitem>
diff --git a/nixpkgs/nixos/doc/manual/md-to-db.sh b/nixpkgs/nixos/doc/manual/md-to-db.sh
index 7949b42e8d81..6dd4b8c6e419 100755
--- a/nixpkgs/nixos/doc/manual/md-to-db.sh
+++ b/nixpkgs/nixos/doc/manual/md-to-db.sh
@@ -12,8 +12,14 @@ pushd $DIR
 # TODO: Remove raw-attribute when we can get rid of DocBook altogether.
 pandoc_commonmark_enabled_extensions=+attributes+fenced_divs+footnotes+bracketed_spans+definition_lists+pipe_tables+raw_attribute
 pandoc_flags=(
-  # media extraction and diagram-generator.lua not needed
-  "--lua-filter=$DIR/../../../doc/labelless-link-is-xref.lua"
+  # Not needed:
+  # - diagram-generator.lua (we do not support that in NixOS manual to limit dependencies)
+  # - media extraction (was only required for diagram generator)
+  # - docbook-reader/citerefentry-to-rst-role.lua (only relevant for DocBook → MarkDown/rST/MyST)
+  "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua"
+  "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/link-unix-man-references.lua"
+  "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua"
+  "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/docbook-writer/labelless-link-is-xref.lua"
   -f "commonmark${pandoc_commonmark_enabled_extensions}+smart"
   -t docbook
 )
@@ -24,15 +30,19 @@ mapfile -t MD_FILES < <(find . -type f -regex '.*\.md$')
 for mf in ${MD_FILES[*]}; do
   if [ "${mf: -11}" == ".section.md" ]; then
     mkdir -p $(dirname "$OUT/$mf")
+    OUTFILE="$OUT/${mf%".section.md"}.section.xml"
     pandoc "$mf" "${pandoc_flags[@]}" \
-      -o "$OUT/${mf%".section.md"}.section.xml"
+      -o "$OUTFILE"
+    grep -q -m 1 "xi:include" "$OUTFILE" && sed -i 's|xmlns:xlink="http://www.w3.org/1999/xlink"| xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"|' "$OUTFILE"
   fi
 
   if [ "${mf: -11}" == ".chapter.md" ]; then
     mkdir -p $(dirname "$OUT/$mf")
+    OUTFILE="$OUT/${mf%".chapter.md"}.chapter.xml"
     pandoc "$mf" "${pandoc_flags[@]}" \
       --top-level-division=chapter \
-      -o "$OUT/${mf%".chapter.md"}.chapter.xml"
+      -o "$OUTFILE"
+    grep -q -m 1 "xi:include" "$OUTFILE" && sed -i 's|xmlns:xlink="http://www.w3.org/1999/xlink"| xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"|' "$OUTFILE"
   fi
 done
 
diff --git a/nixpkgs/nixos/doc/manual/release-notes/rl-2009.section.md b/nixpkgs/nixos/doc/manual/release-notes/rl-2009.section.md
index 48059ab07f5e..79be2a56a54e 100644
--- a/nixpkgs/nixos/doc/manual/release-notes/rl-2009.section.md
+++ b/nixpkgs/nixos/doc/manual/release-notes/rl-2009.section.md
@@ -578,7 +578,9 @@ When upgrading from a previous release, please be aware of the following incompa
 
 - `services.journald.rateLimitBurst` was updated from `1000` to `10000` to follow the new upstream systemd default.
 
-- The notmuch package move its emacs-related binaries and emacs lisp files to a separate output. They\'re not part of the default `out` output anymore - if you relied on the `notmuch-emacs-mua` binary or the emacs lisp files, access them via the `notmuch.emacs` output. Device tree overlay support was improved in [\#79370](https://github.com/NixOS/nixpkgs/pull/79370) and now uses [hardware.deviceTree.kernelPackage](options.html#opt-hardware.deviceTree.kernelPackage) instead of `hardware.deviceTree.base`. [hardware.deviceTree.overlays](options.html#opt-hardware.deviceTree.overlays) configuration was extended to support `.dts` files with symbols. Device trees can now be filtered by setting [hardware.deviceTree.filter](options.html#opt-hardware.deviceTree.filter) option.
+- The notmuch package moves its emacs-related binaries and emacs lisp files to a separate output. They\'re not part of the default `out` output anymore - if you relied on the `notmuch-emacs-mua` binary or the emacs lisp files, access them via the `notmuch.emacs` output.
+
+- Device tree overlay support was improved in [\#79370](https://github.com/NixOS/nixpkgs/pull/79370) and now uses [hardware.deviceTree.kernelPackage](options.html#opt-hardware.deviceTree.kernelPackage) instead of `hardware.deviceTree.base`. [hardware.deviceTree.overlays](options.html#opt-hardware.deviceTree.overlays) configuration was extended to support `.dts` files with symbols. Device trees can now be filtered by setting [hardware.deviceTree.filter](options.html#opt-hardware.deviceTree.filter) option.
 
 - The default output of `buildGoPackage` is now `$out` instead of `$bin`.
 
diff --git a/nixpkgs/nixos/doc/manual/release-notes/rl-2111.section.md b/nixpkgs/nixos/doc/manual/release-notes/rl-2111.section.md
index 3df77d21d827..3dc15449c772 100644
--- a/nixpkgs/nixos/doc/manual/release-notes/rl-2111.section.md
+++ b/nixpkgs/nixos/doc/manual/release-notes/rl-2111.section.md
@@ -14,6 +14,10 @@ In addition to numerous new and upgraded packages, this release has the followin
 
 - PostgreSQL now defaults to major version 13.
 
+- Activation scripts can now opt int to be run when running `nixos-rebuild dry-activate` and detect the dry activation by reading `$NIXOS_ACTION`.
+  This allows activation scripts to output what they would change if the activation was really run.
+  The users/modules activation script supports this and outputs some of is actions.
+
 ## New Services {#sec-release-21.11-new-services}
 
 - [btrbk](https://digint.ch/btrbk/index.html), a backup tool for btrfs subvolumes, taking advantage of btrfs specific capabilities to create atomic snapshots and transfer them incrementally to your backup locations. Available as [services.btrbk](options.html#opt-services.brtbk.instances).
@@ -67,6 +71,8 @@ subsonic-compatible api. Available as [navidrome](#opt-services.navidrome.enable
 
 - [nats](https://nats.io/), a high performance cloud and edge messaging system. Available as [services.nats](#opt-services.nats.enable).
 
+- [git](https://git-scm.com), a distributed version control system. Available as [programs.git](options.html#opt-programs.git.enable).
+
 ## Backward Incompatibilities {#sec-release-21.11-incompatibilities}
 
 
@@ -320,3 +326,8 @@ To be able to access the web UI this port needs to be opened in the firewall.
 - GNOME desktop environment now enables `QGnomePlatform` as the Qt platform theme, which should avoid crashes when opening file chooser dialogs in Qt apps by using XDG desktop portal. Additionally, it will make the apps fit better visually.
 
 - `rofi` has been updated from '1.6.1' to '1.7.0', one important thing is the removal of the old xresources based configuration setup. Read more [in rofi's changelog](https://github.com/davatorium/rofi/blob/cb12e6fc058f4a0f4f/Changelog#L1).
+
+- ipfs now defaults to not listening on you local network. This setting was change as server providers won't accept port scanning on their private network. If you have several ipfs instances running on a network you own, feel free to change the setting `ipfs.localDiscovery = true;`. localDiscovery enables different instances to discover each other and share data.
+
+- `lua` and `luajit` interpreters have been patched to avoid looking into /usr/lib
+  directories, thus increasing the purity of the build.
diff --git a/nixpkgs/nixos/modules/config/update-users-groups.pl b/nixpkgs/nixos/modules/config/update-users-groups.pl
index 14914b13702e..5797b1ce511d 100644
--- a/nixpkgs/nixos/modules/config/update-users-groups.pl
+++ b/nixpkgs/nixos/modules/config/update-users-groups.pl
@@ -1,12 +1,11 @@
 use strict;
+use warnings;
 use File::Basename;
 use File::Path qw(make_path);
 use File::Slurp;
+use Getopt::Long;
 use JSON;
 
-make_path("/var/lib/nixos", { mode => 0755 });
-
-
 # Keep track of deleted uids and gids.
 my $uidMapFile = "/var/lib/nixos/uid-map";
 my $uidMap = -e $uidMapFile ? decode_json(read_file($uidMapFile)) : {};
@@ -14,12 +13,19 @@ my $uidMap = -e $uidMapFile ? decode_json(read_file($uidMapFile)) : {};
 my $gidMapFile = "/var/lib/nixos/gid-map";
 my $gidMap = -e $gidMapFile ? decode_json(read_file($gidMapFile)) : {};
 
+my $is_dry = ($ENV{'NIXOS_ACTION'} // "") eq "dry-activate";
+GetOptions("dry-activate" => \$is_dry);
+make_path("/var/lib/nixos", { mode => 0755 }) unless $is_dry;
 
 sub updateFile {
     my ($path, $contents, $perms) = @_;
+    return if $is_dry;
     write_file($path, { atomic => 1, binmode => ':utf8', perms => $perms // 0644 }, $contents) or die;
 }
 
+sub nscdInvalidate {
+    system("nscd", "--invalidate", $_[0]) unless $is_dry;
+}
 
 sub hashPassword {
     my ($password) = @_;
@@ -29,6 +35,14 @@ sub hashPassword {
     return crypt($password, '$6$' . $salt . '$');
 }
 
+sub dry_print {
+    if ($is_dry) {
+        print STDERR ("$_[1] $_[2]\n")
+    } else {
+        print STDERR ("$_[0] $_[2]\n")
+    }
+}
+
 
 # Functions for allocating free GIDs/UIDs. FIXME: respect ID ranges in
 # /etc/login.defs.
@@ -52,7 +66,7 @@ sub allocGid {
     my ($name) = @_;
     my $prevGid = $gidMap->{$name};
     if (defined $prevGid && !defined $gidsUsed{$prevGid}) {
-        print STDERR "reviving group '$name' with GID $prevGid\n";
+        dry_print("reviving", "would revive", "group '$name' with GID $prevGid");
         $gidsUsed{$prevGid} = 1;
         return $prevGid;
     }
@@ -64,15 +78,14 @@ sub allocUid {
     my ($min, $max, $up) = $isSystemUser ? (400, 999, 0) : (1000, 29999, 1);
     my $prevUid = $uidMap->{$name};
     if (defined $prevUid && $prevUid >= $min && $prevUid <= $max && !defined $uidsUsed{$prevUid}) {
-        print STDERR "reviving user '$name' with UID $prevUid\n";
+        dry_print("reviving", "would revive", "user '$name' with UID $prevUid");
         $uidsUsed{$prevUid} = 1;
         return $prevUid;
     }
     return allocId(\%uidsUsed, \%uidsPrevUsed, $min, $max, $up, sub { my ($uid) = @_; getpwuid($uid) });
 }
 
-
-# Read the declared users/groups.
+# Read the declared users/groups
 my $spec = decode_json(read_file($ARGV[0]));
 
 # Don't allocate UIDs/GIDs that are manually assigned.
@@ -135,7 +148,7 @@ foreach my $g (@{$spec->{groups}}) {
     if (defined $existing) {
         $g->{gid} = $existing->{gid} if !defined $g->{gid};
         if ($g->{gid} != $existing->{gid}) {
-            warn "warning: not applying GID change of group ‘$name’ ($existing->{gid} -> $g->{gid})\n";
+            dry_print("warning: not applying", "warning: would not apply", "GID change of group ‘$name’ ($existing->{gid} -> $g->{gid})");
             $g->{gid} = $existing->{gid};
         }
         $g->{password} = $existing->{password}; # do we want this?
@@ -164,7 +177,7 @@ foreach my $name (keys %groupsCur) {
     my $g = $groupsCur{$name};
     next if defined $groupsOut{$name};
     if (!$spec->{mutableUsers} || defined $declGroups{$name}) {
-        print STDERR "removing group ‘$name’\n";
+        dry_print("removing group", "would remove group", "‘$name’");
     } else {
         $groupsOut{$name} = $g;
     }
@@ -176,7 +189,7 @@ my @lines = map { join(":", $_->{name}, $_->{password}, $_->{gid}, $_->{members}
     (sort { $a->{gid} <=> $b->{gid} } values(%groupsOut));
 updateFile($gidMapFile, to_json($gidMap));
 updateFile("/etc/group", \@lines);
-system("nscd --invalidate group");
+nscdInvalidate("group");
 
 # Generate a new /etc/passwd containing the declared users.
 my %usersOut;
@@ -197,7 +210,7 @@ foreach my $u (@{$spec->{users}}) {
     if (defined $existing) {
         $u->{uid} = $existing->{uid} if !defined $u->{uid};
         if ($u->{uid} != $existing->{uid}) {
-            warn "warning: not applying UID change of user ‘$name’ ($existing->{uid} -> $u->{uid})\n";
+            dry_print("warning: not applying", "warning: would not apply", "UID change of user ‘$name’ ($existing->{uid} -> $u->{uid})");
             $u->{uid} = $existing->{uid};
         }
     } else {
@@ -212,8 +225,10 @@ foreach my $u (@{$spec->{users}}) {
 
     # Ensure home directory incl. ownership and permissions.
     if ($u->{createHome}) {
-        make_path(dirname($u->{home}), { mode => 0755 });
-        mkdir $u->{home}, 0700 if ! -e $u->{home};
+        if (!$is_dry) {
+            make_path(dirname($u->{home}), { mode => 0755 });
+            mkdir $u->{home}, 0700 if ! -e $u->{home};
+        }
         chown $u->{uid}, $u->{gid}, $u->{home};
         chmod 0700, $u->{home};
     }
@@ -252,7 +267,7 @@ foreach my $name (keys %usersCur) {
     my $u = $usersCur{$name};
     next if defined $usersOut{$name};
     if (!$spec->{mutableUsers} || defined $declUsers{$name}) {
-        print STDERR "removing user ‘$name’\n";
+        dry_print("removing user", "would remove user", "‘$name’");
     } else {
         $usersOut{$name} = $u;
     }
@@ -263,7 +278,7 @@ foreach my $name (keys %usersCur) {
     (sort { $a->{uid} <=> $b->{uid} } (values %usersOut));
 updateFile($uidMapFile, to_json($uidMap));
 updateFile("/etc/passwd", \@lines);
-system("nscd --invalidate passwd");
+nscdInvalidate("passwd");
 
 
 # Rewrite /etc/shadow to add new accounts or remove dead ones.
@@ -295,7 +310,7 @@ updateFile("/etc/shadow", \@shadowNew, 0640);
     my $uid = getpwnam "root";
     my $gid = getgrnam "shadow";
     my $path = "/etc/shadow";
-    chown($uid, $gid, $path) || die "Failed to change ownership of $path: $!";
+    (chown($uid, $gid, $path) || die "Failed to change ownership of $path: $!") unless $is_dry;
 }
 
 # Rewrite /etc/subuid & /etc/subgid to include default container mappings
diff --git a/nixpkgs/nixos/modules/config/users-groups.nix b/nixpkgs/nixos/modules/config/users-groups.nix
index f86be3be2c65..d88162558e66 100644
--- a/nixpkgs/nixos/modules/config/users-groups.nix
+++ b/nixpkgs/nixos/modules/config/users-groups.nix
@@ -561,14 +561,16 @@ in {
       shadow.gid = ids.gids.shadow;
     };
 
-    system.activationScripts.users = stringAfter [ "stdio" ]
-      ''
+    system.activationScripts.users = {
+      supportsDryActivation = true;
+      text = ''
         install -m 0700 -d /root
         install -m 0755 -d /home
 
         ${pkgs.perl.withPackages (p: [ p.FileSlurp p.JSON ])}/bin/perl \
         -w ${./update-users-groups.pl} ${spec}
       '';
+    };
 
     # for backwards compatibility
     system.activationScripts.groups = stringAfter [ "users" ] "";
diff --git a/nixpkgs/nixos/modules/misc/documentation.nix b/nixpkgs/nixos/modules/misc/documentation.nix
index f00d58369a72..51b310745604 100644
--- a/nixpkgs/nixos/modules/misc/documentation.nix
+++ b/nixpkgs/nixos/modules/misc/documentation.nix
@@ -129,6 +129,24 @@ in
         '';
       };
 
+      man.manualPages = mkOption {
+        type = types.path;
+        default = pkgs.buildEnv {
+          name = "man-paths";
+          paths = config.environment.systemPackages;
+          pathsToLink = [ "/share/man" ];
+          extraOutputsToInstall = ["man"];
+          ignoreCollisions = true;
+        };
+        defaultText = "all man pages in config.environment.systemPackages";
+        description = ''
+          The manual pages to generate caches for if <option>generateCaches</option>
+          is enabled. Must be a path to a directory with man pages under
+          <literal>/share/man</literal>; see the source for an example.
+          Advanced users can make this a content-addressed derivation to save a few rebuilds.
+        '';
+      };
+
       info.enable = mkOption {
         type = types.bool;
         default = true;
@@ -216,16 +234,8 @@ in
       environment.extraOutputsToInstall = [ "man" ] ++ optional cfg.dev.enable "devman";
       environment.etc."man_db.conf".text =
         let
-          manualPages = pkgs.buildEnv {
-            name = "man-paths";
-            paths = config.environment.systemPackages;
-            pathsToLink = [ "/share/man" ];
-            extraOutputsToInstall = ["man"];
-            ignoreCollisions = true;
-          };
-          manualCache = pkgs.runCommandLocal "man-cache" { }
-          ''
-            echo "MANDB_MAP ${manualPages}/share/man $out" > man.conf
+          manualCache = pkgs.runCommandLocal "man-cache" { } ''
+            echo "MANDB_MAP ${cfg.man.manualPages}/share/man $out" > man.conf
             ${pkgs.man-db}/bin/mandb -C man.conf -psc >/dev/null 2>&1
           '';
         in
diff --git a/nixpkgs/nixos/modules/module-list.nix b/nixpkgs/nixos/modules/module-list.nix
index b8a7c35626e7..d145df05da32 100644
--- a/nixpkgs/nixos/modules/module-list.nix
+++ b/nixpkgs/nixos/modules/module-list.nix
@@ -145,6 +145,7 @@
   ./programs/fuse.nix
   ./programs/gamemode.nix
   ./programs/geary.nix
+  ./programs/git.nix
   ./programs/gnome-disks.nix
   ./programs/gnome-documents.nix
   ./programs/gnome-terminal.nix
@@ -382,6 +383,8 @@
   ./services/display-managers/greetd.nix
   ./services/editors/emacs.nix
   ./services/editors/infinoted.nix
+  ./services/games/crossfire-server.nix
+  ./services/games/deliantra-server.nix
   ./services/games/factorio.nix
   ./services/games/freeciv.nix
   ./services/games/minecraft-server.nix
@@ -875,7 +878,6 @@
   ./services/networking/wasabibackend.nix
   ./services/networking/websockify.nix
   ./services/networking/wg-quick.nix
-  ./services/networking/wicd.nix
   ./services/networking/wireguard.nix
   ./services/networking/wpa_supplicant.nix
   ./services/networking/xandikos.nix
diff --git a/nixpkgs/nixos/modules/programs/bash/bash-completion.nix b/nixpkgs/nixos/modules/programs/bash/bash-completion.nix
index f07b1b636ef9..b8e5b1bfa336 100644
--- a/nixpkgs/nixos/modules/programs/bash/bash-completion.nix
+++ b/nixpkgs/nixos/modules/programs/bash/bash-completion.nix
@@ -26,7 +26,7 @@ in
         shopt -s nullglob
         for p in $NIX_PROFILES; do
           for m in "$p/etc/bash_completion.d/"*; do
-            . $m
+            . "$m"
           done
         done
         eval "$nullglobStatus"
diff --git a/nixpkgs/nixos/modules/programs/bash/bash.nix b/nixpkgs/nixos/modules/programs/bash/bash.nix
index 908ab34b08d0..7281126979e5 100644
--- a/nixpkgs/nixos/modules/programs/bash/bash.nix
+++ b/nixpkgs/nixos/modules/programs/bash/bash.nix
@@ -78,10 +78,10 @@ in
       promptInit = mkOption {
         default = ''
           # Provide a nice prompt if the terminal supports it.
-          if [ "$TERM" != "dumb" -o -n "$INSIDE_EMACS" ]; then
+          if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
             PROMPT_COLOR="1;31m"
-            let $UID && PROMPT_COLOR="1;32m"
-            if [ -n "$INSIDE_EMACS" -o "$TERM" == "eterm" -o "$TERM" == "eterm-color" ]; then
+            ((UID)) && PROMPT_COLOR="1;32m"
+            if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then
               # Emacs term mode doesn't support xterm title escape sequence (\e]0;)
               PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
             else
@@ -173,7 +173,7 @@ in
         # /etc/bashrc: DO NOT EDIT -- this file has been generated automatically.
 
         # Only execute this file once per shell.
-        if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi
+        if [ -n "$__ETC_BASHRC_SOURCED" ] || [ -n "$NOSYSBASHRC" ]; then return; fi
         __ETC_BASHRC_SOURCED=1
 
         # If the profile was not loaded in a parent process, source
diff --git a/nixpkgs/nixos/modules/programs/command-not-found/command-not-found.nix b/nixpkgs/nixos/modules/programs/command-not-found/command-not-found.nix
index 79786584c666..4d2a89b51584 100644
--- a/nixpkgs/nixos/modules/programs/command-not-found/command-not-found.nix
+++ b/nixpkgs/nixos/modules/programs/command-not-found/command-not-found.nix
@@ -49,10 +49,10 @@ in
       ''
         # This function is called whenever a command is not found.
         command_not_found_handle() {
-          local p=${commandNotFound}/bin/command-not-found
-          if [ -x $p -a -f ${cfg.dbPath} ]; then
+          local p='${commandNotFound}/bin/command-not-found'
+          if [ -x "$p" ] && [ -f '${cfg.dbPath}' ]; then
             # Run the helper program.
-            $p "$@"
+            "$p" "$@"
             # Retry the command if we just installed it.
             if [ $? = 126 ]; then
               "$@"
@@ -70,10 +70,10 @@ in
       ''
         # This function is called whenever a command is not found.
         command_not_found_handler() {
-          local p=${commandNotFound}/bin/command-not-found
-          if [ -x $p -a -f ${cfg.dbPath} ]; then
+          local p='${commandNotFound}/bin/command-not-found'
+          if [ -x "$p" ] && [ -f '${cfg.dbPath}' ]; then
             # Run the helper program.
-            $p "$@"
+            "$p" "$@"
 
             # Retry the command if we just installed it.
             if [ $? = 126 ]; then
diff --git a/nixpkgs/nixos/modules/programs/environment.nix b/nixpkgs/nixos/modules/programs/environment.nix
index 8877356360a5..39010323f61e 100644
--- a/nixpkgs/nixos/modules/programs/environment.nix
+++ b/nixpkgs/nixos/modules/programs/environment.nix
@@ -18,7 +18,8 @@ in
 
     environment.variables =
       { NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
-        PAGER = mkDefault "less -R";
+        PAGER = mkDefault "less";
+        LESS = mkDefault "-R";
         EDITOR = mkDefault "nano";
         XDG_CONFIG_DIRS = [ "/etc/xdg" ]; # needs to be before profile-relative paths to allow changes through environment.etc
       };
diff --git a/nixpkgs/nixos/modules/programs/git.nix b/nixpkgs/nixos/modules/programs/git.nix
new file mode 100644
index 000000000000..4e06b576f896
--- /dev/null
+++ b/nixpkgs/nixos/modules/programs/git.nix
@@ -0,0 +1,45 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.programs.git;
+in
+
+{
+  options = {
+    programs.git = {
+      enable = mkEnableOption "git";
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.git;
+        defaultText = "pkgs.git";
+        example = literalExample "pkgs.gitFull";
+        description = "The git package to use";
+      };
+
+      config = mkOption {
+        type = types.attrs;
+        default = { };
+        example = {
+          init.defaultBranch = "main";
+          url."https://github.com/".insteadOf = [ "gh:" "github:" ];
+        };
+        description = ''
+          Configuration to write to /etc/gitconfig. See the CONFIGURATION FILE
+          section of git-config(1) for more information.
+        '';
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.systemPackages = [ cfg.package ];
+    environment.etc.gitconfig = mkIf (cfg.config != {}) {
+      text = generators.toGitINI cfg.config;
+    };
+  };
+
+  meta.maintainers = with maintainers; [ figsoda ];
+}
diff --git a/nixpkgs/nixos/modules/rename.nix b/nixpkgs/nixos/modules/rename.nix
index 233e3ee848be..4db6efb75d82 100644
--- a/nixpkgs/nixos/modules/rename.nix
+++ b/nixpkgs/nixos/modules/rename.nix
@@ -27,6 +27,7 @@ with lib;
     (mkRemovedOptionModule [ "services" "mesos" ] "The corresponding package was removed from nixpkgs.")
     (mkRemovedOptionModule [ "services" "winstone" ] "The corresponding package was removed from nixpkgs.")
     (mkRemovedOptionModule [ "networking" "vpnc" ] "Use environment.etc.\"vpnc/service.conf\" instead.")
+    (mkRemovedOptionModule [ "networking" "wicd" ] "The corresponding package was removed from nixpkgs.")
     (mkRemovedOptionModule [ "environment" "blcr" "enable" ] "The BLCR module has been removed")
     (mkRemovedOptionModule [ "services" "beegfsEnable" ] "The BeeGFS module has been removed")
     (mkRemovedOptionModule [ "services" "beegfs" ] "The BeeGFS module has been removed")
diff --git a/nixpkgs/nixos/modules/services/amqp/rabbitmq.nix b/nixpkgs/nixos/modules/services/amqp/rabbitmq.nix
index 8fdfda9a66d8..dabd80312d9d 100644
--- a/nixpkgs/nixos/modules/services/amqp/rabbitmq.nix
+++ b/nixpkgs/nixos/modules/services/amqp/rabbitmq.nix
@@ -135,25 +135,14 @@ in
         description = "The list of directories containing external plugins";
       };
 
-      managementPlugin = mkOption {
-        description = "The options to run the management plugin";
-        type = types.submodule {
-          options = {
-            enable = mkOption {
-              default = false;
-              type = types.bool;
-              description = ''
-                Whether to enable the management plugin
-              '';
-            };
-            port = mkOption {
-              default = 15672;
-              type = types.port;
-              description = ''
-                On which port to run the management plugin
-              '';
-            };
-          };
+      managementPlugin = {
+        enable = mkEnableOption "the management plugin";
+        port = mkOption {
+          default = 15672;
+          type = types.port;
+          description = ''
+            On which port to run the management plugin
+          '';
         };
       };
     };
diff --git a/nixpkgs/nixos/modules/services/audio/spotifyd.nix b/nixpkgs/nixos/modules/services/audio/spotifyd.nix
index 9279a03aed4e..22848ed98000 100644
--- a/nixpkgs/nixos/modules/services/audio/spotifyd.nix
+++ b/nixpkgs/nixos/modules/services/audio/spotifyd.nix
@@ -4,7 +4,15 @@ with lib;
 
 let
   cfg = config.services.spotifyd;
-  spotifydConf = pkgs.writeText "spotifyd.conf" cfg.config;
+  toml = pkgs.formats.toml {};
+  warnConfig =
+    if cfg.config != ""
+    then lib.trace "Using the stringly typed .config attribute is discouraged. Use the TOML typed .settings attribute instead."
+    else id;
+  spotifydConf =
+    if cfg.settings != {}
+    then toml.generate "spotify.conf" cfg.settings
+    else warnConfig (pkgs.writeText "spotifyd.conf" cfg.config);
 in
 {
   options = {
@@ -15,6 +23,16 @@ in
         default = "";
         type = types.lines;
         description = ''
+          (Deprecated) Configuration for Spotifyd. For syntax and directives, see
+          <link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
+        '';
+      };
+
+      settings = mkOption {
+        default = {};
+        type = toml.type;
+        example = { global.bitrate = 320; };
+        description = ''
           Configuration for Spotifyd. For syntax and directives, see
           <link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
         '';
@@ -23,6 +41,13 @@ in
   };
 
   config = mkIf cfg.enable {
+    assertions = [
+      {
+        assertion = cfg.config == "" || cfg.settings == {};
+        message = "At most one of the .config attribute and the .settings attribute may be set";
+      }
+    ];
+
     systemd.services.spotifyd = {
       wantedBy = [ "multi-user.target" ];
       after = [ "network-online.target" "sound.target" ];
diff --git a/nixpkgs/nixos/modules/services/backup/sanoid.nix b/nixpkgs/nixos/modules/services/backup/sanoid.nix
index 41d0e2e1df68..e70063415ec0 100644
--- a/nixpkgs/nixos/modules/services/backup/sanoid.nix
+++ b/nixpkgs/nixos/modules/services/backup/sanoid.nix
@@ -57,8 +57,13 @@ let
     useTemplate = use_template;
 
     recursive = mkOption {
-      description = "Whether to recursively snapshot dataset children.";
-      type = types.bool;
+      description = ''
+        Whether to recursively snapshot dataset children.
+        You can also set this to <literal>"zfs"</literal> to handle datasets
+        recursively in an atomic way without the possibility to
+        override settings for child datasets.
+      '';
+      type = with types; oneOf [ bool (enum [ "zfs" ]) ];
       default = false;
     };
 
diff --git a/nixpkgs/nixos/modules/services/backup/znapzend.nix b/nixpkgs/nixos/modules/services/backup/znapzend.nix
index debb2a397050..1fccc7cd6076 100644
--- a/nixpkgs/nixos/modules/services/backup/znapzend.nix
+++ b/nixpkgs/nixos/modules/services/backup/znapzend.nix
@@ -324,7 +324,7 @@ in
       autoCreation = mkOption {
         type = bool;
         default = false;
-        description = "Automatically create the destination dataset if it does not exists.";
+        description = "Automatically create the destination dataset if it does not exist.";
       };
 
       zetup = mkOption {
diff --git a/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix b/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix
index 08f5cdfdf334..51b2b5f6eb0d 100644
--- a/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix
+++ b/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix
@@ -343,7 +343,7 @@ in
       };
 
       # Allways include cni plugins
-      services.kubernetes.kubelet.cni.packages = [pkgs.cni-plugins];
+      services.kubernetes.kubelet.cni.packages = [pkgs.cni-plugins pkgs.cni-plugin-flannel];
 
       boot.kernelModules = ["br_netfilter" "overlay"];
 
diff --git a/nixpkgs/nixos/modules/services/games/crossfire-server.nix b/nixpkgs/nixos/modules/services/games/crossfire-server.nix
new file mode 100644
index 000000000000..974aea0cd671
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/games/crossfire-server.nix
@@ -0,0 +1,177 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.crossfire-server;
+  serverPort = 13327;
+in {
+  options.services.crossfire-server = {
+    enable = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        If enabled, the Crossfire game server will be started at boot.
+      '';
+    };
+
+    package = mkOption {
+      type = types.package;
+      default = pkgs.crossfire-server;
+      defaultText = "pkgs.crossfire-server";
+      description = ''
+        The package to use for the Crossfire server (and map/arch data, if you
+        don't change dataDir).
+      '';
+    };
+
+    dataDir = mkOption {
+      type = types.str;
+      default = "${cfg.package}/share/crossfire";
+      defaultText = "\${config.services.crossfire.package}/share/crossfire";
+      description = ''
+        Where to load readonly data from -- maps, archetypes, treasure tables,
+        and the like. If you plan to edit the data on the live server (rather
+        than overlaying the crossfire-maps and crossfire-arch packages and
+        nixos-rebuilding), point this somewhere read-write and copy the data
+        there before starting the server.
+      '';
+    };
+
+    stateDir = mkOption {
+      type = types.str;
+      default = "/var/lib/crossfire";
+      description = ''
+        Where to store runtime data (save files, persistent items, etc).
+
+        If left at the default, this will be automatically created on server
+        startup if it does not already exist. If changed, it is the admin's
+        responsibility to make sure that the directory exists and is writeable
+        by the `crossfire` user.
+      '';
+    };
+
+    openFirewall = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        Whether to open ports in the firewall for the server.
+      '';
+    };
+
+    configFiles = mkOption {
+      type = types.attrsOf types.str;
+      description = ''
+        Text to append to the corresponding configuration files. Note that the
+        files given in the example are *not* the complete set of files available
+        to customize; look in /etc/crossfire after enabling the server to see
+        the available files, and read the comments in each file for detailed
+        documentation on the format and what settings are available.
+
+        Note that the motd, rules, and news files, if configured here, will
+        overwrite the example files that come with the server, rather than being
+        appended to them as the other configuration files are.
+      '';
+      example = literalExample ''
+        dm_file = '''
+          admin:secret_password:localhost
+          jane:xyzzy:*
+        ''';
+        ban_file = '''
+          # Bob is a jerk
+          bob@*
+          # So is everyone on 192.168.86.255/24
+          *@192.168.86.
+        ''';
+        metaserver2 = '''
+          metaserver2_notification on
+          localhostname crossfire.example.net
+        ''';
+        motd = "Welcome to CrossFire!";
+        news = "No news yet.";
+        rules = "Don't be a jerk.";
+        settings = '''
+          # be nicer to newbies and harsher to experienced players
+          balanced_stat_loss true
+          # don't let players pick up and use admin-created items
+          real_wiz false
+        ''';
+      '';
+      default = {};
+    };
+  };
+
+  config = mkIf cfg.enable {
+    users.users.crossfire = {
+      description     = "Crossfire server daemon user";
+      home            = cfg.stateDir;
+      createHome      = false;
+      isSystemUser    = true;
+      group           = "crossfire";
+    };
+    users.groups.crossfire = {};
+
+    # Merge the cfg.configFiles setting with the default files shipped with
+    # Crossfire.
+    # For most files this consists of reading ${crossfire}/etc/crossfire/${name}
+    # and appending the user setting to it; the motd, news, and rules are handled
+    # specially, with user-provided values completely replacing the original.
+    environment.etc = lib.attrsets.mapAttrs'
+      (name: value: lib.attrsets.nameValuePair "crossfire/${name}" {
+        mode = "0644";
+        text =
+          (optionalString (!elem name ["motd" "news" "rules"])
+            (fileContents "${cfg.package}/etc/crossfire/${name}"))
+          + "\n${value}";
+      }) ({
+        ban_file = "";
+        dm_file = "";
+        exp_table = "";
+        forbid = "";
+        metaserver2 = "";
+        motd = (fileContents "${cfg.package}/etc/crossfire/motd");
+        news = (fileContents "${cfg.package}/etc/crossfire/news");
+        rules = (fileContents "${cfg.package}/etc/crossfire/rules");
+        settings = "";
+        stat_bonus = "";
+      } // cfg.configFiles);
+
+    systemd.services.crossfire-server = {
+      description   = "Crossfire Server Daemon";
+      wantedBy      = [ "multi-user.target" ];
+      after         = [ "network.target" ];
+
+      serviceConfig = mkMerge [
+        {
+          ExecStart = "${cfg.package}/bin/crossfire-server -conf /etc/crossfire -local '${cfg.stateDir}' -data '${cfg.dataDir}'";
+          Restart = "always";
+          User = "crossfire";
+          Group = "crossfire";
+          WorkingDirectory = cfg.stateDir;
+        }
+        (mkIf (cfg.stateDir == "/var/lib/crossfire") {
+          StateDirectory = "crossfire";
+        })
+      ];
+
+      # The crossfire server needs access to a bunch of files at runtime that
+      # are not created automatically at server startup; they're meant to be
+      # installed in $PREFIX/var/crossfire by `make install`. And those files
+      # need to be writeable, so we can't just point at the ones in the nix
+      # store. Instead we take the approach of copying them out of the store
+      # on first run. If `bookarch` already exists, we assume the rest of the
+      # files do as well, and copy nothing -- otherwise we risk ovewriting
+      # server state information every time the server is upgraded.
+      preStart = ''
+        if [ ! -e "${cfg.stateDir}"/bookarch ]; then
+          ${pkgs.rsync}/bin/rsync -a --chmod=u=rwX,go=rX \
+            "${cfg.package}/var/crossfire/" "${cfg.stateDir}/"
+        fi
+      '';
+    };
+
+    networking.firewall = mkIf cfg.openFirewall {
+      allowedTCPPorts = [ serverPort ];
+    };
+  };
+}
diff --git a/nixpkgs/nixos/modules/services/games/deliantra-server.nix b/nixpkgs/nixos/modules/services/games/deliantra-server.nix
new file mode 100644
index 000000000000..36bf60417626
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/games/deliantra-server.nix
@@ -0,0 +1,170 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.deliantra-server;
+  serverPort = 13327;
+in {
+  options.services.deliantra-server = {
+    enable = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        If enabled, the Deliantra game server will be started at boot.
+      '';
+    };
+
+    package = mkOption {
+      type = types.package;
+      default = pkgs.deliantra-server;
+      defaultText = "pkgs.deliantra-server";
+      description = ''
+        The package to use for the Deliantra server (and map/arch data, if you
+        don't change dataDir).
+      '';
+    };
+
+    dataDir = mkOption {
+      type = types.str;
+      default = "${pkgs.deliantra-data}";
+      defaultText = "\${pkgs.deliantra-data}";
+      description = ''
+        Where to store readonly data (maps, archetypes, sprites, etc).
+        Note that if you plan to use the live map editor (rather than editing
+        the maps offline and then nixos-rebuilding), THIS MUST BE WRITEABLE --
+        copy the deliantra-data someplace writeable (say,
+        /var/lib/deliantra/data) and update this option accordingly.
+      '';
+    };
+
+    stateDir = mkOption {
+      type = types.str;
+      default = "/var/lib/deliantra";
+      description = ''
+        Where to store runtime data (save files, persistent items, etc).
+
+        If left at the default, this will be automatically created on server
+        startup if it does not already exist. If changed, it is the admin's
+        responsibility to make sure that the directory exists and is writeable
+        by the `crossfire` user.
+      '';
+    };
+
+    openFirewall = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        Whether to open ports in the firewall for the server.
+      '';
+    };
+
+    configFiles = mkOption {
+      type = types.attrsOf types.str;
+      description = ''
+        Contents of the server configuration files. These will be appended to
+        the example configurations the server comes with and overwrite any
+        default settings defined therein.
+
+        The example here is not comprehensive. See the files in
+        /etc/deliantra-server after enabling this module for full documentation.
+      '';
+      example = literalExample ''
+        dm_file = '''
+          admin:secret_password:localhost
+          jane:xyzzy:*
+        ''';
+        motd = "Welcome to Deliantra!";
+        settings = '''
+          # Settings for game mechanics.
+          stat_loss_on_death true
+          armor_max_enchant 7
+        ''';
+        config = '''
+          # Settings for the server daemon.
+          hiscore_url https://deliantra.example.net/scores/
+          max_map_reset 86400
+        ''';
+      '';
+      default = {
+        motd = "";
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    users.users.deliantra = {
+      description     = "Deliantra server daemon user";
+      home            = cfg.stateDir;
+      createHome      = false;
+      isSystemUser    = true;
+      group           = "deliantra";
+    };
+    users.groups.deliantra = {};
+
+    # Merge the cfg.configFiles setting with the default files shipped with
+    # Deliantra.
+    # For most files this consists of reading
+    # ${deliantra}/etc/deliantra-server/${name} and appending the user setting
+    # to it.
+    environment.etc = lib.attrsets.mapAttrs'
+      (name: value: lib.attrsets.nameValuePair "deliantra-server/${name}" {
+        mode = "0644";
+        text =
+          # Deliantra doesn't come with a motd file, but respects it if present
+          # in /etc.
+          (optionalString (name != "motd")
+            (fileContents "${cfg.package}/etc/deliantra-server/${name}"))
+          + "\n${value}";
+      }) ({
+        motd = "";
+        settings = "";
+        config = "";
+        dm_file = "";
+      } // cfg.configFiles);
+
+    systemd.services.deliantra-server = {
+      description   = "Deliantra Server Daemon";
+      wantedBy      = [ "multi-user.target" ];
+      after         = [ "network.target" ];
+
+      environment = {
+        DELIANTRA_DATADIR="${cfg.dataDir}";
+        DELIANTRA_LOCALDIR="${cfg.stateDir}";
+        DELIANTRA_CONFDIR="/etc/deliantra-server";
+      };
+
+      serviceConfig = mkMerge [
+        {
+          ExecStart = "${cfg.package}/bin/deliantra-server";
+          Restart = "always";
+          User = "deliantra";
+          Group = "deliantra";
+          WorkingDirectory = cfg.stateDir;
+        }
+        (mkIf (cfg.stateDir == "/var/lib/deliantra") {
+          StateDirectory = "deliantra";
+        })
+      ];
+
+      # The deliantra server needs access to a bunch of files at runtime that
+      # are not created automatically at server startup; they're meant to be
+      # installed in $PREFIX/var/deliantra-server by `make install`. And those
+      # files need to be writeable, so we can't just point at the ones in the
+      # nix store. Instead we take the approach of copying them out of the store
+      # on first run. If `bookarch` already exists, we assume the rest of the
+      # files do as well, and copy nothing -- otherwise we risk ovewriting
+      # server state information every time the server is upgraded.
+      preStart = ''
+        if [ ! -e "${cfg.stateDir}"/bookarch ]; then
+          ${pkgs.rsync}/bin/rsync -a --chmod=u=rwX,go=rX \
+            "${cfg.package}/var/deliantra-server/" "${cfg.stateDir}/"
+        fi
+      '';
+    };
+
+    networking.firewall = mkIf cfg.openFirewall {
+      allowedTCPPorts = [ serverPort ];
+    };
+  };
+}
diff --git a/nixpkgs/nixos/modules/services/logging/promtail.nix b/nixpkgs/nixos/modules/services/logging/promtail.nix
index 34211687dc1d..95c83796ece6 100644
--- a/nixpkgs/nixos/modules/services/logging/promtail.nix
+++ b/nixpkgs/nixos/modules/services/logging/promtail.nix
@@ -7,6 +7,9 @@ let
   '';
 
   allowSystemdJournal = cfg.configuration ? scrape_configs && lib.any (v: v ? journal) cfg.configuration.scrape_configs;
+
+  allowPositionsFile = !lib.hasPrefix "/var/cache/promtail" positionsFile;
+  positionsFile = cfg.configuration.positions.filename;
 in {
   options.services.promtail = with types; {
     enable = mkEnableOption "the Promtail ingresser";
@@ -53,6 +56,7 @@ in {
         RestrictSUIDSGID = true;
         PrivateMounts = true;
         CacheDirectory = "promtail";
+        ReadWritePaths = lib.optional allowPositionsFile (builtins.dirOf positionsFile);
 
         User = "promtail";
         Group = "promtail";
diff --git a/nixpkgs/nixos/modules/services/misc/nix-ssh-serve.nix b/nixpkgs/nixos/modules/services/misc/nix-ssh-serve.nix
index 7ce3841be2f5..1764c6d79649 100644
--- a/nixpkgs/nixos/modules/services/misc/nix-ssh-serve.nix
+++ b/nixpkgs/nixos/modules/services/misc/nix-ssh-serve.nix
@@ -4,7 +4,7 @@ with lib;
 let cfg = config.nix.sshServe;
     command =
       if cfg.protocol == "ssh"
-        then "nix-store --serve"
+        then "nix-store --serve ${lib.optionalString cfg.write "--write"}"
       else "nix-daemon --stdio";
 in {
   options = {
@@ -17,6 +17,12 @@ in {
         description = "Whether to enable serving the Nix store as a remote store via SSH.";
       };
 
+      write = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Whether to enable writing to the Nix store as a remote store via SSH. Note: the sshServe user is named nix-ssh and is not a trusted-user. nix-ssh should be added to the nix.trustedUsers option in most use cases, such as allowing remote building of derivations.";
+      };
+
       keys = mkOption {
         type = types.listOf types.str;
         default = [];
diff --git a/nixpkgs/nixos/modules/services/monitoring/grafana.nix b/nixpkgs/nixos/modules/services/monitoring/grafana.nix
index fb67bbfb8420..d46e38e82af1 100644
--- a/nixpkgs/nixos/modules/services/monitoring/grafana.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/grafana.nix
@@ -675,6 +675,33 @@ in {
         User = "grafana";
         RuntimeDirectory = "grafana";
         RuntimeDirectoryMode = "0755";
+        # Hardening
+        CapabilityBoundingSet = [ "" ];
+        DeviceAllow = [ "" ];
+        LockPersonality = true;
+        MemoryDenyWriteExecute = true;
+        NoNewPrivileges = true;
+        PrivateDevices = true;
+        PrivateTmp = true;
+        PrivateUsers = true;
+        ProcSubset = "pid";
+        ProtectClock = true;
+        ProtectControlGroups = true;
+        ProtectHome = true;
+        ProtectHostname = true;
+        ProtectKernelLogs = true;
+        ProtectKernelModules = true;
+        ProtectKernelTunables = true;
+        ProtectProc = "invisible";
+        ProtectSystem = "full";
+        RemoveIPC = true;
+        RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
+        RestrictNamespaces = true;
+        RestrictRealtime = true;
+        RestrictSUIDSGID = true;
+        SystemCallArchitectures = "native";
+        SystemCallFilter = [ "@system-service" "~@privileged" "~@resources" ];
+        UMask = "0027";
       };
       preStart = ''
         ln -fs ${cfg.package}/share/grafana/conf ${cfg.dataDir}
diff --git a/nixpkgs/nixos/modules/services/monitoring/nagios.nix b/nixpkgs/nixos/modules/services/monitoring/nagios.nix
index 0afaefe04e18..280a9a001b5b 100644
--- a/nixpkgs/nixos/modules/services/monitoring/nagios.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/nagios.nix
@@ -41,7 +41,7 @@ let
     validated =  pkgs.runCommand "nagios-checked.cfg" {preferLocalBuild=true;} ''
       cp ${file} nagios.cfg
       # nagios checks the existence of /var/lib/nagios, but
-      # it does not exists in the build sandbox, so we fake it
+      # it does not exist in the build sandbox, so we fake it
       mkdir lib
       lib=$(readlink -f lib)
       sed -i s@=${nagiosState}@=$lib@ nagios.cfg
diff --git a/nixpkgs/nixos/modules/services/network-filesystems/ipfs.nix b/nixpkgs/nixos/modules/services/network-filesystems/ipfs.nix
index 57f5f6b006c8..faa515835b67 100644
--- a/nixpkgs/nixos/modules/services/network-filesystems/ipfs.nix
+++ b/nixpkgs/nixos/modules/services/network-filesystems/ipfs.nix
@@ -12,6 +12,11 @@ let
     (optionalString (cfg.defaultMode == "norouting") "--routing=none")
   ] ++ cfg.extraFlags);
 
+  profile =
+    if cfg.localDiscovery
+    then "local-discovery"
+    else "server";
+
   splitMulitaddr = addrRaw: lib.tail (lib.splitString "/" addrRaw);
 
   multiaddrToListenStream = addrRaw:
@@ -173,7 +178,7 @@ in
         description = ''Whether to enable local discovery for the ipfs daemon.
           This will allow ipfs to scan ports on your local network. Some hosting services will ban you if you do this.
         '';
-        default = true;
+        default = false;
       };
 
       serviceFdlimit = mkOption {
@@ -236,14 +241,13 @@ in
       environment.IPFS_PATH = cfg.dataDir;
 
       preStart = ''
-        if [[ ! -f ${cfg.dataDir}/config ]]; then
-          ipfs init ${optionalString cfg.emptyRepo "-e"} \
-            ${optionalString (! cfg.localDiscovery) "--profile=server"}
+        if [[ ! -f "$IPFS_PATH/config" ]]; then
+          ipfs init ${optionalString cfg.emptyRepo "-e"} --profile=${profile}
         else
-          ${if cfg.localDiscovery
-            then "ipfs --offline config profile apply local-discovery"
-            else "ipfs --offline config profile apply server"
-          }
+          # After an unclean shutdown this file may exist which will cause the config command to attempt to talk to the daemon. This will hang forever if systemd is holding our sockets open.
+          rm -vf "$IPFS_PATH/api"
+
+          ipfs --offline config profile apply ${profile}
         fi
       '' + optionalString cfg.autoMount ''
         ipfs --offline config Mounts.FuseAllowOther --json true
diff --git a/nixpkgs/nixos/modules/services/networking/firefox/sync-server.nix b/nixpkgs/nixos/modules/services/networking/firefox/sync-server.nix
index 24f768649530..1ad573abfca3 100644
--- a/nixpkgs/nixos/modules/services/networking/firefox/sync-server.nix
+++ b/nixpkgs/nixos/modules/services/networking/firefox/sync-server.nix
@@ -119,7 +119,7 @@ in
           password, and the <option>syncserver.secret</option> setting is used by the server to
           generate cryptographically-signed authentication tokens.
 
-          If this file does not exists, then it is created with a generated
+          If this file does not exist, then it is created with a generated
           <option>syncserver.secret</option> settings.
        '';
       };
diff --git a/nixpkgs/nixos/modules/services/networking/gnunet.nix b/nixpkgs/nixos/modules/services/networking/gnunet.nix
index 69d4ed047756..cf3d1841a979 100644
--- a/nixpkgs/nixos/modules/services/networking/gnunet.nix
+++ b/nixpkgs/nixos/modules/services/networking/gnunet.nix
@@ -6,12 +6,15 @@ let
 
   cfg = config.services.gnunet;
 
-  homeDir = "/var/lib/gnunet";
+  stateDir = "/var/lib/gnunet";
 
-  configFile = with cfg; pkgs.writeText "gnunetd.conf"
+  configFile = with cfg;
     ''
       [PATHS]
-      SERVICEHOME = ${homeDir}
+      GNUNET_HOME = ${stateDir}
+      GNUNET_RUNTIME_DIR = /run/gnunet
+      GNUNET_USER_RUNTIME_DIR = /run/gnunet
+      GNUNET_DATA_HOME = ${stateDir}/data
 
       [ats]
       WAN_QUOTA_IN = ${toString load.maxNetDownBandwidth} b
@@ -137,8 +140,6 @@ in
     users.users.gnunet = {
       group = "gnunet";
       description = "GNUnet User";
-      home = homeDir;
-      createHome = true;
       uid = config.ids.uids.gnunet;
     };
 
@@ -148,17 +149,20 @@ in
     # so install them globally.
     environment.systemPackages = [ cfg.package ];
 
+    environment.etc."gnunet.conf".text = configFile;
+
     systemd.services.gnunet = {
       description = "GNUnet";
       after = [ "network.target" ];
       wantedBy = [ "multi-user.target" ];
+      restartTriggers = [ configFile ];
       path = [ cfg.package pkgs.miniupnpc ];
-      environment.TMPDIR = "/tmp";
-      serviceConfig.PrivateTmp = true;
-      serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c ${configFile}";
+      serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c /etc/gnunet.conf";
       serviceConfig.User = "gnunet";
       serviceConfig.UMask = "0007";
-      serviceConfig.WorkingDirectory = homeDir;
+      serviceConfig.WorkingDirectory = stateDir;
+      serviceConfig.RuntimeDirectory = "gnunet";
+      serviceConfig.StateDirectory = "gnunet";
     };
 
   };
diff --git a/nixpkgs/nixos/modules/services/networking/wicd.nix b/nixpkgs/nixos/modules/services/networking/wicd.nix
deleted file mode 100644
index aa10a50f876a..000000000000
--- a/nixpkgs/nixos/modules/services/networking/wicd.nix
+++ /dev/null
@@ -1,40 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-{
-
-  ###### interface
-
-  options = {
-
-    networking.wicd.enable = mkOption {
-      type = types.bool;
-      default = false;
-      description = ''
-        Whether to start <command>wicd</command>. Wired and
-        wireless network configurations can then be managed by
-        wicd-client.
-      '';
-    };
-  };
-
-
-  ###### implementation
-
-  config = mkIf config.networking.wicd.enable {
-
-    environment.systemPackages = [pkgs.wicd];
-
-    systemd.services.wicd = {
-      after = [ "network-pre.target" ];
-      before = [ "network.target" ];
-      wants = [ "network.target" ];
-      wantedBy = [ "multi-user.target" ];
-      script = "${pkgs.wicd}/sbin/wicd -f";
-    };
-
-    services.dbus.enable = true;
-    services.dbus.packages = [pkgs.wicd];
-  };
-}
diff --git a/nixpkgs/nixos/modules/services/search/elasticsearch.nix b/nixpkgs/nixos/modules/services/search/elasticsearch.nix
index 440f34b3dc5c..1d7a28d5d245 100644
--- a/nixpkgs/nixos/modules/services/search/elasticsearch.nix
+++ b/nixpkgs/nixos/modules/services/search/elasticsearch.nix
@@ -8,9 +8,13 @@ let
   esConfig = ''
     network.host: ${cfg.listenAddress}
     cluster.name: ${cfg.cluster_name}
+    ${lib.optionalString cfg.single_node ''
+      discovery.type: single-node
+      gateway.auto_import_dangling_indices: true
+    ''}
 
     http.port: ${toString cfg.port}
-    transport.tcp.port: ${toString cfg.tcp_port}
+    transport.port: ${toString cfg.tcp_port}
 
     ${cfg.extraConf}
   '';
@@ -77,6 +81,12 @@ in
       type = types.str;
     };
 
+    single_node = mkOption {
+      description = "Start a single-node cluster";
+      default = true;
+      type = types.bool;
+    };
+
     extraConf = mkOption {
       description = "Extra configuration for elasticsearch.";
       default = "";
diff --git a/nixpkgs/nixos/modules/services/security/privacyidea.nix b/nixpkgs/nixos/modules/services/security/privacyidea.nix
index 63271848e943..5f894d0fa691 100644
--- a/nixpkgs/nixos/modules/services/security/privacyidea.nix
+++ b/nixpkgs/nixos/modules/services/security/privacyidea.nix
@@ -228,7 +228,7 @@ in
         path = with pkgs; [ openssl ];
         environment.PRIVACYIDEA_CONFIGFILE = "${cfg.stateDir}/privacyidea.cfg";
         preStart = let
-          pi-manage = "${pkgs.sudo}/bin/sudo -u privacyidea -HE ${penv}/bin/pi-manage";
+          pi-manage = "${config.security.sudo.package}/bin/sudo -u privacyidea -HE ${penv}/bin/pi-manage";
           pgsu = config.services.postgresql.superUser;
           psql = config.services.postgresql.package;
         in ''
@@ -239,8 +239,8 @@ in
                                                    -i "${piCfgFile}"
           chown ${cfg.user}:${cfg.group} ${cfg.stateDir}/privacyidea.cfg
           if ! test -e "${cfg.stateDir}/db-created"; then
-            ${pkgs.sudo}/bin/sudo -u ${pgsu} ${psql}/bin/createuser --no-superuser --no-createdb --no-createrole ${cfg.user}
-            ${pkgs.sudo}/bin/sudo -u ${pgsu} ${psql}/bin/createdb --owner ${cfg.user} privacyidea
+            ${config.security.sudo.package}/bin/sudo -u ${pgsu} ${psql}/bin/createuser --no-superuser --no-createdb --no-createrole ${cfg.user}
+            ${config.security.sudo.package}/bin/sudo -u ${pgsu} ${psql}/bin/createdb --owner ${cfg.user} privacyidea
             ${pi-manage} create_enckey
             ${pi-manage} create_audit_keys
             ${pi-manage} createdb
diff --git a/nixpkgs/nixos/modules/services/video/mirakurun.nix b/nixpkgs/nixos/modules/services/video/mirakurun.nix
index 6ea73fa5c679..1a99d1c97692 100644
--- a/nixpkgs/nixos/modules/services/video/mirakurun.nix
+++ b/nixpkgs/nixos/modules/services/video/mirakurun.nix
@@ -173,7 +173,7 @@ in
         wantedBy = [ "multi-user.target" ];
         after = [ "network.target" ];
         serviceConfig = {
-          ExecStart = "${mirakurun}/bin/mirakurun";
+          ExecStart = "${mirakurun}/bin/mirakurun-start";
           User = username;
           Group = groupname;
           RuntimeDirectory="mirakurun";
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/sx.nix b/nixpkgs/nixos/modules/services/x11/display-managers/sx.nix
index 132531c0ddc0..73d27390a580 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/sx.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/sx.nix
@@ -34,4 +34,6 @@ in {
     };
     systemd.services.display-manager.enable = false;
   };
+
+  meta.maintainers = with maintainers; [ figsoda ];
 }
diff --git a/nixpkgs/nixos/modules/services/x11/extra-layouts.nix b/nixpkgs/nixos/modules/services/x11/extra-layouts.nix
index f48216ff446f..0e2edc6a5309 100644
--- a/nixpkgs/nixos/modules/services/x11/extra-layouts.nix
+++ b/nixpkgs/nixos/modules/services/x11/extra-layouts.nix
@@ -166,7 +166,8 @@ in
 
     services.xserver = {
       xkbDir = "${pkgs.xkb_patched}/etc/X11/xkb";
-      exportConfiguration = config.services.xserver.displayManager.startx.enable;
+      exportConfiguration = config.services.xserver.displayManager.startx.enable
+        || config.services.xserver.displayManager.sx.enable;
     };
 
   };
diff --git a/nixpkgs/nixos/modules/system/activation/activation-script.nix b/nixpkgs/nixos/modules/system/activation/activation-script.nix
index 3a6930314b1a..548b4de852b7 100644
--- a/nixpkgs/nixos/modules/system/activation/activation-script.nix
+++ b/nixpkgs/nixos/modules/system/activation/activation-script.nix
@@ -17,6 +17,41 @@ let
     '';
   });
 
+  systemActivationScript = set: onlyDry: let
+    set' = filterAttrs (_: v: onlyDry -> v.supportsDryActivation) (mapAttrs (_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v) set);
+    withHeadlines = addAttributeName set';
+  in
+    ''
+      #!${pkgs.runtimeShell}
+
+      systemConfig='@out@'
+
+      export PATH=/empty
+      for i in ${toString path}; do
+          PATH=$PATH:$i/bin:$i/sbin
+      done
+
+      _status=0
+      trap "_status=1 _localstatus=\$?" ERR
+
+      # Ensure a consistent umask.
+      umask 0022
+
+      ${textClosureMap id (withHeadlines) (attrNames withHeadlines)}
+
+    '' + optionalString (!onlyDry) ''
+      # Make this configuration the current configuration.
+      # The readlink is there to ensure that when $systemConfig = /system
+      # (which is a symlink to the store), /run/current-system is still
+      # used as a garbage collection root.
+      ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
+
+      # Prevent the current configuration from being garbage-collected.
+      ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
+
+      exit $_status
+    '';
+
   path = with pkgs; map getBin
     [ coreutils
       gnugrep
@@ -28,7 +63,7 @@ let
       util-linux # needed for mount and mountpoint
     ];
 
-  scriptType = with types;
+  scriptType = withDry: with types;
     let scriptOptions =
       { deps = mkOption
           { type = types.listOf types.str;
@@ -39,6 +74,19 @@ let
           { type = types.lines;
             description = "The content of the script.";
           };
+      } // optionalAttrs withDry {
+        supportsDryActivation = mkOption
+          { type = types.bool;
+            default = false;
+            description = ''
+              Whether this activation script supports being dry-activated.
+              These activation scripts will also be executed on dry-activate
+              activations with the environment variable
+              <literal>NIXOS_ACTION</literal> being set to <literal>dry-activate
+              </literal>.  it's important that these activation scripts  don't
+              modify anything about the system when the variable is set.
+            '';
+          };
       };
     in either str (submodule { options = scriptOptions; });
 
@@ -74,47 +122,19 @@ in
         idempotent and fast.
       '';
 
-      type = types.attrsOf scriptType;
-
-      apply = set: {
-        script =
-          ''
-            #! ${pkgs.runtimeShell}
-
-            systemConfig=@out@
-
-            export PATH=/empty
-            for i in ${toString path}; do
-                PATH=$PATH:$i/bin:$i/sbin
-            done
-
-            _status=0
-            trap "_status=1 _localstatus=\$?" ERR
-
-            # Ensure a consistent umask.
-            umask 0022
-
-            ${
-              let
-                set' = mapAttrs (n: v: if isString v then noDepEntry v else v) set;
-                withHeadlines = addAttributeName set';
-              in textClosureMap id (withHeadlines) (attrNames withHeadlines)
-            }
-
-            # Make this configuration the current configuration.
-            # The readlink is there to ensure that when $systemConfig = /system
-            # (which is a symlink to the store), /run/current-system is still
-            # used as a garbage collection root.
-            ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
-
-            # Prevent the current configuration from being garbage-collected.
-            ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
-
-            exit $_status
-          '';
+      type = types.attrsOf (scriptType true);
+      apply = set: set // {
+        script = systemActivationScript set false;
       };
     };
 
+    system.dryActivationScript = mkOption {
+      description = "The shell script that is to be run when dry-activating a system.";
+      readOnly = true;
+      internal = true;
+      default = systemActivationScript (removeAttrs config.system.activationScripts [ "script" ]) true;
+    };
+
     system.userActivationScripts = mkOption {
       default = {};
 
@@ -137,7 +157,7 @@ in
         idempotent and fast.
       '';
 
-      type = with types; attrsOf scriptType;
+      type = with types; attrsOf (scriptType false);
 
       apply = set: {
         script = ''
diff --git a/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl b/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl
index dd391c8b5d78..b7a062755296 100644
--- a/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl
+++ b/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl
@@ -36,6 +36,8 @@ EOF
     exit 1;
 }
 
+$ENV{NIXOS_ACTION} = $action;
+
 # This is a NixOS installation if it has /etc/NIXOS or a proper
 # /etc/os-release.
 die "This is not a NixOS installation!\n" unless
@@ -360,6 +362,10 @@ if ($action eq "dry-activate") {
         if scalar @unitsToStopFiltered > 0;
     print STDERR "would NOT stop the following changed units: ", join(", ", sort(keys %unitsToSkip)), "\n"
         if scalar(keys %unitsToSkip) > 0;
+
+    print STDERR "would activate the configuration...\n";
+    system("$out/dry-activate", "$out");
+
     print STDERR "would restart systemd\n" if $restartSystemd;
     print STDERR "would restart the following units: ", join(", ", sort(keys %unitsToRestart)), "\n"
         if scalar(keys %unitsToRestart) > 0;
diff --git a/nixpkgs/nixos/modules/system/activation/top-level.nix b/nixpkgs/nixos/modules/system/activation/top-level.nix
index d3e4923a993f..616e1422aa8c 100644
--- a/nixpkgs/nixos/modules/system/activation/top-level.nix
+++ b/nixpkgs/nixos/modules/system/activation/top-level.nix
@@ -56,9 +56,13 @@ let
       ''}
 
       echo "$activationScript" > $out/activate
+      echo "$dryActivationScript" > $out/dry-activate
       substituteInPlace $out/activate --subst-var out
-      chmod u+x $out/activate
-      unset activationScript
+      substituteInPlace $out/dry-activate --subst-var out
+      chmod u+x $out/activate $out/dry-activate
+      unset activationScript dryActivationScript
+      ${pkgs.runtimeShell} -n $out/activate
+      ${pkgs.runtimeShell} -n $out/dry-activate
 
       cp ${config.system.build.bootStage2} $out/init
       substituteInPlace $out/init --subst-var-by systemConfig $out
@@ -108,6 +112,7 @@ let
       config.system.build.installBootLoader
       or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true";
     activationScript = config.system.activationScripts.script;
+    dryActivationScript = config.system.dryActivationScript;
     nixosLabel = config.system.nixos.label;
 
     configurationName = config.boot.loader.grub.configurationName;
diff --git a/nixpkgs/nixos/modules/tasks/lvm.nix b/nixpkgs/nixos/modules/tasks/lvm.nix
index 98a0e2ddef90..aaa76b49fa30 100644
--- a/nixpkgs/nixos/modules/tasks/lvm.nix
+++ b/nixpkgs/nixos/modules/tasks/lvm.nix
@@ -46,22 +46,32 @@ in {
         kernelModules = [ "dm-snapshot" "dm-thin-pool" ];
 
         extraUtilsCommands = ''
-          copy_bin_and_libs ${pkgs.thin-provisioning-tools}/bin/pdata_tools
-          copy_bin_and_libs ${pkgs.thin-provisioning-tools}/bin/thin_check
+          for BIN in ${pkgs.thin-provisioning-tools}/bin/*; do
+            copy_bin_and_libs $BIN
+          done
+        '';
+
+        extraUtilsCommandsTest = ''
+          ls ${pkgs.thin-provisioning-tools}/bin/ | grep -v pdata_tools | while read BIN; do
+            $out/bin/$(basename $BIN) --help > /dev/null
+          done
         '';
       };
 
-      environment.etc."lvm/lvm.conf".text = ''
-        global/thin_check_executable = "${pkgs.thin-provisioning-tools}/bin/thin_check"
-      '';
+      environment.etc."lvm/lvm.conf".text = concatMapStringsSep "\n"
+        (bin: "global/${bin}_executable = ${pkgs.thin-provisioning-tools}/bin/${bin}")
+        [ "thin_check" "thin_dump" "thin_repair" "cache_check" "cache_dump" "cache_repair" ];
     })
     (mkIf (cfg.dmeventd.enable || cfg.boot.thin.enable) {
       boot.initrd.preLVMCommands = ''
           mkdir -p /etc/lvm
           cat << EOF >> /etc/lvm/lvm.conf
-          ${optionalString cfg.boot.thin.enable ''
-            global/thin_check_executable = "$(command -v thin_check)"
-          ''}
+          ${optionalString cfg.boot.thin.enable (
+            concatMapStringsSep "\n"
+              (bin: "global/${bin}_executable = $(command -v ${bin})")
+              [ "thin_check" "thin_dump" "thin_repair" "cache_check" "cache_dump" "cache_repair" ]
+            )
+          }
           ${optionalString cfg.dmeventd.enable ''
             dmeventd/executable = "$(command -v false)"
             activation/monitoring = 0
diff --git a/nixpkgs/nixos/tests/handbrake.nix b/nixpkgs/nixos/tests/handbrake.nix
index 226dc8b2aa8a..c92fb5db7d6c 100644
--- a/nixpkgs/nixos/tests/handbrake.nix
+++ b/nixpkgs/nixos/tests/handbrake.nix
@@ -9,7 +9,7 @@ in {
   name = "handbrake";
 
   meta = {
-    maintainers = with pkgs.lib.maintainers; [ danieldk ];
+    maintainers = with pkgs.lib.maintainers; [ ];
   };
 
   machine = { pkgs, ... }: {
diff --git a/nixpkgs/nixos/tests/kernel-generic.nix b/nixpkgs/nixos/tests/kernel-generic.nix
index 391a93e36981..e88b60d33534 100644
--- a/nixpkgs/nixos/tests/kernel-generic.nix
+++ b/nixpkgs/nixos/tests/kernel-generic.nix
@@ -32,6 +32,7 @@ let
       linuxPackages_5_4
       linuxPackages_5_10
       linuxPackages_5_13
+      linuxPackages_5_14
 
       linuxPackages_4_14_hardened
       linuxPackages_4_19_hardened
diff --git a/nixpkgs/nixos/tests/miniflux.nix b/nixpkgs/nixos/tests/miniflux.nix
index 9a25a9e77cc9..1015550fa8c7 100644
--- a/nixpkgs/nixos/tests/miniflux.nix
+++ b/nixpkgs/nixos/tests/miniflux.nix
@@ -11,7 +11,7 @@ in
 with lib;
 {
   name = "miniflux";
-  meta.maintainers = with pkgs.lib.maintainers; [ bricewge ];
+  meta.maintainers = with pkgs.lib.maintainers; [ ];
 
   nodes = {
     default =
diff --git a/nixpkgs/nixos/tests/mutable-users.nix b/nixpkgs/nixos/tests/mutable-users.nix
index e3f002d9b198..ebe32e6487ef 100644
--- a/nixpkgs/nixos/tests/mutable-users.nix
+++ b/nixpkgs/nixos/tests/mutable-users.nix
@@ -12,6 +12,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
     };
     mutable = { ... }: {
       users.mutableUsers = true;
+      users.users.dry-test.isNormalUser = true;
     };
   };
 
@@ -41,5 +42,32 @@ import ./make-test-python.nix ({ pkgs, ...} : {
             "${mutableSystem}/bin/switch-to-configuration test"
         )
         assert "/run/wrappers/" in machine.succeed("which passwd")
+
+    with subtest("dry-activation does not change files"):
+        machine.succeed('test -e /home/dry-test')  # home was created
+        machine.succeed('rm -rf /home/dry-test')
+
+        files_to_check = ['/etc/group',
+                          '/etc/passwd',
+                          '/etc/shadow',
+                          '/etc/subuid',
+                          '/etc/subgid',
+                          '/var/lib/nixos/uid-map',
+                          '/var/lib/nixos/gid-map',
+                          '/var/lib/nixos/declarative-groups',
+                          '/var/lib/nixos/declarative-users'
+                         ]
+        expected_hashes = {}
+        expected_stats = {}
+        for file in files_to_check:
+            expected_hashes[file] = machine.succeed(f"sha256sum {file}")
+            expected_stats[file] = machine.succeed(f"stat {file}")
+
+        machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate")
+
+        machine.fail('test -e /home/dry-test')  # home was not recreated
+        for file in files_to_check:
+            assert machine.succeed(f"sha256sum {file}") == expected_hashes[file]
+            assert machine.succeed(f"stat {file}") == expected_stats[file]
   '';
 })