···
<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">
4
-
<title>Booting the system</title>
4
+
<title>Booting from the install medium</title>
6
-
NixOS can be installed on BIOS or UEFI systems. The procedure for
7
-
a UEFI installation is by and large the same as a BIOS
8
-
installation. The differences are mentioned in the steps that
6
+
To begin the installation, you have to boot your computer from the
9
+
<orderedlist numeration="arabic">
12
+
Plug in the install drive. Then turn on or restart your
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.
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
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.
48
+
If your computer supports both BIOS and UEFI boot, choose
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
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
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.
80
+
<section xml:id="sec-installation-graphical">
81
+
<title>Graphical Installation</title>
12
-
The installation media can be burned to a CD, or now more
13
-
commonly, <quote>burned</quote> to a USB drive (see
14
-
<xref linkend="sec-booting-from-usb" />).
83
+
The graphical installer is recommended for desktop users and will
84
+
guide you through the installation.
86
+
<orderedlist numeration="arabic">
89
+
In the <quote>Welcome</quote> screen, you can select the
90
+
language of the Installer and the installed system.
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.
102
+
Next you should choose your location to have the timezone set
103
+
correctly. You can actually click on the map!
107
+
The installer will use an online service to guess your
108
+
location based on your public IP address.
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
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.
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>.
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.
146
+
You have the option to allow unfree software in the next
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.
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.
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.
175
+
Check the choices you made in the <quote>Summary</quote> and
176
+
click <quote>Install</quote>.
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.
188
+
When the install is complete, remove the USB flash drive and
189
+
reboot into your new system!
194
+
<section xml:id="sec-installation-manual">
195
+
<title>Manual Installation</title>
17
-
The installation media contains a basic NixOS installation. When
18
-
it’s finished booting, it should have detected most of your
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
The NixOS manual is available by running
23
-
<literal>nixos-help</literal>.
204
+
<literal>nixos-help</literal> in the command line or from the
205
+
application menu in the desktop environment.
208
+
To have access to the command line on the graphical images, open
209
+
Terminal (GNOME) or Konsole (Plasma) from the application menu.
You are logged-in automatically as <literal>nixos</literal>. The
···
34
-
If you downloaded the graphical ISO image, you can run
35
-
<literal>systemctl start display-manager</literal> to start the
36
-
desktop environment. If you want to continue on the terminal, you
37
-
can use <literal>loadkeys</literal> to switch to your preferred
38
-
keyboard layout. (We even provide neo2 via
220
+
You can use <literal>loadkeys</literal> to switch to your
221
+
preferred keyboard layout. (We even provide neo2 via
<literal>loadkeys de neo</literal>!)
···
bootloader lists boot entries, select the serial console boot
52
-
<section xml:id="sec-installation-booting-networking">
235
+
<section xml:id="sec-installation-manual-networking">
<title>Networking in the installer</title>
238
+
<anchor xml:id="sec-installation-booting-networking" />
239
+
<!-- legacy anchor -->
The boot process should have brought up networking (check
<literal>ip a</literal>). Networking is necessary for the
···
134
-
<section xml:id="sec-installation-partitioning">
135
-
<title>Partitioning and formatting</title>
137
-
The NixOS installer doesn’t do any partitioning or formatting, so
138
-
you need to do that yourself.
141
-
The NixOS installer ships with multiple partitioning tools. The
142
-
examples below use <literal>parted</literal>, but also provides
143
-
<literal>fdisk</literal>, <literal>gdisk</literal>,
144
-
<literal>cfdisk</literal>, and <literal>cgdisk</literal>.
147
-
The recommended partition scheme differs depending if the computer
148
-
uses <emphasis>Legacy Boot</emphasis> or
149
-
<emphasis>UEFI</emphasis>.
151
-
<section xml:id="sec-installation-partitioning-UEFI">
152
-
<title>UEFI (GPT)</title>
320
+
<section xml:id="sec-installation-manual-partitioning">
321
+
<title>Partitioning and formatting</title>
323
+
<anchor xml:id="sec-installation-partitioning" />
324
+
<!-- legacy anchor -->
327
+
The NixOS installer doesn’t do any partitioning or formatting,
328
+
so you need to do that yourself.
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>.
154
-
Here's an example partition scheme for UEFI, using
155
-
<literal>/dev/sda</literal> as the device.
337
+
The recommended partition scheme differs depending if the
338
+
computer uses <emphasis>Legacy Boot</emphasis> or
339
+
<emphasis>UEFI</emphasis>.
341
+
<section xml:id="sec-installation-manual-partitioning-UEFI">
342
+
<title>UEFI (GPT)</title>
159
-
You can safely ignore <literal>parted</literal>'s
160
-
informational message about needing to update /etc/fstab.
344
+
<anchor xml:id="sec-installation-partitioning-UEFI" />
345
+
<!-- legacy anchor -->
348
+
Here's an example partition scheme for UEFI, using
349
+
<literal>/dev/sda</literal> as the device.
163
-
<orderedlist numeration="arabic">
166
-
Create a <emphasis>GPT</emphasis> partition table.
353
+
You can safely ignore <literal>parted</literal>'s
354
+
informational message about needing to update /etc/fstab.
357
+
<orderedlist numeration="arabic">
360
+
Create a <emphasis>GPT</emphasis> partition table.
# parted /dev/sda -- mklabel gpt
174
-
Add the <emphasis>root</emphasis> partition. This will fill
175
-
the disk except for the end part, where the swap will live,
176
-
and the space left in front (512MiB) which will be used by
177
-
the boot partition.
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.
# parted /dev/sda -- mkpart primary 512MB -8GB
185
-
Next, add a <emphasis>swap</emphasis> partition. The size
186
-
required will vary according to needs, here a 8GB one is
379
+
Next, add a <emphasis>swap</emphasis> partition. The size
380
+
required will vary according to needs, here a 8GB one is
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
388
+
The swap partition size rules are no different than for
389
+
other Linux distributions.
194
-
The swap partition size rules are no different than for
195
-
other Linux distributions.
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.
201
-
Finally, the <emphasis>boot</emphasis> partition. NixOS by
202
-
default uses the ESP (EFI system partition) as its
203
-
<emphasis>/boot</emphasis> partition. It uses the initially
204
-
reserved 512MiB at the start of the disk.
# parted /dev/sda -- mkpart ESP fat32 1MB 512MB
# parted /dev/sda -- set 3 esp on
213
-
Once complete, you can follow with
214
-
<xref linkend="sec-installation-partitioning-formatting" />.
217
-
<section xml:id="sec-installation-partitioning-MBR">
218
-
<title>Legacy Boot (MBR)</title>
220
-
Here's an example partition scheme for Legacy Boot, using
221
-
<literal>/dev/sda</literal> as the device.
407
+
Once complete, you can follow with
408
+
<xref linkend="sec-installation-manual-partitioning-formatting" />.
411
+
<section xml:id="sec-installation-manual-partitioning-MBR">
412
+
<title>Legacy Boot (MBR)</title>
414
+
<anchor xml:id="sec-installation-partitioning-MBR" />
415
+
<!-- legacy anchor -->
225
-
You can safely ignore <literal>parted</literal>'s
226
-
informational message about needing to update /etc/fstab.
418
+
Here's an example partition scheme for Legacy Boot, using
419
+
<literal>/dev/sda</literal> as the device.
229
-
<orderedlist numeration="arabic">
232
-
Create a <emphasis>MBR</emphasis> partition table.
423
+
You can safely ignore <literal>parted</literal>'s
424
+
informational message about needing to update /etc/fstab.
427
+
<orderedlist numeration="arabic">
430
+
Create a <emphasis>MBR</emphasis> partition table.
# parted /dev/sda -- mklabel msdos
240
-
Add the <emphasis>root</emphasis> partition. This will fill
241
-
the the disk except for the end part, where the swap will
438
+
Add the <emphasis>root</emphasis> partition. This will
439
+
fill the the disk except for the end part, where the swap
# parted /dev/sda -- mkpart primary 1MB -8GB
250
-
Set the root partition’s boot flag to on. This allows the
251
-
disk to be booted from.
448
+
Set the root partition’s boot flag to on. This allows the
449
+
disk to be booted from.
# parted /dev/sda -- set 1 boot on
259
-
Finally, add a <emphasis>swap</emphasis> partition. The size
260
-
required will vary according to needs, here a 8GiB one is
457
+
Finally, add a <emphasis>swap</emphasis> partition. The
458
+
size required will vary according to needs, here a 8GiB
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
466
+
The swap partition size rules are no different than for
467
+
other Linux distributions.
473
+
Once complete, you can follow with
474
+
<xref linkend="sec-installation-manual-partitioning-formatting" />.
477
+
<section xml:id="sec-installation-manual-partitioning-formatting">
478
+
<title>Formatting</title>
480
+
<anchor xml:id="sec-installation-partitioning-formatting" />
481
+
<!-- legacy anchor -->
484
+
Use the following commands:
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:
497
+
# mkfs.ext4 -L nixos /dev/sda1
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:
507
+
# mkswap -L swap /dev/sda2
512
+
<emphasis role="strong">UEFI systems</emphasis>
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:
520
+
# mkfs.fat -F 32 -n boot /dev/sda3
525
+
For creating LVM volumes, the LVM commands, e.g.,
526
+
<literal>pvcreate</literal>, <literal>vgcreate</literal>,
527
+
and <literal>lvcreate</literal>.
268
-
The swap partition size rules are no different than for
269
-
other Linux distributions.
532
+
For creating software RAID devices, use
533
+
<literal>mdadm</literal>.
275
-
Once complete, you can follow with
276
-
<xref linkend="sec-installation-partitioning-formatting" />.
279
-
<section xml:id="sec-installation-partitioning-formatting">
280
-
<title>Formatting</title>
539
+
<section xml:id="sec-installation-manual-installing">
540
+
<title>Installing</title>
282
-
Use the following commands:
542
+
<anchor xml:id="sec-installation-installing" />
543
+
<!-- legacy anchor -->
545
+
<orderedlist numeration="arabic">
287
-
For initialising Ext4 partitions:
288
-
<literal>mkfs.ext4</literal>. It is recommended that you
289
-
assign a unique symbolic label to the file system using the
290
-
option <literal>-L label</literal>, since this makes the
291
-
file system configuration independent from device changes.
548
+
Mount the target file system on which NixOS should be
549
+
installed on <literal>/mnt</literal>, e.g.
295
-
# mkfs.ext4 -L nixos /dev/sda1
552
+
# mount /dev/disk/by-label/nixos /mnt
300
-
For creating swap partitions: <literal>mkswap</literal>.
301
-
Again it’s recommended to assign a label to the swap
302
-
partition: <literal>-L label</literal>. For example:
557
+
<emphasis role="strong">UEFI systems</emphasis>
560
+
Mount the boot file system on <literal>/mnt/boot</literal>,
305
-
# mkswap -L swap /dev/sda2
564
+
# mkdir -p /mnt/boot
565
+
# mount /dev/disk/by-label/boot /mnt/boot
310
-
<emphasis role="strong">UEFI systems</emphasis>
313
-
For creating boot partitions: <literal>mkfs.fat</literal>.
314
-
Again it’s recommended to assign a label to the boot
315
-
partition: <literal>-n label</literal>. For example:
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.
318
-
# mkfs.fat -F 32 -n boot /dev/sda3
323
-
For creating LVM volumes, the LVM commands, e.g.,
324
-
<literal>pvcreate</literal>, <literal>vgcreate</literal>,
325
-
and <literal>lvcreate</literal>.
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>.
330
-
For creating software RAID devices, use
331
-
<literal>mdadm</literal>.
597
+
The command <literal>nixos-generate-config</literal> can
598
+
generate an initial configuration file for you:
337
-
<section xml:id="sec-installation-installing">
338
-
<title>Installing</title>
339
-
<orderedlist numeration="arabic">
342
-
Mount the target file system on which NixOS should be
343
-
installed on <literal>/mnt</literal>, e.g.
346
-
# mount /dev/disk/by-label/nixos /mnt
351
-
<emphasis role="strong">UEFI systems</emphasis>
354
-
Mount the boot file system on <literal>/mnt/boot</literal>,
358
-
# mkdir -p /mnt/boot
359
-
# mount /dev/disk/by-label/boot /mnt/boot
364
-
If your machine has a limited amount of memory, you may want
365
-
to activate swap devices now
366
-
(<literal>swapon device</literal>). The installer (or rather,
367
-
the build actions that it may spawn) may need quite a bit of
368
-
RAM, depending on your configuration.
376
-
You now need to create a file
377
-
<literal>/mnt/etc/nixos/configuration.nix</literal> that
378
-
specifies the intended configuration of the system. This is
379
-
because NixOS has a <emphasis>declarative</emphasis>
380
-
configuration model: you create or edit a description of the
381
-
desired configuration of your system, and then NixOS takes
382
-
care of making it happen. The syntax of the NixOS
383
-
configuration file is described in
384
-
<xref linkend="sec-configuration-syntax" />, while a list of
385
-
available configuration options appears in
386
-
<xref linkend="ch-options" />. A minimal example is shown in
387
-
<link linkend="ex-config">Example: NixOS Configuration</link>.
390
-
The command <literal>nixos-generate-config</literal> can
391
-
generate an initial configuration file for you:
# nixos-generate-config --root /mnt
397
-
You should then edit
398
-
<literal>/mnt/etc/nixos/configuration.nix</literal> to suit
604
+
You should then edit
605
+
<literal>/mnt/etc/nixos/configuration.nix</literal> to suit
# nano /mnt/etc/nixos/configuration.nix
405
-
If you’re using the graphical ISO image, other editors may be
406
-
available (such as <literal>vim</literal>). If you have
407
-
network access, you can also install other editors – for
408
-
instance, you can install Emacs by running
409
-
<literal>nix-env -f '<nixpkgs>' -iA emacs</literal>.
418
-
You <emphasis>must</emphasis> set the option
419
-
<xref linkend="opt-boot.loader.grub.device" /> to
420
-
specify on which disk the GRUB boot loader is to be
421
-
installed. Without it, NixOS cannot boot.
424
-
If there are other operating systems running on the
425
-
machine before installing NixOS, the
426
-
<xref linkend="opt-boot.loader.grub.useOSProber" />
427
-
option can be set to <literal>true</literal> to
428
-
automatically add them to the grub menu.
438
-
You must select a boot-loader, either system-boot or
439
-
GRUB. The recommended option is systemd-boot: set the
441
-
<xref linkend="opt-boot.loader.systemd-boot.enable" />
442
-
to <literal>true</literal>.
443
-
<literal>nixos-generate-config</literal> should do this
444
-
automatically for new configurations when booted in UEFI
448
-
You may want to look at the options starting with
449
-
<link linkend="opt-boot.loader.efi.canTouchEfiVariables"><literal>boot.loader.efi</literal></link>
451
-
<link linkend="opt-boot.loader.systemd-boot.enable"><literal>boot.loader.systemd-boot</literal></link>
455
-
If you want to use GRUB, set
456
-
<xref linkend="opt-boot.loader.grub.device" /> to
457
-
<literal>nodev</literal> and
458
-
<xref linkend="opt-boot.loader.grub.efiSupport" /> to
459
-
<literal>true</literal>.
462
-
With system-boot, you should not need any special
463
-
configuration to detect other installed systems. With
465
-
<xref linkend="opt-boot.loader.grub.useOSProber" /> to
466
-
<literal>true</literal>, but this will only detect
467
-
windows partitions, not other linux distributions. If
468
-
you dual boot another linux distribution, use
469
-
system-boot instead.
475
-
If you need to configure networking for your machine the
476
-
configuration options are described in
477
-
<xref linkend="sec-networking" />. In particular, while wifi
478
-
is supported on the installation image, it is not enabled by
479
-
default in the configuration generated by
480
-
<literal>nixos-generate-config</literal>.
483
-
Another critical option is <literal>fileSystems</literal>,
484
-
specifying the file systems that need to be mounted by NixOS.
485
-
However, you typically don’t need to set it yourself, because
486
-
<literal>nixos-generate-config</literal> sets it automatically
488
-
<literal>/mnt/etc/nixos/hardware-configuration.nix</literal>
489
-
from your currently mounted file systems. (The configuration
490
-
file <literal>hardware-configuration.nix</literal> is included
491
-
from <literal>configuration.nix</literal> and will be
492
-
overwritten by future invocations of
493
-
<literal>nixos-generate-config</literal>; thus, you generally
494
-
should not modify it.) Additionally, you may want to look at
495
-
<link xlink:href="https://github.com/NixOS/nixos-hardware">Hardware
496
-
configuration for known-hardware</link> at this point or after
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>.
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.
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.
645
+
You must select a boot-loader, either system-boot or
646
+
GRUB. The recommended option is systemd-boot: set the
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
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>
658
+
<link linkend="opt-boot.loader.systemd-boot.enable"><literal>boot.loader.systemd-boot</literal></link>
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>.
669
+
With system-boot, you should not need any special
670
+
configuration to detect other installed systems. With
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.
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>.
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
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
703
+
<link xlink:href="https://github.com/NixOS/nixos-hardware">Hardware
704
+
configuration for known-hardware</link> at this point or
705
+
after installation.
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.
501
-
Depending on your hardware configuration or type of file
502
-
system, you may need to set the option
503
-
<literal>boot.initrd.kernelModules</literal> to include the
504
-
kernel modules that are necessary for mounting the root file
505
-
system, otherwise the installed system will not be able to
506
-
boot. (If this happens, boot from the installation media
507
-
again, mount the target file system on
508
-
<literal>/mnt</literal>, fix
509
-
<literal>/mnt/etc/nixos/configuration.nix</literal> and
510
-
rerun <literal>nixos-install</literal>.) In most cases,
511
-
<literal>nixos-generate-config</literal> will figure out the
726
+
Do the installation:
518
-
Do the installation:
524
-
This will install your system based on the configuration you
525
-
provided. If anything fails due to a configuration problem or
526
-
any other issue (such as a network outage while downloading
527
-
binaries from the NixOS binary cache), you can re-run
528
-
<literal>nixos-install</literal> after fixing your
529
-
<literal>configuration.nix</literal>.
532
-
As the last step, <literal>nixos-install</literal> will ask
533
-
you to set the password for the <literal>root</literal> user,
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>.
740
+
As the last step, <literal>nixos-install</literal> will ask
741
+
you to set the password for the <literal>root</literal>
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.
543
-
For unattended installations, it is possible to use
544
-
<literal>nixos-install --no-root-passwd</literal> in order
545
-
to disable the password prompt entirely.
759
+
If everything went well:
551
-
If everything went well:
559
-
You should now be able to boot into the installed NixOS. The
560
-
GRUB boot menu shows a list of <emphasis>available
561
-
configurations</emphasis> (initially just one). Every time you
562
-
change the NixOS configuration (see
563
-
<link linkend="sec-changing-config">Changing
564
-
Configuration</link>), a new item is added to the menu. This
565
-
allows you to easily roll back to a previous configuration if
566
-
something goes wrong.
569
-
You should log in and change the <literal>root</literal>
570
-
password with <literal>passwd</literal>.
573
-
You’ll probably want to create some user accounts as well,
574
-
which can be done with <literal>useradd</literal>:
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.
777
+
You should log in and change the <literal>root</literal>
778
+
password with <literal>passwd</literal>.
781
+
You’ll probably want to create some user accounts as well,
782
+
which can be done with <literal>useradd</literal>:
$ useradd -c 'Eelco Dolstra' -m eelco
581
-
You may also want to install some software. This will be
582
-
covered in <xref linkend="sec-package-management" />.
587
-
<section xml:id="sec-installation-summary">
588
-
<title>Installation summary</title>
590
-
To summarise, <link linkend="ex-install-sequence">Example:
591
-
Commands for Installing NixOS on
592
-
<literal>/dev/sda</literal></link> shows a typical sequence of
593
-
commands for installing NixOS on an empty hard drive (here
594
-
<literal>/dev/sda</literal>). <link linkend="ex-config">Example:
595
-
NixOS Configuration</link> shows a corresponding configuration Nix
598
-
<anchor xml:id="ex-partition-scheme-MBR" />
600
-
<emphasis role="strong">Example: Example partition schemes for
601
-
NixOS on <literal>/dev/sda</literal> (MBR)</emphasis>
789
+
You may also want to install some software. This will be
790
+
covered in <xref linkend="sec-package-management" />.
795
+
<section xml:id="sec-installation-manual-summary">
796
+
<title>Installation summary</title>
798
+
<anchor xml:id="sec-installation-summary" />
799
+
<!-- legacy anchor -->
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
810
+
<anchor xml:id="ex-partition-scheme-MBR" />
812
+
<emphasis role="strong">Example: Example partition schemes for
813
+
NixOS on <literal>/dev/sda</literal> (MBR)</emphasis>
# parted /dev/sda -- mklabel msdos
# parted /dev/sda -- mkpart primary 1MiB -8GiB
# parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
608
-
<anchor xml:id="ex-partition-scheme-UEFI" />
610
-
<emphasis role="strong">Example: Example partition schemes for
611
-
NixOS on <literal>/dev/sda</literal> (UEFI)</emphasis>
820
+
<anchor xml:id="ex-partition-scheme-UEFI" />
822
+
<emphasis role="strong">Example: Example partition schemes for
823
+
NixOS on <literal>/dev/sda</literal> (UEFI)</emphasis>
# 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
620
-
<anchor xml:id="ex-install-sequence" />
622
-
<emphasis role="strong">Example: Commands for Installing NixOS on
623
-
<literal>/dev/sda</literal></emphasis>
626
-
With a partitioned disk.
832
+
<anchor xml:id="ex-install-sequence" />
834
+
<emphasis role="strong">Example: Commands for Installing NixOS
835
+
on <literal>/dev/sda</literal></emphasis>
838
+
With a partitioned disk.
# mkfs.ext4 -L nixos /dev/sda1
# mkswap -L swap /dev/sda2
···
641
-
<anchor xml:id="ex-config" />
643
-
<emphasis role="strong">Example: NixOS Configuration</emphasis>
853
+
<anchor xml:id="ex-config" />
855
+
<emphasis role="strong">Example: NixOS Configuration</emphasis>
# Include the results of the hardware scan.
···
services.sshd.enable = true;
<section xml:id="sec-installation-additional-notes">
<title>Additional installation notes</title>