When I'm working on web stuff I like to mount the docroot into the VM with --mount so I can edit files on the host and see the effects immediately. Unfortunately cache=loose means the guest keeps the old version of the file for random time intervals (sometimes over a minute) so this workflow is blocked.
Before I start working on this I would like to agree on a plan. I had a few ideas:
- add
--mount-cache to specify how all directories are mounted
- extend
--mount to specify mount options on a per-directory basis, eg: --mount,cache=none /host /guest
These involve a bit of work on the command line parsing though and that may become more complex as nixos-shell evolves.
Perhaps it would be better to incorporate VM options into the vm.nix file itself so we can leverage the whole NixOS module system, akin to the way NixOps does it (deployment.targetEnv etc). We may end up with something like this:
{
vm.mounts = {
mountHome = true;
mountNixProfile = true;
# defaults
cache = "loose";
extraMounts = {
# uses defaults defined above
"/tank" = "/tank";
"/var/www" = {
target = "./src";
cache = "none";
};
};
};
# normal NixOS options…
}
I would love to hear your take on this.
When I'm working on web stuff I like to mount the docroot into the VM with
--mountso I can edit files on the host and see the effects immediately. Unfortunatelycache=loosemeans the guest keeps the old version of the file for random time intervals (sometimes over a minute) so this workflow is blocked.Before I start working on this I would like to agree on a plan. I had a few ideas:
--mount-cacheto specify how all directories are mounted--mountto specify mount options on a per-directory basis, eg:--mount,cache=none /host /guestThese involve a bit of work on the command line parsing though and that may become more complex as nixos-shell evolves.
Perhaps it would be better to incorporate VM options into the
vm.nixfile itself so we can leverage the whole NixOS module system, akin to the way NixOps does it (deployment.targetEnvetc). We may end up with something like this:I would love to hear your take on this.