diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 40 |
1 files changed, 26 insertions, 14 deletions
@@ -6,12 +6,14 @@ console. Boots in about a second and a quarter. Stable Nix, no flakes. The guest gets: -- the host's Nix store, read-only, with its own closure from local images - for speed (one per layer, see below), and a writable layer on top, so - nix and `nix-shell` work; +- its own closure, from local images (one per layer, see below), as its + store, read-only, without nix; +- or, with the layer `layers/nix.nix` (see below), on top of that the + host's Nix store, read-only, and a writable layer on top of both, so + nix and `nix-shell` work, and `/nixpkgs`: the host's nixpkgs, + read-only, on the guest's `NIX_PATH`; - `/xchg`: the directory `xchg` in the current working directory, shared with the host (and with other VMs started in the same directory); -- `/nixpkgs`: the host's nixpkgs, read-only, on the guest's `NIX_PATH`; - network access only to HTTPS, through a proxy on the host that allows only listed domains, optionally only listed paths. @@ -61,15 +63,24 @@ nix-build pkgs/run-firecracker-vm Leave the guest with `reboot`. -What nix in the guest adds to the store goes to a scratch disk that's -removed when the guest exits. To keep it across boots: +The guest's store is read-only, and there's no nix, unless it has the +nix layer, preferably first, so its image is the same for all guests +with nix (see layers below): + +```sh +nix-build pkgs/run-firecracker-vm --arg layers '[ layers/nix.nix ./my-service.nix ]' +``` + +What nix in such a guest adds to the store goes to a disk of its own, +which the run script then requires (and refuses for a guest without nix, +like `--nixpkgs` and `--nixpkgs-cache`, below): ```sh ./result/bin/run-firecracker-vm --store ~/fc-store.img [--store-size 50G] ``` The file gets created (sparse, default 16G) if it doesn't exist. Only one -VM at a time can use it. `/home` is gone when the guest exits, too, +VM at a time can use it. `/home` is gone when the guest exits, unless given a disk of its own, which works the same way (kept apart from the store, so either can be kept or thrown away): @@ -86,12 +97,12 @@ so the state doesn't silently end up on the tmpfs: The run script then refuses to start the guest without `--home`. -`/nixpkgs` is the nixpkgs the guest was built from (`<nixpkgs>`, checkout -or not); `--nixpkgs DIR` serves another one. It's not cached in the -guest, so changes to it show up right away, but evaluating is slow; -`--nixpkgs-cache=loose` caches it (several times faster, but changes may -not show up while the guest runs). Other modes: `mmap`, `readahead`, -`none` (the default). +With nix, `/nixpkgs` is the nixpkgs the guest was built from +(`<nixpkgs>`, checkout or not); `--nixpkgs DIR` serves another one. It's +not cached in the guest, so changes to it show up right away, but +evaluating is slow; `--nixpkgs-cache=loose` caches it (several times +faster, but changes may not show up while the guest runs). Other modes: +`mmap`, `readahead`, `none` (the default). The guest gets 2 CPUs and 1024 MiB unless told otherwise (`--vcpus N`, 1 to 32; `--mem-size MIB`). @@ -198,6 +209,7 @@ For `nix-shell` and the like to download, allow `cache.nixos.org`. - `pkgs/run-firecracker-vm/default.nix`: the guest's NixOS configuration, the Firecracker configuration, and the `run-firecracker-vm` script. - `pkgs/run-firecracker-vm/kernel.nix`: the cut-down kernel. +- `layers/nix.nix`: nix, as a layer. - `modules/host/default.nix`: the host's side: network, DHCP/DNS, egress proxy, `fc-egress`. - `modules/host/egress.lua`: the egress policy, for the proxy (OpenResty). @@ -205,7 +217,7 @@ For `nix-shell` and the like to download, allow `cache.nixos.org`. ## Caveats - x86_64 only. -- The guest can read all of the host's store. +- A guest with nix can read all of the host's store. - Only HTTPS with a server name (SNI) gets out; plain HTTP and other protocols don't. - Paths in the host's store outside the guest's closure are visible in |
