WEFT_OS/infra/nixos/configuration.nix
Marco Allegretti 538c752d80
fix(nixos): open the seat through seatd and narrow the package source
In the VM the compositor failed to open the GPU: as a user service it is
outside the tty1 login session, so logind refused it the device and the
console stayed on screen. Run seatd for the seat group the session user
is in and point the compositor's libseat at it.

The package source now holds only what the build reads, so editing the
VM configuration no longer rebuilds Servo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QS8QcxvhVJwU3X2qhPamUW
2026-10-11 09:34:46 +00:00

178 lines
5.2 KiB
Nix

{ pkgs, lib, self, modulesPath, rustOverlay, ... }:
{
imports = [
"${modulesPath}/profiles/qemu-guest.nix"
"${modulesPath}/virtualisation/qemu-vm.nix"
];
system.stateVersion = "25.05";
boot.loader.grub = {
enable = true;
device = "/dev/vda";
};
fileSystems."/" = {
device = "/dev/vda1";
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 = true;
memorySize = 4096;
cores = 4;
diskSize = 20480;
};
hardware.graphics = {
enable = true;
extraPackages = with pkgs; [ mesa virglrenderer ];
};
networking = {
hostName = "weft-vm";
firewall.enable = false;
};
time.timeZone = "UTC";
users.users.weft = {
isNormalUser = true;
description = "WEFT OS session user";
extraGroups = [ "video" "render" "seat" "input" "audio" ];
password = "";
autoSubUidGidRange = false;
};
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;
# The compositor runs as a user service, outside the tty1 login session,
# so logind does not hand it the seat's devices; seatd does, to members of
# its group.
services.seatd = {
enable = true;
group = "seat";
};
services.udev.packages = [ pkgs.libinput ];
environment.systemPackages = with pkgs; [
mesa
wayland-utils
libinput
bash
coreutils
curl
htop
pkgs.weft.weft-servo-shell
pkgs.weft.weft-app-shell
pkgs.weft.weft-pack
];
nixpkgs.overlays = [
rustOverlay
(final: prev: {
rust193 = final.rust-bin.stable."1.93.0".default;
weft = final.callPackage ./weft-packages.nix {
rust193 = final.rust193;
};
})
];
# graphical-session.target refuses a manual start; the login shell starts
# this target, which binds it, as Wayland compositors' session targets do.
systemd.user.targets.weft-session = {
description = "WEFT OS session";
bindsTo = [ "graphical-session.target" ];
wants = [ "graphical-session-pre.target" ];
after = [ "graphical-session-pre.target" ];
};
systemd.user.services = {
weft-compositor = {
description = "WEFT OS Wayland Compositor";
before = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
wantedBy = [ "weft-session.target" ];
serviceConfig = {
Type = "notify";
ExecStart = "${pkgs.weft.weft-compositor}/bin/weft-compositor";
# The compositor publishes WAYLAND_DISPLAY to the user manager for the
# units after it; a restarted compositor must not inherit it, or an
# X11 DISPLAY, or it would pick the nested backend.
UnsetEnvironment = "WAYLAND_DISPLAY DISPLAY";
Environment = "LIBSEAT_BACKEND=seatd";
Restart = "on-failure";
RestartSec = "1";
};
};
weft-servo-shell = {
description = "WEFT OS System Shell";
requires = [ "weft-compositor.service" ];
after = [ "weft-compositor.service" ];
partOf = [ "graphical-session.target" ];
wantedBy = [ "weft-session.target" ];
environment = {
WEFT_SYSTEM_UI_HTML = "${pkgs.weft.weft-servo-shell}/share/weft/shell/system-ui.html";
WEFT_UI_KIT_JS = "${pkgs.weft.weft-servo-shell}/share/weft/system/weft-ui-kit.js";
};
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.weft.weft-servo-shell}/bin/weft-servo-shell";
Restart = "on-failure";
RestartSec = "2";
};
};
weft-appd = {
description = "WEFT Application Daemon";
requires = [ "weft-compositor.service" ];
after = [ "weft-compositor.service" "weft-servo-shell.service" ];
partOf = [ "graphical-session.target" ];
wantedBy = [ "weft-session.target" ];
serviceConfig = {
Type = "notify";
ExecStart = "${pkgs.weft.weft-appd}/bin/weft-appd";
Restart = "on-failure";
RestartSec = "1s";
Environment = [
"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=/run/wrappers/bin/weft-mount-helper"
"WEFT_UI_KIT_JS=${pkgs.weft.weft-app-shell}/share/weft/system/weft-ui-kit.js"
];
};
};
};
programs.bash.loginShellInit = ''
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
systemctl --user start weft-session.target
fi
'';
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
trusted-users = [ "root" "weft" ];
};
}