Commit graph

99 commits

Author SHA1 Message Date
eb4e2ffcaa Add VM configuration options and migrate to --block
- Rename `disks` to `additionalDisks` with structured format
  (path, readOnly, enableDiscard, blockSize, devIdentifier, useDirect)
- Add custom boot options: rootDisk, kernel, initramfs, rootDiskReadonly
- Add kernelParams for extra kernel command line options
- Add gpu option (default: "context-types=cross-domain:virgl2")
- Add sharedDirectories for crosvm --shared-dir
- Add global crosvmLogLevel option (default: "info")
- Add --name argument to crosvm set to VM name
- Migrate deprecated --disk/--rwdisk to --block format
- Switch flake to nixos-unstable channel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 19:09:51 +00:00
5e32c13b03 Move disposable/idleTimeout to runtime kernel parameters
VMs with different disposable settings but identical guestPrograms and
guestConfig now share the same rootfs image. The idle watchdog service
is always included but reads isDisposable and idleTimeout from the
kernel command line at startup, exiting immediately for non-disposable VMs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:16:15 +00:00
49235bbb79 Update documentation 2026-02-04 17:59:20 +00:00
03eb42e48b Reenable server-side decoration forcing
The double-decoration crash issue has been fixed. Verified that both konsole
(prefers server-side decorations) and firefox (prefers client-side) work and
show server-side decorations.
2026-02-04 17:16:32 +00:00
5e584681dc Revert server-side decoration forcing
Did not work with native wayland clients. Fixes:
```
feb 04 15:48:07 stofa crosvm[356756]:  [devices/src/virtio/gpu/mod.rs:759] error processing gpu command CmdSubmit3d: ErrRutabaga(RutabagaError { kind: NixError(EPIPE), context: None })
feb 04 15:48:07 stofa crosvm[356756]:  [devices/src/virtio/gpu/protocol.rs:973] Returning VIRTIO_GPU_RESP_ERR_UNSPEC for error ErrRutabaga(RutabagaError { kind: NixError(EPIPE), context: None })
```
2026-02-04 16:03:00 +00:00
3450465149 Bump crosvm (rebased on latest upstream) 2026-02-04 16:03:00 +00:00
a8998a87c5 Use wayland-1 for WAYLAND_DISPLAY
Reverts bb0162f711
2026-02-04 16:03:00 +00:00
1fcad4dca8 Add treefmt-nix formatter and clean up idiomatic Nix patterns
- Add treefmt-nix with nixfmt for code formatting (nix fmt)
- Extract cidrToNetworkBase and mkVmCase helper functions
- Use lib.nameValuePair for cleaner listToAttrs patterns
- Consolidate assertions with single let block
- Remove duplicate util-linux package
- Document formatting requirement in CLAUDE.md
- Apply nixfmt to all Nix files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:02:43 +00:00
6d06c1d5a2 crosvm: Allow madvise(MADV_GUARD_INSTALL) 2026-02-04 11:40:58 +00:00
f4754e300d Add bash completion for vm-* scripts
Add programs.qubes-lite.enableBashIntegration option (default enabled)
that provides tab completion for vm-run, vm-start-debug, vm-stop,
vm-shell, and vm-root-shell commands.

VM names are queried dynamically from systemd socket units at completion
time, so existing shells see new VMs immediately after nixos-rebuild
without needing to reload.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:39:32 +00:00
45ffac9190 Update crosvm GPU seccomp policy to fix segfaults
Allow madvise(MADV_NOHUGEPAGE), setsockopt and sendmmsg. nvidia driver
calls XOpenDisplay which triggers DNS resolution so these are needed.
2026-02-04 11:09:51 +00:00
bb0162f711 Use wayland-0 for proxy display socket name
Matches other config. The proxy defaults to wayland-1.
2026-02-04 10:22:17 +00:00
7274fafbdc Force server-side decorations
Use my wayland-proxy-virtwl fork. Unconditionally requests server-side
decorations even if the client doesn't want them.

