Starting from the debian rescue system:


groupadd nixbld
adduser --ingroup nixbld --no-create-home --disabled-login nixbuilder
vigr

curl -L https://nixos.org/nix/install | sh

. /root/.nix-profile/etc/profile.d/nix.sh
cfdisk /dev/sda
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mount /dev/disk/by-label/nixos /mnt/
nix-channel --add https://nixos.org/channels/nixos-20.03 nixpkgs
nix-env -iE "_: with import <nixpkgs/nixos> { configuration = {}; }; with config.system.build; [ nixos-generate-config nixos-install nixos-enter manual.manpages ]"

nixos-generate-config --root /mnt

editing the configuration.nix, important bits:

 config, pkgs, modulesPath, ... }:
{
  imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];

  boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.extraModulePackages = [ ];

  fileSystems."/" = { device = "/dev/disk/by-label/nixos"; fsType = "ext4"; };
  swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];

  boot.loader.grub.enable = true;
  boot.loader.grub.version = 2;
  boot.loader.grub.device = "/dev/sda"; # set to sdb for install from rescue system only

  networking.hostName = "XXXXXXX"; # Define your hostname.
  networking.interfaces.ens3.ipv4.addresses = [ {
    address = "51.77.201.XXXXXXXX";
    prefixLength = 32;
  } ];
  networking.interfaces.ens3.ipv4.routes = [ {
    address = "51.77.200.1";
    prefixLength = 32;
    options = { dev = "ens3"; };
  } ];
  networking.interfaces.ens3.ipv6.addresses = [ {
    address = "2001:41d0:404:200::XXXXXXXXXXXX";
    prefixLength = 128;
  } ];
  networking.defaultGateway = "51.77.200.1";
  networking.defaultGateway6 = {
    address = "2001:41d0:404:200::1";
    interface = "ens3";
  };
  networking.nameservers = [ "8.8.8.8" ];

I deleted hardware-configuration.nix.

Running the installer:

nixos-install --root /mnt

If anything goes wrong

mount -o bind /dev /mnt/dev
mount -o bind /proc /mnt/proc
mount -o bind /sys /mnt/sys
chroot /mnt /nix/var/nix/profiles/system/activate
chroot /mnt /run/current-system/sw/bin/bash