1<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-building-image">
2 <title>Building a NixOS (Live) ISO</title>
3 <para>
4 Default live installer configurations are available inside
5 <literal>nixos/modules/installer/cd-dvd</literal>. For building
6 other system images,
7 <link xlink:href="https://github.com/nix-community/nixos-generators">nixos-generators</link>
8 is a good place to start looking at.
9 </para>
10 <para>
11 You have two options:
12 </para>
13 <itemizedlist spacing="compact">
14 <listitem>
15 <para>
16 Use any of those default configurations as is
17 </para>
18 </listitem>
19 <listitem>
20 <para>
21 Combine them with (any of) your host config(s)
22 </para>
23 </listitem>
24 </itemizedlist>
25 <para>
26 System images, such as the live installer ones, know how to enforce
27 configuration settings on wich they immediately depend in order to
28 work correctly.
29 </para>
30 <para>
31 However, if you are confident, you can opt to override those
32 enforced values with <literal>mkForce</literal>.
33 </para>
34 <section xml:id="sec-building-image-instructions">
35 <title>Practical Instructions</title>
36 <programlisting>
37$ git clone https://github.com/NixOS/nixpkgs.git
38$ cd nixpkgs/nixos
39$ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix
40</programlisting>
41 <para>
42 To check the content of an ISO image, mount it like so:
43 </para>
44 <programlisting>
45# mount -o loop -t iso9660 ./result/iso/cd.iso /mnt/iso
46</programlisting>
47 </section>
48 <section xml:id="sec-building-image-tech-notes">
49 <title>Technical Notes</title>
50 <para>
51 The config value enforcement is implemented via
52 <literal>mkImageMediaOverride = mkOverride 60;</literal> and
53 therefore primes over simple value assignments, but also yields to
54 <literal>mkForce</literal>.
55 </para>
56 <para>
57 This property allows image designers to implement in semantically
58 correct ways those configuration values upon which the correct
59 functioning of the image depends.
60 </para>
61 <para>
62 For example, the iso base image overrides those file systems which
63 it needs at a minimum for correct functioning, while the installer
64 base image overrides the entire file system layout because there
65 can’t be any other guarantees on a live medium than those given by
66 the live medium itself. The latter is especially true befor
67 formatting the target block device(s). On the other hand, the
68 netboot iso only overrides its minimum dependencies since netboot
69 images are always made-to-target.
70 </para>
71 </section>
72</chapter>