Hi,
I would like to create a (stateless) NixOS VM where /nix is on a separate persistent partition, to cache nix derivations there even when the VM is re-created. The partition would be initially blank, so I would like to essentially copy the /nix of the VM image to that partition if needed, before actually booting the system derivation.
I kind of have an idea how I could implement that: run some service (probably during initrd) which runs nix copy /mnt/vmimageroot/nix/store/$systemderivation /mnt/nixpartition/store/$systemderivation
, then continue with booting with the partition mounted to /nix.
But I’m wondering if there is already something which does this, or if someone has already tried something similar?
This also seems like a great use case of the local overlay store feature, has anyone tried that for NixOS?
Thanks!