Install NixOS on Liteserver: Difference between revisions

imported>Hugo-Heagren
No edit summary
Klinger (talk | contribs)
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Note|This guide is a work in progress.}}
This guide describes how to install NixOS on [https://liteserver.nl/ liteserver], paying special attention to networking using liteserver's provided IPV6 subnets.
This guide describes how to install NixOS on [https://liteserver.nl/ liteserver], paying special attention to networking using liteserver's provided IPV6 subnets.


Line 6: Line 4:
Register for a VPS with liteserver. You can't select NixOS at this point, but whatever you ''do'' select will be overwritten later (by the NixOS ISO) so it doesn't matter what you choose.
Register for a VPS with liteserver. You can't select NixOS at this point, but whatever you ''do'' select will be overwritten later (by the NixOS ISO) so it doesn't matter what you choose.


Once you have a VPS with liteserver, follow their [https://clients.liteserver.nl/index.php?rp=/knowledgebase/43/How-do-I-install-or-reinstall-my-VPS.html manual installation guide]. The most appropriate ISO is generally the minimal one.
Once you have a VPS with liteserver, follow their [https://clients.liteserver.nl/index.php?rp=/knowledgebase/43/How-do-I-install-or-reinstall-my-VPS.html manual installation guide]. The most appropriate ISO is generally the minimal one. By the end of this process, the 'Boot Order' under Settings/VPS Configuration should have 'CDROM1' (or something similar) ''first'' (on top) and then 'DISK1' (or something similar) ''second''. This is important.


== NixOS installation process ==  
== NixOS installation process ==  
Line 19: Line 17:


Your liteserver VPS will come with an IPV6 subnet (as described [https://clients.liteserver.nl/index.php?rp=/knowledgebase/2/How-do-I-use-my-assigned-IPv6-subnet.html here]). Find the IP address of your subnet in the information area for your VPS: under the 'Server Information' tab, go the 'Settings' subtab (lower down), then on the left go to 'Manage IPV6 Subnets'. There should be one subnet listed, with an IPV6 address. Now to add access to the subnet run:
Your liteserver VPS will come with an IPV6 subnet (as described [https://clients.liteserver.nl/index.php?rp=/knowledgebase/2/How-do-I-use-my-assigned-IPv6-subnet.html here]). Find the IP address of your subnet in the information area for your VPS: under the 'Server Information' tab, go the 'Settings' subtab (lower down), then on the left go to 'Manage IPV6 Subnets'. There should be one subnet listed, with an IPV6 address. Now to add access to the subnet run:
Your subnet will look something like this: <code>2a04:52c0:118:fe87::1/64</code>. Replace the 1 with 2, and the 64 with 48. Then run:


<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
ifconfig ens3 inet6 add <YOUR IPV6 ADDRESS>
ip addr add <YOUR MODIFIED SUBNET> dev ens3
</syntaxhighlight>
</syntaxhighlight>


Your IPV6 address can be abbreviated here (e.g. with <code>::</code> in place of many 0s). See [https://www.ibm.com/docs/en/i/7.4?topic=concepts-ipv6-address-formats the IBM documentation] for more information.
such as:


You may also need to run the following to ensure the network is active:
<syntaxhighlight lang="shell">
ip addr add 2a04:52c0:118:fe87::2/48 dev ens3
</syntaxhighlight>
 
You must then add a gateway. The gateway will be the identical with the IPV6 address above, but without the last clause from the initial part, and without the <code>/<number></code> at the very end. So if your IPV6 address is <code>2a04:52c0:118:fe87::1/64</code> then the gateway is <code>2a04:52c0:118::1</code>.


<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
ifconfig ens3 up
ip route add default via 2a04:52c0:118::1
</syntaxhighlight>
</syntaxhighlight>


Line 47: Line 51:
For more about this process, see [https://www.baeldung.com/linux/dns-resolv-conf-file the baeldung article] on DNS configuration, and the man page <code>resolv.conf(5)</code>
For more about this process, see [https://www.baeldung.com/linux/dns-resolv-conf-file the baeldung article] on DNS configuration, and the man page <code>resolv.conf(5)</code>


To test the connection try something like <code>ping www.example.com</code>. If this returns something meaningful, network is succesfully connected.
To test the connection try something like <code>ping www.example.com</code>. If this returns something meaningful, then the network is succesfully connected.


=== Partitioning and formatting ===
=== Partitioning and formatting ===
Liteserver's VPSs are non-UEFI systems (i.e. 'legacy'). Follow the manual for this type. The manual assumes that <code>/dev/sda</code> exists (as well as friends like <code>/dev/sda1</code>, <code>/dev/sda2</code>, etc.). On VPSs like Liteserver provides, <code>/dev/sda</code> ''doesn't'' exist, but <code>/dev/vda</code> plays the same role (see [https://www.baeldung.com/linux/vda-vs-sda this baeldung article] for a good explanation of this). Accordingly, substitute <code>/dev/vda</code>, <code>/dev/vda1</code>, <code>/dev/vda2</code>, etc for <code>/dev/sda</code>, <code>/dev/sda1</code>, <code>/dev/sda2</code>, etc in the manual's instructions.
Liteserver's VPSs are non-UEFI systems (i.e. 'legacy'). Follow the manual for this type. The manual assumes that <code>/dev/sda</code> exists (as well as friends like <code>/dev/sda1</code>, <code>/dev/sda2</code>, etc.). On VPSs like Liteserver provides, <code>/dev/sda</code> ''doesn't'' exist, but <code>/dev/vda</code> plays the same role (see [https://www.baeldung.com/linux/vda-vs-sda this baeldung article] for a good explanation of this). Accordingly, substitute <code>/dev/vda</code>, <code>/dev/vda1</code>, <code>/dev/vda2</code>, etc for <code>/dev/sda</code>, <code>/dev/sda1</code>, <code>/dev/sda2</code>, etc in the manual's instructions.
=== Config ===
This section deals with what you should put in your <code>/etc/nixos/configuration.nix</code>.
==== Boot ====
Set the following:
<syntaxhighlight lang="shell">
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/vda";
</syntaxhighlight>
==== Networking ====
The below setup does not include DHCP, and instead statically configures both IPV6 and IPV4. The IPV4 is especially important if you want to ssh into your server (which you almost certainly will -- the qemu portal offered by liteserver is not particularly nice to work with). We disable DHCP because it inteferes with such static configuration.
You can find your IPV4 address listed as the 'Primary IP' on the front dashboard after you login to Liteserver's client area. It will look something like '192.0.2.0'. Your IPV4 gateway is your IPV4, with a '1' instead of the final number. So if your IPV4 address is '192.0.2.0', then your gateway is '192.0.2.1'.
<syntaxhighlight lang="nix">
  # We have to use static config (no DHCP)
  # to deal with Liteserver and enable proper SSH
  networking.useDHCP = false;
  systemd.network.enable = true;
  systemd.network.networks."10-wan" = {
    matchConfig.Name = "ens3";
    address = [
      "<YOUR IPV4 ADDRESS>/24" # the '/24' is *not* a typo
      "<YOUR MODIFIED SUBNET (from above)>" # e.g. 2a04:52c0:118:fe87::2/48
    ];
    gateway = [
      "<YOUR IPV4 GATEWAY>"
      "<YOUR GATEWAY (from above)>"
    ];
  };
</syntaxhighlight>
This is a declarative equivalent of the networking done in the CLI above.
=== Install and (re)Boot ===
As the end of the manual says, once you've finished the configuration, run <code>nixos-install</code>. ''Don't'' run <code>reboot</code> as the manual tells you to. Instead, go to the server settings and 'stop' the VPS. Then go to 'Boot Order' under Settings/VPS Configuration, and switch the order of the two entries.
You should ''now'' have 'DISK1' (or something similar) ''first'' (on top) and then 'CDROM1' (or something similar) ''second''.
Now 'start' the VPS with the start button. If all went well, you should see a new GRUB menu and boot into a fresh Nixos system.


[[Category:Guide]]
[[Category:Guide]]
[[Category:Deployment]]