Install NixOS on a Contabo-VPS
this little guide describes how to bootstrap nix to install nixos on a contabo-vps server:
create /nix
and used tempfs, because otherwise the disk is full quickly
mkdir /nix
mount -t tmpfs tmpfs /nix -o size=5g
create nix-build users
groupadd nixbld
for n in $(seq 1 10); do useradd -c "Nix build user $n" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(command -v nologin)" "nixbld$n"; done
install nix
bash <(curl -L https://nixos.org/nix/install)
. $HOME/.nix-profile/etc/profile.d/nix.sh
nix-channel --add https://nixos.org/channels/nixos-22.05 nixpkgs
setup nixpkgs
nix-env -iE "_: with import <nixpkgs/nixos> { configuration = {}; }; with config.system.build; [ nixos-generate-config nixos-install nixos-enter manual.manpages ]"
Now partition the disks the way you want them and mount them to /mnt
Contabio has UEFI, but I tried multiple methods and only BIOS was working.
mount /dev/sda1 /mnt
nextup generate config
nixos-generate-config --root /mnt
make sure these lines are included in your config:
{ config, lib, pkgs, ... }:
{
boot.initrd = {
availableKernelModules = [
"virtio_pci" # disk
"virtio_scsi" # disk
];
kernelModules = [
"dm-snapshot"
];
};
}
install NixOS
nixos-install
after rebooting make sure the nix-channels are up-to-date
nix-channel --add https://nixos.org/channels/nixos-22.05 nixos
nixos-rebuild switch --upgrade
another method using the official .iso
is explained here