forked from mirrors/nixpkgs
nixos: nixos/doc/manual/installation/changing-config.xml to CommonMark
This commit is contained in:
parent
e7c482f789
commit
b85403368f
|
@ -0,0 +1,117 @@
|
|||
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-changing-config">
|
||||
<title>Changing the Configuration</title>
|
||||
<para>
|
||||
The file <literal>/etc/nixos/configuration.nix</literal> contains
|
||||
the current configuration of your machine. Whenever you’ve
|
||||
<link linkend="ch-configuration">changed something</link> in that
|
||||
file, you should do
|
||||
</para>
|
||||
<programlisting>
|
||||
# nixos-rebuild switch
|
||||
</programlisting>
|
||||
<para>
|
||||
to build the new configuration, make it the default configuration
|
||||
for booting, and try to realise the configuration in the running
|
||||
system (e.g., by restarting system services).
|
||||
</para>
|
||||
<warning>
|
||||
<para>
|
||||
This command doesn't start/stop
|
||||
<link xlink:href="options.html#opt-systemd.user.services">user
|
||||
services</link> automatically. <literal>nixos-rebuild</literal>
|
||||
only runs a <literal>daemon-reload</literal> for each user with
|
||||
running user services.
|
||||
</para>
|
||||
</warning>
|
||||
<warning>
|
||||
<para>
|
||||
These commands must be executed as root, so you should either run
|
||||
them from a root shell or by prefixing them with
|
||||
<literal>sudo -i</literal>.
|
||||
</para>
|
||||
</warning>
|
||||
<para>
|
||||
You can also do
|
||||
</para>
|
||||
<programlisting>
|
||||
# nixos-rebuild test
|
||||
</programlisting>
|
||||
<para>
|
||||
to build the configuration and switch the running system to it, but
|
||||
without making it the boot default. So if (say) the configuration
|
||||
locks up your machine, you can just reboot to get back to a working
|
||||
configuration.
|
||||
</para>
|
||||
<para>
|
||||
There is also
|
||||
</para>
|
||||
<programlisting>
|
||||
# nixos-rebuild boot
|
||||
</programlisting>
|
||||
<para>
|
||||
to build the configuration and make it the boot default, but not
|
||||
switch to it now (so it will only take effect after the next
|
||||
reboot).
|
||||
</para>
|
||||
<para>
|
||||
You can make your configuration show up in a different submenu of
|
||||
the GRUB 2 boot screen by giving it a different <emphasis>profile
|
||||
name</emphasis>, e.g.
|
||||
</para>
|
||||
<programlisting>
|
||||
# nixos-rebuild switch -p test
|
||||
</programlisting>
|
||||
<para>
|
||||
which causes the new configuration (and previous ones created using
|
||||
<literal>-p test</literal>) to show up in the GRUB submenu
|
||||
<quote>NixOS - Profile 'test'</quote>. This can be useful to
|
||||
separate test configurations from <quote>stable</quote>
|
||||
configurations.
|
||||
</para>
|
||||
<para>
|
||||
Finally, you can do
|
||||
</para>
|
||||
<programlisting>
|
||||
$ nixos-rebuild build
|
||||
</programlisting>
|
||||
<para>
|
||||
to build the configuration but nothing more. This is useful to see
|
||||
whether everything compiles cleanly.
|
||||
</para>
|
||||
<para>
|
||||
If you have a machine that supports hardware virtualisation, you can
|
||||
also test the new configuration in a sandbox by building and running
|
||||
a QEMU <emphasis>virtual machine</emphasis> that contains the
|
||||
desired configuration. Just do
|
||||
</para>
|
||||
<programlisting>
|
||||
$ nixos-rebuild build-vm
|
||||
$ ./result/bin/run-*-vm
|
||||
</programlisting>
|
||||
<para>
|
||||
The VM does not have any data from your host system, so your
|
||||
existing user accounts and home directories will not be available
|
||||
unless you have set <literal>mutableUsers = false</literal>. Another
|
||||
way is to temporarily add the following to your configuration:
|
||||
</para>
|
||||
<programlisting language="bash">
|
||||
users.users.your-user.initialHashedPassword = "test";
|
||||
</programlisting>
|
||||
<para>
|
||||
<emphasis>Important:</emphasis> delete the $hostname.qcow2 file if
|
||||
you have started the virtual machine at least once without the right
|
||||
users, otherwise the changes will not get picked up. You can forward
|
||||
ports on the host to the guest. For instance, the following will
|
||||
forward host port 2222 to guest port 22 (SSH):
|
||||
</para>
|
||||
<programlisting>
|
||||
$ QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm
|
||||
</programlisting>
|
||||
<para>
|
||||
allowing you to log in via SSH (assuming you have set the
|
||||
appropriate passwords or SSH authorized keys):
|
||||
</para>
|
||||
<programlisting>
|
||||
$ ssh -p 2222 localhost
|
||||
</programlisting>
|
||||
</chapter>
|
100
nixos/doc/manual/installation/changing-config.chapter.md
Normal file
100
nixos/doc/manual/installation/changing-config.chapter.md
Normal file
|
@ -0,0 +1,100 @@
|
|||
# Changing the Configuration {#sec-changing-config}
|
||||
|
||||
The file `/etc/nixos/configuration.nix` contains the current
|
||||
configuration of your machine. Whenever you've [changed
|
||||
something](#ch-configuration) in that file, you should do
|
||||
|
||||
```ShellSession
|
||||
# nixos-rebuild switch
|
||||
```
|
||||
|
||||
to build the new configuration, make it the default configuration for
|
||||
booting, and try to realise the configuration in the running system
|
||||
(e.g., by restarting system services).
|
||||
|
||||
::: {.warning}
|
||||
This command doesn\'t start/stop [user services](options.html#opt-systemd.user.services)
|
||||
automatically. `nixos-rebuild` only runs a `daemon-reload` for each user with running
|
||||
user services.
|
||||
:::
|
||||
|
||||
::: {.warning}
|
||||
These commands must be executed as root, so you should either run them
|
||||
from a root shell or by prefixing them with `sudo -i`.
|
||||
:::
|
||||
|
||||
You can also do
|
||||
|
||||
```ShellSession
|
||||
# nixos-rebuild test
|
||||
```
|
||||
|
||||
to build the configuration and switch the running system to it, but
|
||||
without making it the boot default. So if (say) the configuration locks
|
||||
up your machine, you can just reboot to get back to a working
|
||||
configuration.
|
||||
|
||||
There is also
|
||||
|
||||
```ShellSession
|
||||
# nixos-rebuild boot
|
||||
```
|
||||
|
||||
to build the configuration and make it the boot default, but not switch
|
||||
to it now (so it will only take effect after the next reboot).
|
||||
|
||||
You can make your configuration show up in a different submenu of the
|
||||
GRUB 2 boot screen by giving it a different *profile name*, e.g.
|
||||
|
||||
```ShellSession
|
||||
# nixos-rebuild switch -p test
|
||||
```
|
||||
|
||||
which causes the new configuration (and previous ones created using
|
||||
`-p test`) to show up in the GRUB submenu "NixOS - Profile \'test\'".
|
||||
This can be useful to separate test configurations from "stable"
|
||||
configurations.
|
||||
|
||||
Finally, you can do
|
||||
|
||||
```ShellSession
|
||||
$ nixos-rebuild build
|
||||
```
|
||||
|
||||
to build the configuration but nothing more. This is useful to see
|
||||
whether everything compiles cleanly.
|
||||
|
||||
If you have a machine that supports hardware virtualisation, you can
|
||||
also test the new configuration in a sandbox by building and running a
|
||||
QEMU *virtual machine* that contains the desired configuration. Just do
|
||||
|
||||
```ShellSession
|
||||
$ nixos-rebuild build-vm
|
||||
$ ./result/bin/run-*-vm
|
||||
```
|
||||
|
||||
The VM does not have any data from your host system, so your existing
|
||||
user accounts and home directories will not be available unless you have
|
||||
set `mutableUsers = false`. Another way is to temporarily add the
|
||||
following to your configuration:
|
||||
|
||||
```nix
|
||||
users.users.your-user.initialHashedPassword = "test";
|
||||
```
|
||||
|
||||
*Important:* delete the \$hostname.qcow2 file if you have started the
|
||||
virtual machine at least once without the right users, otherwise the
|
||||
changes will not get picked up. You can forward ports on the host to the
|
||||
guest. For instance, the following will forward host port 2222 to guest
|
||||
port 22 (SSH):
|
||||
|
||||
```ShellSession
|
||||
$ QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm
|
||||
```
|
||||
|
||||
allowing you to log in via SSH (assuming you have set the appropriate
|
||||
passwords or SSH authorized keys):
|
||||
|
||||
```ShellSession
|
||||
$ ssh -p 2222 localhost
|
||||
```
|
|
@ -1,97 +0,0 @@
|
|||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="5.0"
|
||||
xml:id="sec-changing-config">
|
||||
<title>Changing the Configuration</title>
|
||||
<para>
|
||||
The file <filename>/etc/nixos/configuration.nix</filename> contains the
|
||||
current configuration of your machine. Whenever you’ve
|
||||
<link linkend="ch-configuration">changed something</link> in that file, you
|
||||
should do
|
||||
<screen>
|
||||
<prompt># </prompt>nixos-rebuild switch
|
||||
</screen>
|
||||
to build the new configuration, make it the default configuration for
|
||||
booting, and try to realise the configuration in the running system (e.g., by
|
||||
restarting system services).
|
||||
<warning>
|
||||
<para>
|
||||
This command doesn't start/stop <link linkend="opt-systemd.user.services">user
|
||||
services</link> automatically. <command>nixos-rebuild</command> only runs a
|
||||
<literal>daemon-reload</literal> for each user with running user services.
|
||||
</para>
|
||||
</warning>
|
||||
</para>
|
||||
<warning>
|
||||
<para>
|
||||
These commands must be executed as root, so you should either run them from
|
||||
a root shell or by prefixing them with <literal>sudo -i</literal>.
|
||||
</para>
|
||||
</warning>
|
||||
<para>
|
||||
You can also do
|
||||
<screen>
|
||||
<prompt># </prompt>nixos-rebuild test
|
||||
</screen>
|
||||
to build the configuration and switch the running system to it, but without
|
||||
making it the boot default. So if (say) the configuration locks up your
|
||||
machine, you can just reboot to get back to a working configuration.
|
||||
</para>
|
||||
<para>
|
||||
There is also
|
||||
<screen>
|
||||
<prompt># </prompt>nixos-rebuild boot
|
||||
</screen>
|
||||
to build the configuration and make it the boot default, but not switch to it
|
||||
now (so it will only take effect after the next reboot).
|
||||
</para>
|
||||
<para>
|
||||
You can make your configuration show up in a different submenu of the GRUB 2
|
||||
boot screen by giving it a different <emphasis>profile name</emphasis>, e.g.
|
||||
<screen>
|
||||
<prompt># </prompt>nixos-rebuild switch -p test
|
||||
</screen>
|
||||
which causes the new configuration (and previous ones created using
|
||||
<literal>-p test</literal>) to show up in the GRUB submenu “NixOS - Profile
|
||||
'test'”. This can be useful to separate test configurations from
|
||||
“stable” configurations.
|
||||
</para>
|
||||
<para>
|
||||
Finally, you can do
|
||||
<screen>
|
||||
<prompt>$ </prompt>nixos-rebuild build
|
||||
</screen>
|
||||
to build the configuration but nothing more. This is useful to see whether
|
||||
everything compiles cleanly.
|
||||
</para>
|
||||
<para>
|
||||
If you have a machine that supports hardware virtualisation, you can also
|
||||
test the new configuration in a sandbox by building and running a QEMU
|
||||
<emphasis>virtual machine</emphasis> that contains the desired configuration.
|
||||
Just do
|
||||
<screen>
|
||||
<prompt>$ </prompt>nixos-rebuild build-vm
|
||||
<prompt>$ </prompt>./result/bin/run-*-vm
|
||||
</screen>
|
||||
The VM does not have any data from your host system, so your existing user
|
||||
accounts and home directories will not be available unless you have set
|
||||
<literal>mutableUsers = false</literal>. Another way is to temporarily add
|
||||
the following to your configuration:
|
||||
<screen>
|
||||
<link linkend="opt-users.users._name_.initialHashedPassword">users.users.your-user.initialHashedPassword</link> = "test";
|
||||
</screen>
|
||||
<emphasis>Important:</emphasis> delete the $hostname.qcow2 file if you have
|
||||
started the virtual machine at least once without the right users, otherwise
|
||||
the changes will not get picked up. You can forward ports on the host to the
|
||||
guest. For instance, the following will forward host port 2222 to guest port
|
||||
22 (SSH):
|
||||
<screen>
|
||||
<prompt>$ </prompt>QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm
|
||||
</screen>
|
||||
allowing you to log in via SSH (assuming you have set the appropriate
|
||||
passwords or SSH authorized keys):
|
||||
<screen>
|
||||
<prompt>$ </prompt>ssh -p 2222 localhost
|
||||
</screen>
|
||||
</para>
|
||||
</chapter>
|
|
@ -12,6 +12,6 @@
|
|||
</partintro>
|
||||
<xi:include href="../from_md/installation/obtaining.chapter.xml" />
|
||||
<xi:include href="installing.xml" />
|
||||
<xi:include href="changing-config.xml" />
|
||||
<xi:include href="../from_md/installation/changing-config.chapter.xml" />
|
||||
<xi:include href="upgrading.xml" />
|
||||
</part>
|
||||
|
|
Loading…
Reference in a new issue