From 489972d8c8dfb246a6b466dfd54bd3730727e046 Mon Sep 17 00:00:00 2001 From: Benoit de Chezelles Date: Mon, 13 Jul 2026 21:15:04 +0200 Subject: [PATCH] nix: Add NixOS-based VMs for live testing in clean desktop env (#7928) - Separate perSystemOutputs & globalOutputs in flake.nix (lots of indent changes!) - Add NixOS VM configs for Gnome & Plasma testing - Add section in contrib docs --- .gitignore | 1 + CONTRIBUTING.md | 48 +++++ nix/flake.lock | 6 +- nix/flake.nix | 432 ++++++++++++++++++++------------------ nix/vm/base.nix | 36 ++++ nix/vm/default.nix | 16 ++ nix/vm/desktop-gnome.nix | 58 +++++ nix/vm/desktop-plasma.nix | 30 +++ nix/vm/patch-opengl.nix | 21 ++ nix/vm/shared-repo.nix | 28 +++ nix/vm/vm-settings.nix | 20 ++ 11 files changed, 490 insertions(+), 206 deletions(-) create mode 100644 nix/vm/base.nix create mode 100644 nix/vm/default.nix create mode 100644 nix/vm/desktop-gnome.nix create mode 100644 nix/vm/desktop-plasma.nix create mode 100644 nix/vm/patch-opengl.nix create mode 100644 nix/vm/shared-repo.nix create mode 100644 nix/vm/vm-settings.nix diff --git a/.gitignore b/.gitignore index 79ab1de61..d0bf62a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ dhat-heap.json /assets/flatpak/generated-sources.json /__pycache__/ /nix/result +*.qcow2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a306a547..b0ce3c99e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,6 +89,12 @@ $ run $ bt ``` +Starting WezTerm with `wezterm-gui start --always-new-process` is useful to ensure Mux logs are not +hidden in an background process started in an earlier test. + +Start WezTerm with `wezterm-gui --config-file ./test-conf.lua ……` to test a custom config file. + + ### Please include tests to cover your changes! This will help ensure that your contributions keep working as things change. @@ -106,6 +112,48 @@ match expectations](https://github.com/wezterm/wezterm/blob/fd532a8c2fb3b5659359 Please also make a point of adding comments to your tests to help clarify the intent of the test! +### Testing in a NixOS VM + +If you need to test WezTerm in a clean desktop environment (e.g. to reproduce a +display server bug or verify a desktop integration), you can use the provided +NixOS VM configurations. + +Two desktop variants are available: +- GNOME (`testing-on-gnome`) +- KDE Plasma (`testing-on-plasma`). + +**Prerequisites:** Nix is installed, with flakes enabled (`experimental-features = nix-command flakes`). + +**Workflow:** + +```console +$ cargo build # build wezterm locally +$ nixos-rebuild build-vm --flake ./nix#testing-on-plasma # build the Plasma VM image +$ REPO=$PWD ./result/bin/run-nixos-vm # start the VM +``` + +> [!NOTE] +> You might need to tweak desktop settings (e.g. the keyboard layout) on first VM start. +> +> The VM state is stored in `nixos.qcow2` in the current working directory on the host. + +Inside the VM, open a terminal (e.g. _Console_ on GNOME, _Konsole_ on Plasma), then: + +```console +$ cd repo # go into ~/repo +$ ./target/debug/wezterm-gui # run wezterm for your tests +``` + +The host repository is mounted into the VM at `/home/dev/repo` via a 9p shared directory, +so changes on the host (rebuilds, test config file, ..) are immediately visible inside the VM. + +Keep the VM running and make your changes locally, re-build wezterm on your host and kill/start +wezterm again in the VM for your tests. + +> [!WARNING] +> The host repo is supposed to be mounted in read-write but I (@bew) don't know why changes in the +> repo are not actually propagated to the host. (PR welcome!) + ### Please also include documentation if you are adding or changing behavior This helps to keep things well-understood and working in the long term. diff --git a/nix/flake.lock b/nix/flake.lock index 58c4c0a8e..683a5d3c2 100644 --- a/nix/flake.lock +++ b/nix/flake.lock @@ -71,11 +71,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1780711917, - "narHash": "sha256-Cw9useKmvzRyrzQtghZPi56ImYXKsyrh+vo94hCYM3I=", + "lastModified": 1783816212, + "narHash": "sha256-2aZisVTVGSFEk3MYcOiWQp3zvwyzbqpktB69Rcfp150=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f3ce60d5372cbb1490033766bdd4748dc0128e86", + "rev": "3b32825de172d0bc85664f495edb096b10862524", "type": "github" }, "original": { diff --git a/nix/flake.nix b/nix/flake.nix index 5c307928c..e421837d3 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -42,222 +42,248 @@ outputs = inputs@{ self, ... }: - inputs.flake-utils.lib.eachDefaultSystem ( - system: - let - overlays = [ (import inputs.rust-overlay) ]; - pkgs = import (inputs.nixpkgs) { inherit system overlays; }; - - inherit (inputs.nixpkgs) lib; - inherit (pkgs) stdenv; - - nativeBuildInputs = - with pkgs; - [ - installShellFiles - ncurses # tic for terminfo - pkg-config - python3 - ] - ++ lib.optional stdenv.isDarwin perl; - - buildInputs = - with pkgs; - [ - fontconfig - openssl - zlib - ] - ++ lib.optionals stdenv.isLinux [ - libxkbcommon - wayland - - libx11 - libxcb - libxcb-util - libxcb-image - libxcb-keysyms - libxcb-wm # contains xcb-ewmh among others - ] - ++ lib.optionals stdenv.isDarwin ([ - libiconv - ]); - - libPath = lib.makeLibraryPath ( - with pkgs; - [ - libxcb-image - libGL - vulkan-loader - ] - ); - - rustPlatform = pkgs.makeRustPlatform { - cargo = pkgs.rust-bin.stable.latest.minimal; - rustc = pkgs.rust-bin.stable.latest.minimal; - }; - in - { - packages.default = rustPlatform.buildRustPackage (finalAttrs: { - inherit buildInputs nativeBuildInputs; - - pname = "wezterm"; - src = ./..; - - # Rebuild the usual version number of the project from info of commit being built. - # Format: `-