MatthewCroughan / NixThePlanet

Run macOS, Windows and more via a single Nix command, or simple nixosModules
MIT License
534 stars 12 forks source link

How do you increase `diskSize` ? #6

Closed fillon closed 8 months ago

fillon commented 8 months ago

Hi

Great project... loving it

Installed macos and trying to install Xcode and ran out of space (50GB)

How do you setup a bigger diskSize?

MatthewCroughan commented 8 months ago

It is documented in the README.md how to use the makeDarwinImage function, and there is a package option for the macos-ventura module. So if you're familiar with NixOS you should be able to figure out how to use this to set the disk size.

services.macos-ventura = {
  enable = true;
  package = pkgs.makeDarwinImage { diskSizeBytes = 60000000000; };
};

This will incur a full rebuild of the base disk image. I would like to figure out a way of expanding this that doesn't involve a full rebuild of the disk image, by creating a second image that will ssh into the VM and perform resize operations. I will implement this in the future.

MatthewCroughan commented 8 months ago

Actually, that won't work currently, but I'm testing a fix that makes that work here, whilst also adding a test for it to make sure it keeps working.

https://github.com/MatthewCroughan/NixThePlanet/commit/bda55ba4bdfddc7aea0422427031be7194d05764

You can see the CI running for it here https://hercules-ci.com/github/MatthewCroughan/NixThePlanet/jobs/343

fillon commented 8 months ago

Thanks :) I was trying to figure out what I was doing wrong.

Down the track, how would you a force rebuild of the vm? I could not find where the ./macos-ventura.qcow2 is located. Lost of black magic, just 3 months into nix so still in learning phase. But greatly impressed by the possibilities.

MatthewCroughan commented 8 months ago

There's no black magic here, it just puts the qcow2 image into the dataDir option which defaults to /var/lib/nixtheplanet-macos-ventura

https://github.com/MatthewCroughan/NixThePlanet/blob/2dec745defe105e94397f713d4d4ad7caf488884/makeDarwinImage/module.nix#L16-L19

fillon commented 8 months ago

that's what i have . no qcow2 file there

ls -als /var/lib/nixtheplanet-macos-ventura 
 /var/lib/nixtheplanet-macos-ventura -> private/nixtheplanet-macos-ventura
MatthewCroughan commented 8 months ago

It's a symlink to private/nixtheplanet-macos-ventura which you're not looking in.

fillon commented 8 months ago

got it.. feeling dumb now

MatthewCroughan commented 8 months ago

No problem, it can be confusing. The reason it's a symlink into private is because of the systemd DynamicUser option

https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#DynamicUser=

This means the VM is launched in QEMU with a random UID every single time, and systemd chowns the file to the QEMU process each time the service is launched.

rastarr commented 7 months ago

It's a symlink to private/nixtheplanet-macos-ventura which you're not looking in.

How do I go about removing trace of this VM including the created stuff in private/nixtheplanet-macos-ventura ?

MatthewCroughan commented 7 months ago

@rastarr

rm -rf /var/lib/nixtheplanet-macos-ventura
rm -rf /var/lib/private/nixtheplanet-macos-ventura
nix-collect-garbage

TL;DR, the macOS base image is 40G and lives in the /nix/store, removing it is able to be done like shown above, or by manual deletion via nix store delete.

Note, nix-collect-garbage will garbage collect other things on the system automatically, which includes the stuff we just removed, as it is no longer referenced thanks to the rm of the symlinks. If you don't want that then you should nix store delete the macOS base image that was created manually, which is a symlink to the nix store that you can see in /var/lib/private/nixtheplanet-macos-ventura yourself with ls -lah.

rastarr commented 7 months ago

Thanks heaps for the fast reply Matthew I'll check this repo out a bit later if it's needed. Great work on it as well, appreciated

@rastarr


rm -rf /var/lib/nixtheplanet-macos-ventura
rm -rf /var/lib/private/nixtheplanet-macos-ventura
nix-collect-garbage