Tested with firefox, works there.
2026-02-04 09:39:57 +00:00
c8a8e23d37 Update documentation 2026-02-04 02:38:19 +00:00
62ab0476b8 refactor: remove legacy s6-based rootfs implementation
Remove the old s6/execline-based rootfs in favor of the NixOS module approach:

- Delete rootfs/ directory (s6-based rootfs builder)
- Delete mktuntap/ directory (TAP utility, now using --tap-name)
- Delete default.nix (legacy package with vs*/tt*/ff* scripts)
- Update flake.nix to point packages.default to rootfs-nixos
- Update documentation to reflect NixOS-only architecture

The NixOS module (modules/) with socket-activated VMs is now the only
supported approach. VMs are configured declaratively via
programs.qubes-lite.nixosVms.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:09:10 +00:00
5b170f4218 feat: add vm-shell and vm-root-shell scripts for SSH over vsock
Add two new scripts to the NixOS module that SSH into VMs:
- vm-shell <name> - SSH as user
- vm-root-shell <name> - SSH as root

Users must configure SSH keys in guestConfig for these to work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:55:44 +00:00
23b8622f79 Remove default root pass, enable OpenSSH for ssh-over-vsock 2026-02-04 01:51:42 +00:00
4d40e07425 feat: add global guestConfig option for NixOS VMs
Add programs.qubes-lite.guestConfig option for NixOS configuration
that applies to all VMs. Per-VM guestConfig is deep-merged with the
global config using lib.recursiveUpdate, with per-VM values taking
precedence on conflicts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:39:17 +00:00
0a12a36b48 docs: update README.md and CLAUDE.md for on-demand VMs
- Document new CLI scripts: vm-run, vm-start-debug, vm-stop
- Replace autoStart with disposable/idleTimeout options
- Add section on disposable VMs with auto-shutdown
- Document socket activation architecture
- Update examples to show disposable VM configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:25:35 +00:00
78c0f4cc7f docs: update socket wantedBy to default.target
sockets.target is passive in user sessions. default.target ensures
sockets start automatically on login.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:23:14 +00:00
f45d28275b fix: use default.target for socket activation
sockets.target is a passive target that isn't automatically activated
in user sessions. Using default.target ensures the socket starts when
the user logs in.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:17:16 +00:00
fa670c4bbf docs: mark on-demand VM implementation as complete
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:06:01 +00:00
62d47520ff chore: remove autoStart option and legacy run-in-vm script
autoStart is replaced by socket activation.
run-in-vm is replaced by vm-run which uses socket activation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:04:42 +00:00
70d0a9669b feat: add vm-start-debug and vm-stop CLI scripts
- vm-start-debug: runs crosvm directly, bypassing socket activation
- vm-stop: sends shutdown command via vsock

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:03:25 +00:00
b1ee1386b4 feat: add vm-run CLI script
vm-run <vm-name> <command> connects to socket, triggering VM
activation if needed, then sends command.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:01:38 +00:00
5bf1604fb7 feat: add proxy service template for socket activation
- mkProxyScript waits for guest vsock, then forwards stdin/stdout
- qubes-lite-<name>@.service spawned per connection by socket
- qubes-lite-<name>-vm.service runs crosvm (required by proxy)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:59:50 +00:00
884271a4c8 feat: generate systemd socket units for VM activation
Creates qubes-lite-<name>.socket for each VM, listening on
$XDG_RUNTIME_DIR/qubes-lite/<name>.sock with Accept=true.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:58:21 +00:00
07abca1ac5 feat: add idle watchdog for disposable VMs
When _qubesLite.disposable is true, vm-idle-watchdog monitors for:
- No active vsock-cmd@ instances
- Last activity older than idleTimeout seconds

