Install NixOS on Liteserver: Difference between revisions
imported>Hugo-Heagren No edit summary |
imported>Hugo-Heagren mNo edit summary |
||
Line 65: | Line 65: | ||
boot.loader.grub.enable = true; | boot.loader.grub.enable = true; | ||
boot.loader.grub.version = 2; | boot.loader.grub.version = 2; | ||
boot.loader.grub.device = "/dev/vda" | boot.loader.grub.device = "/dev/vda"; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 23:01, 23 February 2024
This guide describes how to install NixOS on liteserver, paying special attention to networking using liteserver's provided IPV6 subnets.
Installing the ISO on the vps
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 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
Liteserver provides shell access to your VPS with an in-browser terminal emulator. The icon is a stylised 'VNC' under the 'server information' tab on the page for your VPS. Click the icon to open the terminal emulator. Now follow the NixOS manual, with specific guidance below. Given the above process of installing on the VPS, you should begin at Manual Installation. As the manual suggests, you should run:
sudo -i
Networking in the Installer
You must connect to the internet before proceeding. Even if you intend (as you should) to eventually configure network access declaratively in /etc/nixos/configuration.nix
, during the installation process you will need to configure it non-declaratively by issuing commands in the terminal.
Your liteserver VPS will come with an IPV6 subnet (as described 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: 2a04:52c0:118:fe87::1/64
. Replace the 1 with 2, and the 64 with 48. Then run:
ip addr add <YOUR MODIFIED SUBNET> dev ens3
such as:
ip addr add 2a04:52c0:118:fe87::2/48 dev ens3
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 /<number>
at the very end. So if your IPV6 address is 2a04:52c0:118:fe87::1/64
then the gateway is 2a04:52c0:118::1
.
ip route add default via 2a04:52c0:118::1
Finally, you must configure DNS nameservers. The recommended nameservers for liteserver are listed at the bottom of this knowledgebase article, under the heading 'Recommended IPv6 DNS Resolvers'. Edit the file /etc/resolv.conf
(e.g. with nano /etc/resolv.conf
) and for every DNS resolver address add a new line of the following form:
nameserver <NAMESERVER ADDRESS>
For example, at the time of writing the recommended DNS nameservers are 2a01:6340:1:20:4::10
and 2a04:52c0:130:2a5c::10
. So the lines to add look like this:
nameserver 2a01:6340:1:20:4::10
nameserver 2a04:52c0:130:2a5c::10
For more about this process, see the baeldung article on DNS configuration, and the man page resolv.conf(5)
To test the connection try something like ping www.example.com
. If this returns something meaningful, then the network is succesfully connected.
Partitioning and formatting
Liteserver's VPSs are non-UEFI systems (i.e. 'legacy'). Follow the manual for this type. The manual assumes that /dev/sda
exists (as well as friends like /dev/sda1
, /dev/sda2
, etc.). On VPSs like Liteserver provides, /dev/sda
doesn't exist, but /dev/vda
plays the same role (see this baeldung article for a good explanation of this). Accordingly, substitute /dev/vda
, /dev/vda1
, /dev/vda2
, etc for /dev/sda
, /dev/sda1
, /dev/sda2
, etc in the manual's instructions.
Config
This section deals with what you should put in your /etc/nixos/configuration.nix
.
Boot
Set the following:
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/vda";
Networking
To setup networking, configure:
systemd.network.enable = true;
systemd.network.networks."10-wan" = {
# because the architecture is amd64
matchConfig.Name = "ens3";
networkConfig.DHCP = "ipv4";
address = [
# From liteserver's config for my subnet (on this machine)
"<YOUR MODIFIED SUBNET (from above)>" # e.g. 2a04:52c0:118:fe87::2/48
];
routes = [
{ routeConfig.Gateway = "<YOUR GATEWAY (from above)"; } # e.g. 2a04:52c0:118::1
];
};
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 nixos-install
. Don't run reboot
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.