parent
409934a6e5
commit
51bf2e175e
@ -0,0 +1,74 @@ |
||||
# Building Specific Parts of NixOS {#sec-building-parts} |
||||
|
||||
With the command `nix-build`, you can build specific parts of your NixOS |
||||
configuration. This is done as follows: |
||||
|
||||
```ShellSession |
||||
$ cd /path/to/nixpkgs/nixos |
||||
$ nix-build -A config.option |
||||
``` |
||||
|
||||
where `option` is a NixOS option with type "derivation" (i.e. something |
||||
that can be built). Attributes of interest include: |
||||
|
||||
`system.build.toplevel` |
||||
|
||||
: The top-level option that builds the entire NixOS system. Everything |
||||
else in your configuration is indirectly pulled in by this option. |
||||
This is what `nixos-rebuild` builds and what `/run/current-system` |
||||
points to afterwards. |
||||
|
||||
A shortcut to build this is: |
||||
|
||||
```ShellSession |
||||
$ nix-build -A system |
||||
``` |
||||
|
||||
`system.build.manual.manualHTML` |
||||
|
||||
: The NixOS manual. |
||||
|
||||
`system.build.etc` |
||||
|
||||
: A tree of symlinks that form the static parts of `/etc`. |
||||
|
||||
`system.build.initialRamdisk` , `system.build.kernel` |
||||
|
||||
: The initial ramdisk and kernel of the system. This allows a quick |
||||
way to test whether the kernel and the initial ramdisk boot |
||||
correctly, by using QEMU's `-kernel` and `-initrd` options: |
||||
|
||||
```ShellSession |
||||
$ nix-build -A config.system.build.initialRamdisk -o initrd |
||||
$ nix-build -A config.system.build.kernel -o kernel |
||||
$ qemu-system-x86_64 -kernel ./kernel/bzImage -initrd ./initrd/initrd -hda /dev/null |
||||
``` |
||||
|
||||
`system.build.nixos-rebuild` , `system.build.nixos-install` , `system.build.nixos-generate-config` |
||||
|
||||
: These build the corresponding NixOS commands. |
||||
|
||||
`systemd.units.unit-name.unit` |
||||
|
||||
: This builds the unit with the specified name. Note that since unit |
||||
names contain dots (e.g. `httpd.service`), you need to put them |
||||
between quotes, like this: |
||||
|
||||
```ShellSession |
||||
$ nix-build -A 'config.systemd.units."httpd.service".unit' |
||||
``` |
||||
|
||||
You can also test individual units, without rebuilding the whole |
||||
system, by putting them in `/run/systemd/system`: |
||||
|
||||
```ShellSession |
||||
$ cp $(nix-build -A 'config.systemd.units."httpd.service".unit')/httpd.service \ |
||||
/run/systemd/system/tmp-httpd.service |
||||
# systemctl daemon-reload |
||||
# systemctl start tmp-httpd.service |
||||
``` |
||||
|
||||
Note that the unit must not have the same name as any unit in |
||||
`/etc/systemd/system` since those take precedence over |
||||
`/run/systemd/system`. That's why the unit is installed as |
||||
`tmp-httpd.service` here. |
@ -1,121 +0,0 @@ |
||||
<chapter xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/XInclude" |
||||
version="5.0" |
||||
xml:id="sec-building-parts"> |
||||
<title>Building Specific Parts of NixOS</title> |
||||
<para> |
||||
With the command <command>nix-build</command>, you can build specific parts |
||||
of your NixOS configuration. This is done as follows: |
||||
<screen> |
||||
<prompt>$ </prompt>cd <replaceable>/path/to/nixpkgs/nixos</replaceable> |
||||
<prompt>$ </prompt>nix-build -A config.<replaceable>option</replaceable></screen> |
||||
where <replaceable>option</replaceable> is a NixOS option with type |
||||
“derivation” (i.e. something that can be built). Attributes of interest |
||||
include: |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
<varname>system.build.toplevel</varname> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
The top-level option that builds the entire NixOS system. Everything else |
||||
in your configuration is indirectly pulled in by this option. This is |
||||
what <command>nixos-rebuild</command> builds and what |
||||
<filename>/run/current-system</filename> points to afterwards. |
||||
</para> |
||||
<para> |
||||
A shortcut to build this is: |
||||
<screen> |
||||
<prompt>$ </prompt>nix-build -A system</screen> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<varname>system.build.manual.manualHTML</varname> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
The NixOS manual. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<varname>system.build.etc</varname> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
A tree of symlinks that form the static parts of |
||||
<filename>/etc</filename>. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<varname>system.build.initialRamdisk</varname> |
||||
</term> |
||||
<term> |
||||
<varname>system.build.kernel</varname> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
The initial ramdisk and kernel of the system. This allows a quick way to |
||||
test whether the kernel and the initial ramdisk boot correctly, by using |
||||
QEMU’s <option>-kernel</option> and <option>-initrd</option> options: |
||||
<screen> |
||||
<prompt>$ </prompt>nix-build -A config.system.build.initialRamdisk -o initrd |
||||
<prompt>$ </prompt>nix-build -A config.system.build.kernel -o kernel |
||||
<prompt>$ </prompt>qemu-system-x86_64 -kernel ./kernel/bzImage -initrd ./initrd/initrd -hda /dev/null |
||||
</screen> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<varname>system.build.nixos-rebuild</varname> |
||||
</term> |
||||
<term> |
||||
<varname>system.build.nixos-install</varname> |
||||
</term> |
||||
<term> |
||||
<varname>system.build.nixos-generate-config</varname> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
These build the corresponding NixOS commands. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<varname>systemd.units.<replaceable>unit-name</replaceable>.unit</varname> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
This builds the unit with the specified name. Note that since unit names |
||||
contain dots (e.g. <literal>httpd.service</literal>), you need to put |
||||
them between quotes, like this: |
||||
<screen> |
||||
<prompt>$ </prompt>nix-build -A 'config.systemd.units."httpd.service".unit' |
||||
</screen> |
||||
You can also test individual units, without rebuilding the whole system, |
||||
by putting them in <filename>/run/systemd/system</filename>: |
||||
<screen> |
||||
<prompt>$ </prompt>cp $(nix-build -A 'config.systemd.units."httpd.service".unit')/httpd.service \ |
||||
/run/systemd/system/tmp-httpd.service |
||||
<prompt># </prompt>systemctl daemon-reload |
||||
<prompt># </prompt>systemctl start tmp-httpd.service |
||||
</screen> |
||||
Note that the unit must not have the same name as any unit in |
||||
<filename>/etc/systemd/system</filename> since those take precedence over |
||||
<filename>/run/systemd/system</filename>. That’s why the unit is |
||||
installed as <filename>tmp-httpd.service</filename> here. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</para> |
||||
</chapter> |
@ -0,0 +1,124 @@ |
||||
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-building-parts"> |
||||
<title>Building Specific Parts of NixOS</title> |
||||
<para> |
||||
With the command <literal>nix-build</literal>, you can build |
||||
specific parts of your NixOS configuration. This is done as follows: |
||||
</para> |
||||
<programlisting> |
||||
$ cd /path/to/nixpkgs/nixos |
||||
$ nix-build -A config.option |
||||
</programlisting> |
||||
<para> |
||||
where <literal>option</literal> is a NixOS option with type |
||||
<quote>derivation</quote> (i.e. something that can be built). |
||||
Attributes of interest include: |
||||
</para> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
<literal>system.build.toplevel</literal> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
The top-level option that builds the entire NixOS system. |
||||
Everything else in your configuration is indirectly pulled in |
||||
by this option. This is what <literal>nixos-rebuild</literal> |
||||
builds and what <literal>/run/current-system</literal> points |
||||
to afterwards. |
||||
</para> |
||||
<para> |
||||
A shortcut to build this is: |
||||
</para> |
||||
<programlisting> |
||||
$ nix-build -A system |
||||
</programlisting> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<literal>system.build.manual.manualHTML</literal> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
The NixOS manual. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<literal>system.build.etc</literal> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
A tree of symlinks that form the static parts of |
||||
<literal>/etc</literal>. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<literal>system.build.initialRamdisk</literal> , |
||||
<literal>system.build.kernel</literal> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
The initial ramdisk and kernel of the system. This allows a |
||||
quick way to test whether the kernel and the initial ramdisk |
||||
boot correctly, by using QEMU’s <literal>-kernel</literal> and |
||||
<literal>-initrd</literal> options: |
||||
</para> |
||||
<programlisting> |
||||
$ nix-build -A config.system.build.initialRamdisk -o initrd |
||||
$ nix-build -A config.system.build.kernel -o kernel |
||||
$ qemu-system-x86_64 -kernel ./kernel/bzImage -initrd ./initrd/initrd -hda /dev/null |
||||
</programlisting> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<literal>system.build.nixos-rebuild</literal> , |
||||
<literal>system.build.nixos-install</literal> , |
||||
<literal>system.build.nixos-generate-config</literal> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
These build the corresponding NixOS commands. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
<literal>systemd.units.unit-name.unit</literal> |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
This builds the unit with the specified name. Note that since |
||||
unit names contain dots (e.g. |
||||
<literal>httpd.service</literal>), you need to put them |
||||
between quotes, like this: |
||||
</para> |
||||
<programlisting> |
||||
$ nix-build -A 'config.systemd.units."httpd.service".unit' |
||||
</programlisting> |
||||
<para> |
||||
You can also test individual units, without rebuilding the |
||||
whole system, by putting them in |
||||
<literal>/run/systemd/system</literal>: |
||||
</para> |
||||
<programlisting> |
||||
$ cp $(nix-build -A 'config.systemd.units."httpd.service".unit')/httpd.service \ |
||||
/run/systemd/system/tmp-httpd.service |
||||
# systemctl daemon-reload |
||||
# systemctl start tmp-httpd.service |
||||
</programlisting> |
||||
<para> |
||||
Note that the unit must not have the same name as any unit in |
||||
<literal>/etc/systemd/system</literal> since those take |
||||
precedence over <literal>/run/systemd/system</literal>. That’s |
||||
why the unit is installed as |
||||
<literal>tmp-httpd.service</literal> here. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</chapter> |
Loading…
Reference in new issue