Triggers clean systemctl poweroff when conditions met.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:55:50 +00:00
2d5b554102 feat: replace vsock-command-listener with socket-activated template
- Remove socat-based vsock-command-listener service
- Add vsock-cmd.socket for systemd socket activation
- Add vsock-cmd@.service template spawned per connection
- Template touches /run/qubes-lite/last-activity on start/stop

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:54:24 +00:00
002d207ca6 feat: pass disposable/idleTimeout options to guest
buildRootfs now passes _qubesLite options from host VM config
to guest NixOS configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:52:37 +00:00
7275698636 feat: add _qubesLite options interface to guest config
Adds options._qubesLite.{disposable, idleTimeout} for host to pass
auto-shutdown configuration to guest.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:47:35 +00:00
d328638564 feat: add disposable and idleTimeout VM options
These options enable on-demand VM shutdown:
- disposable: enables auto-shutdown when idle
- idleTimeout: seconds to wait before shutdown

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:42:34 +00:00
a59478d5d0 Add design doc for on-demand VM launch with auto-shutdown
Socket-activated VMs that start on first command and optionally
shut down after configurable idle period. Uses systemd template
units for process tracking on both host and guest sides.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:35:46 +00:00
eb758f1892 Add declarative NixOS module for VM configuration
Replace the simple guestPrograms-only module with a full declarative
module that allows configuring VMs from configuration.nix:

- programs.qubes-lite.enable, user, vmNetwork, natEnable, natInterface
- programs.qubes-lite.nixosVms list with per-VM config (id, name,
  memory, cpus, network, disks, guestPrograms, guestConfig)
- Automatic TAP interface creation via networking.interfaces
- NAT configuration for VM internet access
- Per-VM NixOS rootfs builds with combined packages
- Generated launcher scripts (qubes-lite-start-<name>)
- run-in-vm helper for executing commands via vsock
- Systemd user services for each VM
- Validation: odd IDs 3-255, unique IDs/names
2026-02-03 23:09:56 +00:00
c50b309807 WIP: Add rootfs-nixos package for NixOS-based VM images
Adds a new rootfs-nixos/ package that builds a NixOS system into a
qcow2 image with overlayfs root (read-only ext4 + tmpfs upper).
2026-02-03 21:32:14 +00:00
b46e11d551 Use my crosvm fork for nVidia compat, home paths 2026-02-03 19:18:07 +00:00
Thomas Leonard
76c845a22f Update to NixOS 25.11
Changes needed:

- Some minor renaming for nixpkgs changes.
- Kernel modules now come from a separate output.
- dash over vsock seems to be broken; switched to bash.
  (it seems to be trying to use the console instead of the vsock)
2025-12-01 12:24:02 +00:00
Thomas Leonard
88690f4056 Remove git from default programs
You probably want gitFull anyway.
2025-11-21 17:20:09 +00:00
Thomas Leonard
d1480c75f5 Trim default packages
Just keep the most useful ones by default. Users can add their own now.
2025-11-19 12:17:24 +00:00
Thomas Leonard
6bb8e07552 Allow configuring guest packages 2025-11-19 12:12:03 +00:00
Thomas Leonard
a5572b980d Ensure reboot is the busybox one
systemd's version may end up in PATH, and that won't work.
2025-09-06 10:54:51 +01:00
Thomas Leonard
ca240495f0 Switch from Evince to Okular
Allows setting sensible colours.
2025-09-03 16:55:40 +01:00
Thomas Leonard
ffc37306c3 Add gvfs (and fix dbus)
Add gvfs so that evince can remember where you are in a document.
Start dbus at session launch so that everything gets the same one
(evince doesn't launch it if missing).
2025-08-29 10:49:13 +01:00
Thomas Leonard
8f24386f06 Update to nixos-25.05 stable branch 2025-05-24 09:12:41 +01:00
Thomas Leonard
afb5b6221b Update crosvm to fix selections crash 2025-05-17 15:44:52 +01:00
Thomas Leonard
4d09034365 Configure reasonable default fonts for VMs
Just copied in the defaults file from the host.
2025-05-17 13:17:15 +01:00
Thomas Leonard
e5dd116be3 Update guest kernel to 6.12
Seems to work fine with the new crosvm.
2025-05-17 10:42:37 +01:00
Thomas Leonard
e7514f2358 Update to nixos 25.05 beta 2025-05-17 10:02:59 +01:00
Thomas Leonard
7374f31111 Add wl-clipboard to guests 2025-04-06 11:06:44 +01:00
Thomas Leonard
82badddf74 Update flake.lock
Mainly to get new Wayland proxy with viewport support.
2025-03-08 14:25:45 +00:00