i don’t use aws anymore, but i did (and still do, with another provider) this, normally from a mounted recovery iso or similar. you should be able to do it on anything hosted on ec2.
what feels wrong? spin the vm up, attach the appropriate ebs volume(s), peep the disk paths (pretty sure aws still does /dev/vd*, ideally you use something in /dev/disk/by-* after working out which one points to the volume you want to use), then nixos-anywhere it with the disko config pointing to those disks in the format you want - nixos-anywhere (uses|can use) disko.
assuming flakes, this becomes nix run github:nix-community/nixos-anywhere -- --flake .#my-cool-vm user@ip.address.goes.here and awayyyyyyyyyyyyyy we go. i’d imagine the command for non-flakes is similarly shaped, and that’d be the only difference.
if you run nixos-anywhere --help you can see the disko modes it offers:
$ nix run github:nix-community/nixos-anywhere -- --help
...
* --disko-mode disko|mount|format
set the disko mode to format, mount or destroy. Default is disko.
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
which map to the disko modes:
$ nix run github:nix-community/disko -- --help
...
* -m, --mode mode
set the mode, either destroy, format, mount, unmount, format,mount or destroy,format,mount
destroy: unmount filesystems and destroy partition tables of the selected disks
format: create partition tables, zpools, lvms, raids and filesystems if they don't exist yet
mount: mount the partitions at the specified root-mountpoint
format,mount: run format and mount in sequence
destroy,format,mount: run all three modes in sequence. Previously known as --mode disko
assuming you have your 200gb nix volume at /dev/vdb and your 200gb home volume at /dev/vdc (with your root at /dev/vda), you can configure disko somewhat like this (apologies if not quite right/idiomatic, pillaged it from the readme and edited it in the discourse reply box):
{
disko.devices = {
disk = {
root = {
device = "/dev/vda";
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
type = "EF00";
size = "500M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "xfs";
mountpoint = "/";
};
};
};
};
};
nix = {
device = "/dev/vdb";
type = "disk";
content = {
type = "gpt";
partitions = {
nix = {
size = "100%";
content = {
type = "filesystem";
format = "xfs";
mountpoint = "/nix";
};
};
};
};
};
home = {
device = "/dev/vdc";
type = "disk";
content = {
type = "gpt";
partitions = {
home = {
size = "100%";
content = {
type = "filesystem";
format = "xfs";
mountpoint = "/home";
};
};
};
};
};
};
};
}
not really. i guess you could cart that ebs volume around to another instance for a laugh because it’s entirely separate, otherwise inside an ec2 instance it’s more or less the same anyway assuming you’re using the same storage class. it would also kinda make snapshotting the store a bit easier using aws’s native tools if you do want a clone of it.