Mic92/nixos-shell

9p cache / VM options

Closed this issue · 3 comments

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.

Mic92 commented

I also thought about additional nixos options because environment variables become tedious to maintain https://github.com/Mic92/nixos-shell#ram

There is an option to pass additional parameters to qemu: https://github.com/nix-community/nixos-generators/blob/master/formats/vm.nix#L7
This could be extended for nixos-shell.

Mic92 commented

All options should be namespaced by some prefix like nixos-shell so we never collide with nixpkgs itself.

Mic92 commented

This one should be fixed by now.