1<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">
2 <title>Installing NixOS</title>
3 <section xml:id="sec-installation-booting">
4 <title>Booting from the install medium</title>
5 <para>
6 To begin the installation, you have to boot your computer from the
7 install drive.
8 </para>
9 <orderedlist numeration="arabic">
10 <listitem>
11 <para>
12 Plug in the install drive. Then turn on or restart your
13 computer.
14 </para>
15 </listitem>
16 <listitem>
17 <para>
18 Open the boot menu by pressing the appropriate key, which is
19 usually shown on the display on early boot. Select the USB
20 flash drive (the option usually contains the word
21 <quote>USB</quote>). If you choose the incorrect drive, your
22 computer will likely continue to boot as normal. In that case
23 restart your computer and pick a different drive.
24 </para>
25 <note>
26 <para>
27 The key to open the boot menu is different across computer
28 brands and even models. It can be <keycap>F12</keycap>, but
29 also <keycap>F1</keycap>, <keycap>F9</keycap>,
30 <keycap>F10</keycap>, <keycap>Enter</keycap>,
31 <keycap>Del</keycap>, <keycap>Esc</keycap> or another
32 function key. If you are unsure and don’t see it on the
33 early boot screen, you can search online for your computers
34 brand, model followed by <quote>boot from usb</quote>. The
35 computer might not even have that feature, so you have to go
36 into the BIOS/UEFI settings to change the boot order. Again,
37 search online for details about your specific computer
38 model.
39 </para>
40 <para>
41 For Apple computers with Intel processors press and hold the
42 <keycap>⌥</keycap> (Option or Alt) key until you see the
43 boot menu. On Apple silicon press and hold the power button.
44 </para>
45 </note>
46 <note>
47 <para>
48 If your computer supports both BIOS and UEFI boot, choose
49 the UEFI option.
50 </para>
51 </note>
52 <note>
53 <para>
54 If you use a CD for the installation, the computer will
55 probably boot from it automatically. If not, choose the
56 option containing the word <quote>CD</quote> from the boot
57 menu.
58 </para>
59 </note>
60 </listitem>
61 <listitem>
62 <para>
63 Shortly after selecting the appropriate boot drive, you should
64 be presented with a menu with different installer options.
65 Leave the default and wait (or press <keycap>Enter</keycap> to
66 speed up).
67 </para>
68 </listitem>
69 <listitem>
70 <para>
71 The graphical images will start their corresponding desktop
72 environment and the graphical installer, which can take some
73 time. The minimal images will boot to a command line. You have
74 to follow the instructions in
75 <xref linkend="sec-installation-manual" /> there.
76 </para>
77 </listitem>
78 </orderedlist>
79 </section>
80 <section xml:id="sec-installation-graphical">
81 <title>Graphical Installation</title>
82 <para>
83 The graphical installer is recommended for desktop users and will
84 guide you through the installation.
85 </para>
86 <orderedlist numeration="arabic">
87 <listitem>
88 <para>
89 In the <quote>Welcome</quote> screen, you can select the
90 language of the Installer and the installed system.
91 </para>
92 <tip>
93 <para>
94 Leaving the language as <quote>American English</quote> will
95 make it easier to search for error messages in a search
96 engine or to report an issue.
97 </para>
98 </tip>
99 </listitem>
100 <listitem>
101 <para>
102 Next you should choose your location to have the timezone set
103 correctly. You can actually click on the map!
104 </para>
105 <note>
106 <para>
107 The installer will use an online service to guess your
108 location based on your public IP address.
109 </para>
110 </note>
111 </listitem>
112 <listitem>
113 <para>
114 Then you can select the keyboard layout. The default keyboard
115 model should work well with most desktop keyboards. If you
116 have a special keyboard or notebook, your model might be in
117 the list. Select the language you are most comfortable typing
118 in.
119 </para>
120 </listitem>
121 <listitem>
122 <para>
123 On the <quote>Users</quote> screen, you have to type in your
124 display name, login name and password. You can also enable an
125 option to automatically login to the desktop.
126 </para>
127 </listitem>
128 <listitem>
129 <para>
130 Then you have the option to choose a desktop environment. If
131 you want to create a custom setup with a window manager, you
132 can select <quote>No desktop</quote>.
133 </para>
134 <tip>
135 <para>
136 If you don’t have a favorite desktop and don’t know which
137 one to choose, you can stick to either GNOME or Plasma. They
138 have a quite different design, so you should choose
139 whichever you like better. They are both popular choices and
140 well tested on NixOS.
141 </para>
142 </tip>
143 </listitem>
144 <listitem>
145 <para>
146 You have the option to allow unfree software in the next
147 screen.
148 </para>
149 </listitem>
150 <listitem>
151 <para>
152 The easiest option in the <quote>Partitioning</quote> screen
153 is <quote>Erase disk</quote>, which will delete all data from
154 the selected disk and install the system on it. Also select
155 <quote>Swap (with Hibernation)</quote> in the dropdown below
156 it. You have the option to encrypt the whole disk with LUKS.
157 </para>
158 <note>
159 <para>
160 At the top left you see if the Installer was booted with
161 BIOS or UEFI. If you know your system supports UEFI and it
162 shows <quote>BIOS</quote>, reboot with the correct option.
163 </para>
164 </note>
165 <warning>
166 <para>
167 Make sure you have selected the correct disk at the top and
168 that no valuable data is still on the disk! It will be
169 deleted when formatting the disk.
170 </para>
171 </warning>
172 </listitem>
173 <listitem>
174 <para>
175 Check the choices you made in the <quote>Summary</quote> and
176 click <quote>Install</quote>.
177 </para>
178 <note>
179 <para>
180 The installation takes about 15 minutes. The time varies
181 based on the selected desktop environment, internet
182 connection speed and disk write speed.
183 </para>
184 </note>
185 </listitem>
186 <listitem>
187 <para>
188 When the install is complete, remove the USB flash drive and
189 reboot into your new system!
190 </para>
191 </listitem>
192 </orderedlist>
193 </section>
194 <section xml:id="sec-installation-manual">
195 <title>Manual Installation</title>
196 <para>
197 NixOS can be installed on BIOS or UEFI systems. The procedure for
198 a UEFI installation is broadly the same as for a BIOS
199 installation. The differences are mentioned in the following
200 steps.
201 </para>
202 <para>
203 The NixOS manual is available by running
204 <literal>nixos-help</literal> in the command line or from the
205 application menu in the desktop environment.
206 </para>
207 <para>
208 To have access to the command line on the graphical images, open
209 Terminal (GNOME) or Konsole (Plasma) from the application menu.
210 </para>
211 <para>
212 You are logged-in automatically as <literal>nixos</literal>. The
213 <literal>nixos</literal> user account has an empty password so you
214 can use <literal>sudo</literal> without a password:
215 </para>
216 <programlisting>
217$ sudo -i
218</programlisting>
219 <para>
220 You can use <literal>loadkeys</literal> to switch to your
221 preferred keyboard layout. (We even provide neo2 via
222 <literal>loadkeys de neo</literal>!)
223 </para>
224 <para>
225 If the text is too small to be legible, try
226 <literal>setfont ter-v32n</literal> to increase the font size.
227 </para>
228 <para>
229 To install over a serial port connect with
230 <literal>115200n8</literal> (e.g.
231 <literal>picocom -b 115200 /dev/ttyUSB0</literal>). When the
232 bootloader lists boot entries, select the serial console boot
233 entry.
234 </para>
235 <section xml:id="sec-installation-manual-networking">
236 <title>Networking in the installer</title>
237 <para>
238 <anchor xml:id="sec-installation-booting-networking" />
239 <!-- legacy anchor -->
240 </para>
241 <para>
242 The boot process should have brought up networking (check
243 <literal>ip a</literal>). Networking is necessary for the
244 installer, since it will download lots of stuff (such as source
245 tarballs or Nixpkgs channel binaries). It’s best if you have a
246 DHCP server on your network. Otherwise configure networking
247 manually using <literal>ifconfig</literal>.
248 </para>
249 <para>
250 On the graphical installer, you can configure the network, wifi
251 included, through NetworkManager. Using the
252 <literal>nmtui</literal> program, you can do so even in a
253 non-graphical session. If you prefer to configure the network
254 manually, disable NetworkManager with
255 <literal>systemctl stop NetworkManager</literal>.
256 </para>
257 <para>
258 On the minimal installer, NetworkManager is not available, so
259 configuration must be perfomed manually. To configure the wifi,
260 first start wpa_supplicant with
261 <literal>sudo systemctl start wpa_supplicant</literal>, then run
262 <literal>wpa_cli</literal>. For most home networks, you need to
263 type in the following commands:
264 </para>
265 <programlisting>
266> add_network
2670
268> set_network 0 ssid "myhomenetwork"
269OK
270> set_network 0 psk "mypassword"
271OK
272> set_network 0 key_mgmt WPA-PSK
273OK
274> enable_network 0
275OK
276</programlisting>
277 <para>
278 For enterprise networks, for example
279 <emphasis>eduroam</emphasis>, instead do:
280 </para>
281 <programlisting>
282> add_network
2830
284> set_network 0 ssid "eduroam"
285OK
286> set_network 0 identity "myname@example.com"
287OK
288> set_network 0 password "mypassword"
289OK
290> set_network 0 key_mgmt WPA-EAP
291OK
292> enable_network 0
293OK
294</programlisting>
295 <para>
296 When successfully connected, you should see a line such as this
297 one
298 </para>
299 <programlisting>
300<3>CTRL-EVENT-CONNECTED - Connection to 32:85:ab:ef:24:5c completed [id=0 id_str=]
301</programlisting>
302 <para>
303 you can now leave <literal>wpa_cli</literal> by typing
304 <literal>quit</literal>.
305 </para>
306 <para>
307 If you would like to continue the installation from a different
308 machine you can use activated SSH daemon. You need to copy your
309 ssh key to either
310 <literal>/home/nixos/.ssh/authorized_keys</literal> or
311 <literal>/root/.ssh/authorized_keys</literal> (Tip: For
312 installers with a modifiable filesystem such as the sd-card
313 installer image a key can be manually placed by mounting the
314 image on a different machine). Alternatively you must set a
315 password for either <literal>root</literal> or
316 <literal>nixos</literal> with <literal>passwd</literal> to be
317 able to login.
318 </para>
319 </section>
320 <section xml:id="sec-installation-manual-partitioning">
321 <title>Partitioning and formatting</title>
322 <para>
323 <anchor xml:id="sec-installation-partitioning" />
324 <!-- legacy anchor -->
325 </para>
326 <para>
327 The NixOS installer doesn’t do any partitioning or formatting,
328 so you need to do that yourself.
329 </para>
330 <para>
331 The NixOS installer ships with multiple partitioning tools. The
332 examples below use <literal>parted</literal>, but also provides
333 <literal>fdisk</literal>, <literal>gdisk</literal>,
334 <literal>cfdisk</literal>, and <literal>cgdisk</literal>.
335 </para>
336 <para>
337 The recommended partition scheme differs depending if the
338 computer uses <emphasis>Legacy Boot</emphasis> or
339 <emphasis>UEFI</emphasis>.
340 </para>
341 <section xml:id="sec-installation-manual-partitioning-UEFI">
342 <title>UEFI (GPT)</title>
343 <para>
344 <anchor xml:id="sec-installation-partitioning-UEFI" />
345 <!-- legacy anchor -->
346 </para>
347 <para>
348 Here's an example partition scheme for UEFI, using
349 <literal>/dev/sda</literal> as the device.
350 </para>
351 <note>
352 <para>
353 You can safely ignore <literal>parted</literal>'s
354 informational message about needing to update /etc/fstab.
355 </para>
356 </note>
357 <orderedlist numeration="arabic">
358 <listitem>
359 <para>
360 Create a <emphasis>GPT</emphasis> partition table.
361 </para>
362 <programlisting>
363# parted /dev/sda -- mklabel gpt
364</programlisting>
365 </listitem>
366 <listitem>
367 <para>
368 Add the <emphasis>root</emphasis> partition. This will
369 fill the disk except for the end part, where the swap will
370 live, and the space left in front (512MiB) which will be
371 used by the boot partition.
372 </para>
373 <programlisting>
374# parted /dev/sda -- mkpart primary 512MB -8GB
375</programlisting>
376 </listitem>
377 <listitem>
378 <para>
379 Next, add a <emphasis>swap</emphasis> partition. The size
380 required will vary according to needs, here a 8GB one is
381 created.
382 </para>
383 <programlisting>
384# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
385</programlisting>
386 <note>
387 <para>
388 The swap partition size rules are no different than for
389 other Linux distributions.
390 </para>
391 </note>
392 </listitem>
393 <listitem>
394 <para>
395 Finally, the <emphasis>boot</emphasis> partition. NixOS by
396 default uses the ESP (EFI system partition) as its
397 <emphasis>/boot</emphasis> partition. It uses the
398 initially reserved 512MiB at the start of the disk.
399 </para>
400 <programlisting>
401# parted /dev/sda -- mkpart ESP fat32 1MB 512MB
402# parted /dev/sda -- set 3 esp on
403</programlisting>
404 </listitem>
405 </orderedlist>
406 <para>
407 Once complete, you can follow with
408 <xref linkend="sec-installation-manual-partitioning-formatting" />.
409 </para>
410 </section>
411 <section xml:id="sec-installation-manual-partitioning-MBR">
412 <title>Legacy Boot (MBR)</title>
413 <para>
414 <anchor xml:id="sec-installation-partitioning-MBR" />
415 <!-- legacy anchor -->
416 </para>
417 <para>
418 Here's an example partition scheme for Legacy Boot, using
419 <literal>/dev/sda</literal> as the device.
420 </para>
421 <note>
422 <para>
423 You can safely ignore <literal>parted</literal>'s
424 informational message about needing to update /etc/fstab.
425 </para>
426 </note>
427 <orderedlist numeration="arabic">
428 <listitem>
429 <para>
430 Create a <emphasis>MBR</emphasis> partition table.
431 </para>
432 <programlisting>
433# parted /dev/sda -- mklabel msdos
434</programlisting>
435 </listitem>
436 <listitem>
437 <para>
438 Add the <emphasis>root</emphasis> partition. This will
439 fill the the disk except for the end part, where the swap
440 will live.
441 </para>
442 <programlisting>
443# parted /dev/sda -- mkpart primary 1MB -8GB
444</programlisting>
445 </listitem>
446 <listitem>
447 <para>
448 Set the root partition’s boot flag to on. This allows the
449 disk to be booted from.
450 </para>
451 <programlisting>
452# parted /dev/sda -- set 1 boot on
453</programlisting>
454 </listitem>
455 <listitem>
456 <para>
457 Finally, add a <emphasis>swap</emphasis> partition. The
458 size required will vary according to needs, here a 8GB one
459 is created.
460 </para>
461 <programlisting>
462# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
463</programlisting>
464 <note>
465 <para>
466 The swap partition size rules are no different than for
467 other Linux distributions.
468 </para>
469 </note>
470 </listitem>
471 </orderedlist>
472 <para>
473 Once complete, you can follow with
474 <xref linkend="sec-installation-manual-partitioning-formatting" />.
475 </para>
476 </section>
477 <section xml:id="sec-installation-manual-partitioning-formatting">
478 <title>Formatting</title>
479 <para>
480 <anchor xml:id="sec-installation-partitioning-formatting" />
481 <!-- legacy anchor -->
482 </para>
483 <para>
484 Use the following commands:
485 </para>
486 <itemizedlist>
487 <listitem>
488 <para>
489 For initialising Ext4 partitions:
490 <literal>mkfs.ext4</literal>. It is recommended that you
491 assign a unique symbolic label to the file system using
492 the option <literal>-L label</literal>, since this makes
493 the file system configuration independent from device
494 changes. For example:
495 </para>
496 <programlisting>
497# mkfs.ext4 -L nixos /dev/sda1
498</programlisting>
499 </listitem>
500 <listitem>
501 <para>
502 For creating swap partitions: <literal>mkswap</literal>.
503 Again it’s recommended to assign a label to the swap
504 partition: <literal>-L label</literal>. For example:
505 </para>
506 <programlisting>
507# mkswap -L swap /dev/sda2
508</programlisting>
509 </listitem>
510 <listitem>
511 <para>
512 <emphasis role="strong">UEFI systems</emphasis>
513 </para>
514 <para>
515 For creating boot partitions: <literal>mkfs.fat</literal>.
516 Again it’s recommended to assign a label to the boot
517 partition: <literal>-n label</literal>. For example:
518 </para>
519 <programlisting>
520# mkfs.fat -F 32 -n boot /dev/sda3
521</programlisting>
522 </listitem>
523 <listitem>
524 <para>
525 For creating LVM volumes, the LVM commands, e.g.,
526 <literal>pvcreate</literal>, <literal>vgcreate</literal>,
527 and <literal>lvcreate</literal>.
528 </para>
529 </listitem>
530 <listitem>
531 <para>
532 For creating software RAID devices, use
533 <literal>mdadm</literal>.
534 </para>
535 </listitem>
536 </itemizedlist>
537 </section>
538 </section>
539 <section xml:id="sec-installation-manual-installing">
540 <title>Installing</title>
541 <para>
542 <anchor xml:id="sec-installation-installing" />
543 <!-- legacy anchor -->
544 </para>
545 <orderedlist numeration="arabic">
546 <listitem>
547 <para>
548 Mount the target file system on which NixOS should be
549 installed on <literal>/mnt</literal>, e.g.
550 </para>
551 <programlisting>
552# mount /dev/disk/by-label/nixos /mnt
553</programlisting>
554 </listitem>
555 <listitem>
556 <para>
557 <emphasis role="strong">UEFI systems</emphasis>
558 </para>
559 <para>
560 Mount the boot file system on <literal>/mnt/boot</literal>,
561 e.g.
562 </para>
563 <programlisting>
564# mkdir -p /mnt/boot
565# mount /dev/disk/by-label/boot /mnt/boot
566</programlisting>
567 </listitem>
568 <listitem>
569 <para>
570 If your machine has a limited amount of memory, you may want
571 to activate swap devices now
572 (<literal>swapon device</literal>). The installer (or
573 rather, the build actions that it may spawn) may need quite
574 a bit of RAM, depending on your configuration.
575 </para>
576 <programlisting>
577# swapon /dev/sda2
578</programlisting>
579 </listitem>
580 <listitem>
581 <para>
582 You now need to create a file
583 <literal>/mnt/etc/nixos/configuration.nix</literal> that
584 specifies the intended configuration of the system. This is
585 because NixOS has a <emphasis>declarative</emphasis>
586 configuration model: you create or edit a description of the
587 desired configuration of your system, and then NixOS takes
588 care of making it happen. The syntax of the NixOS
589 configuration file is described in
590 <xref linkend="sec-configuration-syntax" />, while a list of
591 available configuration options appears in
592 <xref linkend="ch-options" />. A minimal example is shown in
593 <link linkend="ex-config">Example: NixOS
594 Configuration</link>.
595 </para>
596 <para>
597 The command <literal>nixos-generate-config</literal> can
598 generate an initial configuration file for you:
599 </para>
600 <programlisting>
601# nixos-generate-config --root /mnt
602</programlisting>
603 <para>
604 You should then edit
605 <literal>/mnt/etc/nixos/configuration.nix</literal> to suit
606 your needs:
607 </para>
608 <programlisting>
609# nano /mnt/etc/nixos/configuration.nix
610</programlisting>
611 <para>
612 If you’re using the graphical ISO image, other editors may
613 be available (such as <literal>vim</literal>). If you have
614 network access, you can also install other editors – for
615 instance, you can install Emacs by running
616 <literal>nix-env -f '<nixpkgs>' -iA emacs</literal>.
617 </para>
618 <variablelist>
619 <varlistentry>
620 <term>
621 BIOS systems
622 </term>
623 <listitem>
624 <para>
625 You <emphasis>must</emphasis> set the option
626 <xref linkend="opt-boot.loader.grub.device" /> to
627 specify on which disk the GRUB boot loader is to be
628 installed. Without it, NixOS cannot boot.
629 </para>
630 <para>
631 If there are other operating systems running on the
632 machine before installing NixOS, the
633 <xref linkend="opt-boot.loader.grub.useOSProber" />
634 option can be set to <literal>true</literal> to
635 automatically add them to the grub menu.
636 </para>
637 </listitem>
638 </varlistentry>
639 <varlistentry>
640 <term>
641 UEFI systems
642 </term>
643 <listitem>
644 <para>
645 You must select a boot-loader, either system-boot or
646 GRUB. The recommended option is systemd-boot: set the
647 option
648 <xref linkend="opt-boot.loader.systemd-boot.enable" />
649 to <literal>true</literal>.
650 <literal>nixos-generate-config</literal> should do
651 this automatically for new configurations when booted
652 in UEFI mode.
653 </para>
654 <para>
655 You may want to look at the options starting with
656 <link linkend="opt-boot.loader.efi.canTouchEfiVariables"><literal>boot.loader.efi</literal></link>
657 and
658 <link linkend="opt-boot.loader.systemd-boot.enable"><literal>boot.loader.systemd-boot</literal></link>
659 as well.
660 </para>
661 <para>
662 If you want to use GRUB, set
663 <xref linkend="opt-boot.loader.grub.device" /> to
664 <literal>nodev</literal> and
665 <xref linkend="opt-boot.loader.grub.efiSupport" /> to
666 <literal>true</literal>.
667 </para>
668 <para>
669 With system-boot, you should not need any special
670 configuration to detect other installed systems. With
671 GRUB, set
672 <xref linkend="opt-boot.loader.grub.useOSProber" /> to
673 <literal>true</literal>, but this will only detect
674 windows partitions, not other linux distributions. If
675 you dual boot another linux distribution, use
676 system-boot instead.
677 </para>
678 </listitem>
679 </varlistentry>
680 </variablelist>
681 <para>
682 If you need to configure networking for your machine the
683 configuration options are described in
684 <xref linkend="sec-networking" />. In particular, while wifi
685 is supported on the installation image, it is not enabled by
686 default in the configuration generated by
687 <literal>nixos-generate-config</literal>.
688 </para>
689 <para>
690 Another critical option is <literal>fileSystems</literal>,
691 specifying the file systems that need to be mounted by
692 NixOS. However, you typically don’t need to set it yourself,
693 because <literal>nixos-generate-config</literal> sets it
694 automatically in
695 <literal>/mnt/etc/nixos/hardware-configuration.nix</literal>
696 from your currently mounted file systems. (The configuration
697 file <literal>hardware-configuration.nix</literal> is
698 included from <literal>configuration.nix</literal> and will
699 be overwritten by future invocations of
700 <literal>nixos-generate-config</literal>; thus, you
701 generally should not modify it.) Additionally, you may want
702 to look at
703 <link xlink:href="https://github.com/NixOS/nixos-hardware">Hardware
704 configuration for known-hardware</link> at this point or
705 after installation.
706 </para>
707 <note>
708 <para>
709 Depending on your hardware configuration or type of file
710 system, you may need to set the option
711 <literal>boot.initrd.kernelModules</literal> to include
712 the kernel modules that are necessary for mounting the
713 root file system, otherwise the installed system will not
714 be able to boot. (If this happens, boot from the
715 installation media again, mount the target file system on
716 <literal>/mnt</literal>, fix
717 <literal>/mnt/etc/nixos/configuration.nix</literal> and
718 rerun <literal>nixos-install</literal>.) In most cases,
719 <literal>nixos-generate-config</literal> will figure out
720 the required modules.
721 </para>
722 </note>
723 </listitem>
724 <listitem>
725 <para>
726 Do the installation:
727 </para>
728 <programlisting>
729# nixos-install
730</programlisting>
731 <para>
732 This will install your system based on the configuration you
733 provided. If anything fails due to a configuration problem
734 or any other issue (such as a network outage while
735 downloading binaries from the NixOS binary cache), you can
736 re-run <literal>nixos-install</literal> after fixing your
737 <literal>configuration.nix</literal>.
738 </para>
739 <para>
740 As the last step, <literal>nixos-install</literal> will ask
741 you to set the password for the <literal>root</literal>
742 user, e.g.
743 </para>
744 <programlisting>
745setting root password...
746New password: ***
747Retype new password: ***
748</programlisting>
749 <note>
750 <para>
751 For unattended installations, it is possible to use
752 <literal>nixos-install --no-root-passwd</literal> in order
753 to disable the password prompt entirely.
754 </para>
755 </note>
756 </listitem>
757 <listitem>
758 <para>
759 If everything went well:
760 </para>
761 <programlisting>
762# reboot
763</programlisting>
764 </listitem>
765 <listitem>
766 <para>
767 You should now be able to boot into the installed NixOS. The
768 GRUB boot menu shows a list of <emphasis>available
769 configurations</emphasis> (initially just one). Every time
770 you change the NixOS configuration (see
771 <link linkend="sec-changing-config">Changing
772 Configuration</link>), a new item is added to the menu. This
773 allows you to easily roll back to a previous configuration
774 if something goes wrong.
775 </para>
776 <para>
777 You should log in and change the <literal>root</literal>
778 password with <literal>passwd</literal>.
779 </para>
780 <para>
781 You’ll probably want to create some user accounts as well,
782 which can be done with <literal>useradd</literal>:
783 </para>
784 <programlisting>
785$ useradd -c 'Eelco Dolstra' -m eelco
786$ passwd eelco
787</programlisting>
788 <para>
789 You may also want to install some software. This will be
790 covered in <xref linkend="sec-package-management" />.
791 </para>
792 </listitem>
793 </orderedlist>
794 </section>
795 <section xml:id="sec-installation-manual-summary">
796 <title>Installation summary</title>
797 <para>
798 <anchor xml:id="sec-installation-summary" />
799 <!-- legacy anchor -->
800 </para>
801 <para>
802 To summarise, <link linkend="ex-install-sequence">Example:
803 Commands for Installing NixOS on
804 <literal>/dev/sda</literal></link> shows a typical sequence of
805 commands for installing NixOS on an empty hard drive (here
806 <literal>/dev/sda</literal>). <link linkend="ex-config">Example:
807 NixOS Configuration</link> shows a corresponding configuration
808 Nix expression.
809 </para>
810 <anchor xml:id="ex-partition-scheme-MBR" />
811 <para>
812 <emphasis role="strong">Example: Example partition schemes for
813 NixOS on <literal>/dev/sda</literal> (MBR)</emphasis>
814 </para>
815 <programlisting>
816# parted /dev/sda -- mklabel msdos
817# parted /dev/sda -- mkpart primary 1MB -8GB
818# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
819</programlisting>
820 <anchor xml:id="ex-partition-scheme-UEFI" />
821 <para>
822 <emphasis role="strong">Example: Example partition schemes for
823 NixOS on <literal>/dev/sda</literal> (UEFI)</emphasis>
824 </para>
825 <programlisting>
826# parted /dev/sda -- mklabel gpt
827# parted /dev/sda -- mkpart primary 512MB -8GB
828# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
829# parted /dev/sda -- mkpart ESP fat32 1MB 512MB
830# parted /dev/sda -- set 3 esp on
831</programlisting>
832 <anchor xml:id="ex-install-sequence" />
833 <para>
834 <emphasis role="strong">Example: Commands for Installing NixOS
835 on <literal>/dev/sda</literal></emphasis>
836 </para>
837 <para>
838 With a partitioned disk.
839 </para>
840 <programlisting>
841# mkfs.ext4 -L nixos /dev/sda1
842# mkswap -L swap /dev/sda2
843# swapon /dev/sda2
844# mkfs.fat -F 32 -n boot /dev/sda3 # (for UEFI systems only)
845# mount /dev/disk/by-label/nixos /mnt
846# mkdir -p /mnt/boot # (for UEFI systems only)
847# mount /dev/disk/by-label/boot /mnt/boot # (for UEFI systems only)
848# nixos-generate-config --root /mnt
849# nano /mnt/etc/nixos/configuration.nix
850# nixos-install
851# reboot
852</programlisting>
853 <anchor xml:id="ex-config" />
854 <para>
855 <emphasis role="strong">Example: NixOS Configuration</emphasis>
856 </para>
857 <programlisting>
858{ config, pkgs, ... }: {
859 imports = [
860 # Include the results of the hardware scan.
861 ./hardware-configuration.nix
862 ];
863
864 boot.loader.grub.device = "/dev/sda"; # (for BIOS systems only)
865 boot.loader.systemd-boot.enable = true; # (for UEFI systems only)
866
867 # Note: setting fileSystems is generally not
868 # necessary, since nixos-generate-config figures them out
869 # automatically in hardware-configuration.nix.
870 #fileSystems."/".device = "/dev/disk/by-label/nixos";
871
872 # Enable the OpenSSH server.
873 services.sshd.enable = true;
874}
875</programlisting>
876 </section>
877 </section>
878 <section xml:id="sec-installation-additional-notes">
879 <title>Additional installation notes</title>
880 <xi:include href="installing-usb.section.xml" />
881 <xi:include href="installing-pxe.section.xml" />
882 <xi:include href="installing-kexec.section.xml" />
883 <xi:include href="installing-virtualbox-guest.section.xml" />
884 <xi:include href="installing-from-other-distro.section.xml" />
885 <xi:include href="installing-behind-a-proxy.section.xml" />
886 </section>
887</chapter>