summary refs log tree commit diff
path: root/nixos/doc/manual/man-nixos-install.xml
blob: 84849282e9abd1a48971fa4ab6d263000e5ff4f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<refentry xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:xi="http://www.w3.org/2001/XInclude">
 <refmeta>
  <refentrytitle><command>nixos-install</command>
  </refentrytitle><manvolnum>8</manvolnum>
  <refmiscinfo class="source">NixOS</refmiscinfo>
<!-- <refmiscinfo class="version"><xi:include href="version.txt" parse="text"/></refmiscinfo> -->
 </refmeta>
 <refnamediv>
  <refname><command>nixos-install</command></refname>
  <refpurpose>install bootloader and NixOS</refpurpose>
 </refnamediv>
 <refsynopsisdiv>
  <cmdsynopsis>
   <command>nixos-install</command>
   <arg>
    <group choice='req'>
     <arg choice='plain'>
      <option>--verbose</option>
     </arg>
     <arg choice='plain'>
      <option>-v</option>
     </arg>
    </group>
   </arg>
   <arg>
    <arg choice='plain'>
     <option>-I</option>
    </arg>
     <replaceable>path</replaceable>
   </arg>

   <arg>
    <arg choice='plain'>
     <option>--root</option>
    </arg>
     <replaceable>root</replaceable>
   </arg>

   <arg>
    <arg choice='plain'>
     <option>--system</option>
    </arg>
     <replaceable>path</replaceable>
   </arg>

   <arg>
     <arg choice='plain'>
       <option>--channel</option>
     </arg>
     <replaceable>channel</replaceable>
   </arg>

   <arg>
    <arg choice='plain'>
     <option>--no-channel-copy</option>
    </arg>
   </arg>

   <arg>
    <arg choice='plain'>
     <option>--no-root-passwd</option>
    </arg>
   </arg>

   <arg>
    <arg choice='plain'>
     <option>--no-bootloader</option>
    </arg>
   </arg>

   <arg>
    <group choice='req'>
    <arg choice='plain'>
     <option>--max-jobs</option>
    </arg>

    <arg choice='plain'>
     <option>-j</option>
    </arg>
     </group> <replaceable>number</replaceable>
   </arg>

   <arg>
    <option>--cores</option> <replaceable>number</replaceable>
   </arg>

   <arg>
    <option>--option</option> <replaceable>name</replaceable> <replaceable>value</replaceable>
   </arg>

   <arg>
    <arg choice='plain'>
     <option>--show-trace</option>
    </arg>
   </arg>

   <arg>
    <arg choice='plain'>
     <option>--help</option>
    </arg>
   </arg>
  </cmdsynopsis>
 </refsynopsisdiv>
 <refsection>
  <title>Description</title>
  <para>
   This command installs NixOS in the file system mounted on
   <filename>/mnt</filename>, based on the NixOS configuration specified in
   <filename>/mnt/etc/nixos/configuration.nix</filename>. It performs the
   following steps:
   <itemizedlist>
    <listitem>
     <para>
      It copies Nix and its dependencies to
      <filename>/mnt/nix/store</filename>.
     </para>
    </listitem>
    <listitem>
     <para>
      It runs Nix in <filename>/mnt</filename> to build the NixOS configuration
      specified in <filename>/mnt/etc/nixos/configuration.nix</filename>.
     </para>
    </listitem>
    <listitem>
      <para>
        It installs the current channel <quote>nixos</quote> in the target channel
        profile (unless <option>--no-channel-copy</option> is specified).
      </para>
    </listitem>
    <listitem>
     <para>
      It installs the GRUB boot loader on the device specified in the option
      <option>boot.loader.grub.device</option> (unless
      <option>--no-bootloader</option> is specified), and generates a GRUB
      configuration file that boots into the NixOS configuration just
      installed.
     </para>
    </listitem>
    <listitem>
     <para>
      It prompts you for a password for the root account (unless
      <option>--no-root-passwd</option> is specified).
     </para>
    </listitem>
   </itemizedlist>
  </para>
  <para>
   This command is idempotent: if it is interrupted or fails due to a temporary
   problem (e.g. a network issue), you can safely re-run it.
  </para>
 </refsection>
 <refsection>
  <title>Options</title>
  <para>
   This command accepts the following options:
  </para>
  <variablelist>
   <varlistentry>
    <term><option>--verbose</option> / <option>-v</option></term>
    <listitem>
     <para>Increases the level of verbosity of diagnostic messages
     printed on standard error.  For each Nix operation, the information
     printed on standard output is well-defined; any diagnostic
     information is printed on standard error, never on standard
     output.</para>
     <para>Please note that this option may be specified repeatedly.</para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>--root</option>
    </term>
    <listitem>
     <para>
      Defaults to <filename>/mnt</filename>. If this option is given, treat the
      directory <replaceable>root</replaceable> as the root of the NixOS
      installation.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>--system</option>
    </term>
    <listitem>
     <para>
      If this option is provided, <command>nixos-install</command> will install
      the specified closure rather than attempt to build one from
      <filename>/mnt/etc/nixos/configuration.nix</filename>.
     </para>
     <para>
      The closure must be an appropriately configured NixOS system, with boot
      loader and partition configuration that fits the target host. Such a
      closure is typically obtained with a command such as <command>nix-build
      -I nixos-config=./configuration.nix '&lt;nixpkgs/nixos&gt;' -A system
      --no-out-link</command>
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
     <term>
       <option>--channel</option>
     </term>
     <listitem>
       <para>
         If this option is provided, do not copy the current
         <quote>nixos</quote> channel to the target host. Instead, use the
         specified derivation.
       </para>
     </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>-I</option>
    </term>
    <listitem>
     <para>
      Add a path to the Nix expression search path. This option may be given
      multiple times. See the NIX_PATH environment variable for information on
      the semantics of the Nix search path. Paths added through
      <replaceable>-I</replaceable> take precedence over NIX_PATH.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>--max-jobs</option>
    </term>
    <term>
     <option>-j</option>
    </term>
    <listitem>
     <para>
      Sets the maximum number of build jobs that Nix will perform in parallel
      to the specified number. The default is <literal>1</literal>. A higher
      value is useful on SMP systems or to exploit I/O latency.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>--cores</option>
    </term>
    <listitem>
     <para>
      Sets the value of the <envar>NIX_BUILD_CORES</envar> environment variable
      in the invocation of builders. Builders can use this variable at their
      discretion to control the maximum amount of parallelism. For instance, in
      Nixpkgs, if the derivation attribute
      <varname>enableParallelBuilding</varname> is set to
      <literal>true</literal>, the builder passes the
      <option>-j<replaceable>N</replaceable></option> flag to GNU Make. The
      value <literal>0</literal> means that the builder should use all
      available CPU cores in the system.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>--option</option> <replaceable>name</replaceable> <replaceable>value</replaceable>
    </term>
    <listitem>
     <para>
      Set the Nix configuration option <replaceable>name</replaceable> to
      <replaceable>value</replaceable>.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>--show-trace</option>
    </term>
    <listitem>
     <para>
      Causes Nix to print out a stack trace in case of Nix expression
      evaluation errors.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <option>--help</option>
    </term>
    <listitem>
     <para>
      Synonym for <command>man nixos-install</command>.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsection>
 <refsection>
  <title>Examples</title>
  <para>
   A typical NixOS installation is done by creating and mounting a file system
   on <filename>/mnt</filename>, generating a NixOS configuration in
   <filename>/mnt/etc/nixos/configuration.nix</filename>, and running
   <command>nixos-install</command>. For instance, if we want to install NixOS
   on an <literal>ext4</literal> file system created in
   <filename>/dev/sda1</filename>:
<screen>
<prompt>$ </prompt>mkfs.ext4 /dev/sda1
<prompt>$ </prompt>mount /dev/sda1 /mnt
<prompt>$ </prompt>nixos-generate-config --root /mnt
<prompt>$ </prompt># edit /mnt/etc/nixos/configuration.nix
<prompt>$ </prompt>nixos-install
<prompt>$ </prompt>reboot
</screen>
  </para>
 </refsection>
</refentry>