Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nixinator/0ee87de5356d08bbb0a88685c3ce7fd5 to your computer and use it in GitHub Desktop.
Save nixinator/0ee87de5356d08bbb0a88685c3ce7fd5 to your computer and use it in GitHub Desktop.
#!/bin/sh
sudo -s
parted /dev/vda -- mklabel msdos
parted /dev/vda -- mkpart primary 1MiB -2GiB
parted /dev/vda -- mkpart primary linux-swap -2GiB 100%
mkfs.xfs -L nixos /dev/vda1
mkswap -L swap /dev/vda2
swapon /dev/vda2
mount /dev/disk/by-label/nixos /mnt
nix-channel --add https://nixos.org/channels/nixos-21.11 nixos
nix-channel --update
# generate NixOS config
nixos-generate-config --root /mnt
echo "System configuration.nix:"
tee /mnt/etc/nixos/configuration.nix << EOF
{ config, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
];
environment.systemPackages = with pkgs; [
htop
];
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/vda";
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
passwordAuthentication = false;
challengeResponseAuthentication = false;
permitRootLogin = "no";
};
users.users.kranzes = {
isNormalUser = true;
initialPassword = "ChangeMeVultr";
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOIxgHstqeTdLimsLRe+cdqv6Sgt/dILCrUqQz6Gtxwb kranzes@pongo" ];
};
nix.package = pkgs.nixUnstable;
nix.extraOptions = "experimental-features = nix-command flakes";
programs.vim.defaultEditor = true;
system.stateVersion = "21.11";
}
EOF
nixos-install --no-root-passwd
echo "Done. Now reboot via \"Remove ISO\" on the Vultr web UI."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment