From bc649d17c4daf98eff61e4a3a539048f125ea810 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 9 Oct 2026 20:56:52 +0000 Subject: [PATCH] fix(nixos): show the session and install the mount helper setuid The VM ran without graphics, so the desktop could not be seen, and weft-appd was pointed at the mount helper's store path, which cannot be set-user-ID, so verified package images could not mount. The VM opens a graphics window, with tty0 as the primary console and the serial console as a secondary one. weft-mount-helper is installed through security.wrappers, setuid root and executable only by the users group, built to run cryptsetup's veritysetup, and weft-appd uses /run/wrappers/bin/weft-mount-helper. --- docs/building.md | 6 +++--- infra/nixos/configuration.nix | 18 ++++++++++++++++-- infra/nixos/weft-packages.nix | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/building.md b/docs/building.md index 9791fb4..103f44c 100644 --- a/docs/building.md +++ b/docs/building.md @@ -144,9 +144,9 @@ See `infra/nixos/weft-packages.nix` for the package derivations. Its `outputHash Logging in on tty1 starts the user target `weft-session.target`, which binds `graphical-session.target` (that one refuses a manual start) and wants `weft-compositor`, then `weft-servo-shell` with the system UI page its package installs, and `weft-appd` with the runtime, app shell, file portal and mount helper packages. Run as a systemd user service, the compositor publishes its socket as `WAYLAND_DISPLAY` to the user manager before reporting readiness, so the units after it, and the app shells weft-appd starts, connect to it. The units in `infra/systemd/` are the same session for an installation outside Nix, as user units under `weft-session.target`. The image is not yet bootable to a working desktop: - the Servo source hash in `outputHashes` is still a placeholder, so no package builds until a Nix build reports it; -- the shell packages do not enable `servo-embed`, so `weft-servo-shell` and `weft-app-shell` exit at startup; -- the VM runs without graphics (`virtualisation.graphics = false` in `infra/nixos/configuration.nix`, for a serial console), so the session's output is not shown; -- `WEFT_MOUNT_HELPER` names the mount helper's store path, which cannot be setuid, so verified images cannot be mounted; a setuid wrapper would be needed. +- the shell packages do not enable `servo-embed`, so `weft-servo-shell` and `weft-app-shell` exit at startup. + +The VM opens a graphics window; `tty0` is its primary console and the serial console a secondary one. `weft-mount-helper` is installed setuid root through `security.wrappers` at `/run/wrappers/bin/weft-mount-helper`, built to run cryptsetup's `veritysetup`. ## CI diff --git a/infra/nixos/configuration.nix b/infra/nixos/configuration.nix index 271012a..ae6f86b 100644 --- a/infra/nixos/configuration.nix +++ b/infra/nixos/configuration.nix @@ -18,8 +18,10 @@ fsType = "ext4"; }; + # The session is graphical: tty0 is the primary console, and the serial + # console stays available as a secondary one for debugging. virtualisation = { - graphics = false; + graphics = true; memorySize = 4096; cores = 4; diskSize = 20480; @@ -48,6 +50,18 @@ services.getty.autologinUser = "weft"; security.polkit.enable = true; + + # weft-mount-helper mounts verified package images and must run as root; + # the Nix store cannot hold set-user-ID programs. Only the session user's + # group may run it, and it mounts only in the caller's own runtime + # directory (see crates/weft-mount-helper). + security.wrappers.weft-mount-helper = { + source = "${pkgs.weft.weft-mount-helper}/bin/weft-mount-helper"; + owner = "root"; + group = "users"; + setuid = true; + permissions = "u+rx,g+x"; + }; services.dbus.enable = true; services.udev.packages = [ pkgs.libinput ]; @@ -134,7 +148,7 @@ "WEFT_RUNTIME_BIN=${pkgs.weft.weft-runtime}/bin/weft-runtime" "WEFT_APP_SHELL_BIN=${pkgs.weft.weft-app-shell}/bin/weft-app-shell" "WEFT_FILE_PORTAL_BIN=${pkgs.weft.weft-file-portal}/bin/weft-file-portal" - "WEFT_MOUNT_HELPER=${pkgs.weft.weft-mount-helper}/bin/weft-mount-helper" + "WEFT_MOUNT_HELPER=/run/wrappers/bin/weft-mount-helper" ]; }; }; diff --git a/infra/nixos/weft-packages.nix b/infra/nixos/weft-packages.nix index 7a86106..dfde0de 100644 --- a/infra/nixos/weft-packages.nix +++ b/infra/nixos/weft-packages.nix @@ -82,5 +82,9 @@ in { weft-mount-helper = mkWeftPkg { pname = "weft-mount-helper"; extraBuildInputs = with pkgs; [ cryptsetup ]; + # The helper runs setuid and takes no program from its caller's PATH. + extraEnv = { + WEFT_VERITYSETUP = "${pkgs.cryptsetup}/bin/veritysetup"; + }; }; }