Nixos-shell: Difference between revisions

imported>Mic92
fix typo
imported>Onny
Add example with mounting directories
Line 11: Line 11:
== Usage ==
== Usage ==


== Simple port forward  ==
Create a single example file containing the system configuration for the virtual machine
Create a single example file containing the system configuration for the virtual machine


Line 30: Line 31:


After the VM is successfully booted, DokuWiki will be available on http://localhost:8080
After the VM is successfully booted, DokuWiki will be available on http://localhost:8080
== Mounting host directories ==
This snippet mounts the directory <code>calendar</code> which resides in the working directory where you run nixos-shell on the host. It gets mounted to <code>/var/lib/nextcloud/store-apps/calendar</code> on the guest. The target directory must exist before mounting gets executed.
{{file|myvm.nix|nix|<nowiki>
{ pkgs, ... }: {
  nixos-shell.mounts.extraMounts = {
    "/var/lib/nextcloud/store-apps/calendar" = {
      target = ./calendar;
      cache = "none";
    };
};
</nowiki>}}
Mounting is done through the network filesystem protocol 9p. Currently [https://github.com/Mic92/nixos-shell/issues/71 it's not possible] to mount the target directory with a specific UID/GID, so you'll have to change the permissions on the host directory according to your needs.