1 <refentry xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xmlns:xi="http://www.w3.org/2001/XInclude">
5 <refentrytitle><command>nixos-install</command>
6 </refentrytitle><manvolnum>8</manvolnum>
7 <refmiscinfo class="source">NixOS</refmiscinfo>
8 <!-- <refmiscinfo class="version"><xi:include href="version.txt" parse="text"/></refmiscinfo> -->
11 <refname><command>nixos-install</command></refname>
12 <refpurpose>install bootloader and NixOS</refpurpose>
16 <command>nixos-install</command>
20 <option>--verbose</option>
31 <replaceable>path</replaceable>
36 <option>--root</option>
38 <replaceable>root</replaceable>
43 <option>--system</option>
45 <replaceable>path</replaceable>
49 <option>--flake</option> <replaceable>flake-uri</replaceable>
54 <arg choice='plain'><option>--impure</option></arg>
60 <option>--channel</option>
62 <replaceable>channel</replaceable>
67 <option>--no-channel-copy</option>
74 <option>--no-root-password</option>
77 <option>--no-root-passwd</option>
84 <option>--no-bootloader</option>
91 <option>--max-jobs</option>
97 </group> <replaceable>number</replaceable>
101 <option>--cores</option> <replaceable>number</replaceable>
105 <option>--option</option> <replaceable>name</replaceable> <replaceable>value</replaceable>
110 <option>--show-trace</option>
116 <option>--keep-going</option>
122 <option>--help</option>
128 <title>Description</title>
130 This command installs NixOS in the file system mounted on
131 <filename>/mnt</filename>, based on the NixOS configuration specified in
132 <filename>/mnt/etc/nixos/configuration.nix</filename>. It performs the
137 It copies Nix and its dependencies to
138 <filename>/mnt/nix/store</filename>.
143 It runs Nix in <filename>/mnt</filename> to build the NixOS configuration
144 specified in <filename>/mnt/etc/nixos/configuration.nix</filename>.
149 It installs the current channel <quote>nixos</quote> in the target channel
150 profile (unless <option>--no-channel-copy</option> is specified).
155 It installs the GRUB boot loader on the device specified in the option
156 <option>boot.loader.grub.device</option> (unless
157 <option>--no-bootloader</option> is specified), and generates a GRUB
158 configuration file that boots into the NixOS configuration just
164 It prompts you for a password for the root account (unless
165 <option>--no-root-password</option> is specified).
171 This command is idempotent: if it is interrupted or fails due to a temporary
172 problem (e.g. a network issue), you can safely re-run it.
176 <title>Options</title>
178 This command accepts the following options:
182 <term><option>--verbose</option> / <option>-v</option></term>
184 <para>Increases the level of verbosity of diagnostic messages
185 printed on standard error. For each Nix operation, the information
186 printed on standard output is well-defined; any diagnostic
187 information is printed on standard error, never on standard
189 <para>Please note that this option may be specified repeatedly.</para>
194 <option>--root</option>
198 Defaults to <filename>/mnt</filename>. If this option is given, treat the
199 directory <replaceable>root</replaceable> as the root of the NixOS
206 <option>--system</option>
210 If this option is provided, <command>nixos-install</command> will install
211 the specified closure rather than attempt to build one from
212 <filename>/mnt/etc/nixos/configuration.nix</filename>.
215 The closure must be an appropriately configured NixOS system, with boot
216 loader and partition configuration that fits the target host. Such a
217 closure is typically obtained with a command such as <command>nix-build
218 -I nixos-config=./configuration.nix '<nixpkgs/nixos>' -A system
219 --no-out-link</command>
225 <option>--flake</option> <replaceable>flake-uri</replaceable>#<replaceable>name</replaceable>
229 Build the NixOS system from the specified flake.
230 The flake must contain an output named
231 <literal>nixosConfigurations.<replaceable>name</replaceable></literal>.
237 <option>--channel</option>
241 If this option is provided, do not copy the current
242 <quote>nixos</quote> channel to the target host. Instead, use the
243 specified derivation.
253 Add a path to the Nix expression search path. This option may be given
254 multiple times. See the NIX_PATH environment variable for information on
255 the semantics of the Nix search path. Paths added through
256 <replaceable>-I</replaceable> take precedence over NIX_PATH.
262 <option>--max-jobs</option>
269 Sets the maximum number of build jobs that Nix will perform in parallel
270 to the specified number. The default is <literal>1</literal>. A higher
271 value is useful on SMP systems or to exploit I/O latency.
277 <option>--cores</option>
281 Sets the value of the <envar>NIX_BUILD_CORES</envar> environment variable
282 in the invocation of builders. Builders can use this variable at their
283 discretion to control the maximum amount of parallelism. For instance, in
284 Nixpkgs, if the derivation attribute
285 <varname>enableParallelBuilding</varname> is set to
286 <literal>true</literal>, the builder passes the
287 <option>-j<replaceable>N</replaceable></option> flag to GNU Make. The
288 value <literal>0</literal> means that the builder should use all
289 available CPU cores in the system.
295 <option>--option</option> <replaceable>name</replaceable> <replaceable>value</replaceable>
299 Set the Nix configuration option <replaceable>name</replaceable> to
300 <replaceable>value</replaceable>.
306 <option>--show-trace</option>
310 Causes Nix to print out a stack trace in case of Nix expression
317 <option>--keep-going</option>
321 Causes Nix to continue building derivations as far as possible
322 in the face of failed builds.
328 <option>--help</option>
332 Synonym for <command>man nixos-install</command>.
339 <title>Examples</title>
341 A typical NixOS installation is done by creating and mounting a file system
342 on <filename>/mnt</filename>, generating a NixOS configuration in
343 <filename>/mnt/etc/nixos/configuration.nix</filename>, and running
344 <command>nixos-install</command>. For instance, if we want to install NixOS
345 on an <literal>ext4</literal> file system created in
346 <filename>/dev/sda1</filename>:
348 <prompt>$ </prompt>mkfs.ext4 /dev/sda1
349 <prompt>$ </prompt>mount /dev/sda1 /mnt
350 <prompt>$ </prompt>nixos-generate-config --root /mnt
351 <prompt>$ </prompt># edit /mnt/etc/nixos/configuration.nix
352 <prompt>$ </prompt>nixos-install
353 <prompt>$ </prompt>reboot