2026-03-12 20:28:14 +00:00
|
|
|
{ pkgs, lib, self, modulesPath, rustOverlay, ... }:
|
2026-03-12 14:41:33 +00:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
imports = [
|
|
|
|
|
"${modulesPath}/profiles/qemu-guest.nix"
|
2026-03-12 20:07:39 +00:00
|
|
|
"${modulesPath}/virtualisation/qemu-vm.nix"
|
2026-03-12 14:41:33 +00:00
|
|
|
];
|
|
|
|
|
|
2026-03-12 20:19:11 +00:00
|
|
|
system.stateVersion = "25.05";
|
2026-03-12 14:41:33 +00:00
|
|
|
|
|
|
|
|
boot.loader.grub = {
|
|
|
|
|
enable = true;
|
|
|
|
|
device = "/dev/vda";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fileSystems."/" = {
|
|
|
|
|
device = "/dev/vda1";
|
|
|
|
|
fsType = "ext4";
|
|
|
|
|
};
|
|
|
|
|
|
2026-10-09 20:56:52 +00:00
|
|
|
# The session is graphical: tty0 is the primary console, and the serial
|
|
|
|
|
# console stays available as a secondary one for debugging.
|
2026-03-12 14:41:33 +00:00
|
|
|
virtualisation = {
|
2026-10-09 20:56:52 +00:00
|
|
|
graphics = true;
|
2026-03-12 14:41:33 +00:00
|
|
|
memorySize = 4096;
|
|
|
|
|
cores = 4;
|
|
|
|
|
diskSize = 20480;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-12 20:07:39 +00:00
|
|
|
hardware.graphics = {
|
2026-03-12 14:41:33 +00:00
|
|
|
enable = true;
|
2026-10-09 19:35:48 +00:00
|
|
|
extraPackages = with pkgs; [ mesa virglrenderer ];
|
2026-03-12 14:41:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
2026-10-09 20:56:52 +00:00
|
|
|
|
|
|
|
|
# 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";
|
|
|
|
|
};
|
2026-03-12 14:41:33 +00:00
|
|
|
services.dbus.enable = true;
|
|
|
|
|
|
|
|
|
|
services.udev.packages = [ pkgs.libinput ];
|
|
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
|
mesa
|
|
|
|
|
wayland-utils
|
|
|
|
|
libinput
|
|
|
|
|
bash
|
|
|
|
|
coreutils
|
|
|
|
|
curl
|
|
|
|
|
htop
|
2026-03-12 20:07:39 +00:00
|
|
|
pkgs.weft.weft-servo-shell
|
|
|
|
|
pkgs.weft.weft-app-shell
|
|
|
|
|
pkgs.weft.weft-pack
|
2026-03-12 14:41:33 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
nixpkgs.overlays = [
|
2026-03-12 20:28:14 +00:00
|
|
|
rustOverlay
|
2026-03-12 14:41:33 +00:00
|
|
|
(final: prev: {
|
2026-03-12 20:28:14 +00:00
|
|
|
rust193 = final.rust-bin.stable."1.93.0".default;
|
|
|
|
|
weft = final.callPackage ./weft-packages.nix {
|
|
|
|
|
rust193 = final.rust193;
|
|
|
|
|
};
|
2026-03-12 14:41:33 +00:00
|
|
|
})
|
|
|
|
|
];
|
|
|
|
|
|
fix(session): start the session as user units through its own target
The tty1 login hook ran systemctl --user start graphical-session.target,
which systemd refuses (RefuseManualStart=yes), so none of the NixOS
session's services started. The units in infra/systemd were wanted by
graphical.target, a system target, although weft-appd's needs the
session user's runtime and home directories and the compositor publishes
its socket to the user manager; run as system units the shell could
never learn the socket.
weft-session.target binds graphical-session.target and wants the
compositor, shell and weft-appd, in the NixOS configuration and as a
user unit in infra/systemd; the login hook starts it. The services are
part of the graphical session, the shell no longer hardcodes the
compositor's socket, and the compositor's units unset WAYLAND_DISPLAY
and DISPLAY so a restarted compositor does not take them for an
enclosing session and pick the nested backend. As a user unit, weft-appd
drops ProtectSystem= and PrivateTmp=, which a user manager implements
with PrivateUsers=yes, under which the setuid mount helper cannot mount
verified images. docs/building.md adds the VM's disabled graphics and
its mount helper, which the Nix store cannot hold setuid, to what still
keeps the image from a working desktop.
Rendered from the NixOS configuration, and as installed from
infra/systemd, the units pass systemd-analyze --user verify.
2026-10-09 20:34:33 +00:00
|
|
|
# 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" ];
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-12 14:41:33 +00:00
|
|
|
systemd.user.services = {
|
|
|
|
|
weft-compositor = {
|
|
|
|
|
description = "WEFT OS Wayland Compositor";
|
fix(session): start the session as user units through its own target
The tty1 login hook ran systemctl --user start graphical-session.target,
which systemd refuses (RefuseManualStart=yes), so none of the NixOS
session's services started. The units in infra/systemd were wanted by
graphical.target, a system target, although weft-appd's needs the
session user's runtime and home directories and the compositor publishes
its socket to the user manager; run as system units the shell could
never learn the socket.
weft-session.target binds graphical-session.target and wants the
compositor, shell and weft-appd, in the NixOS configuration and as a
user unit in infra/systemd; the login hook starts it. The services are
part of the graphical session, the shell no longer hardcodes the
compositor's socket, and the compositor's units unset WAYLAND_DISPLAY
and DISPLAY so a restarted compositor does not take them for an
enclosing session and pick the nested backend. As a user unit, weft-appd
drops ProtectSystem= and PrivateTmp=, which a user manager implements
with PrivateUsers=yes, under which the setuid mount helper cannot mount
verified images. docs/building.md adds the VM's disabled graphics and
its mount helper, which the Nix store cannot hold setuid, to what still
keeps the image from a working desktop.
Rendered from the NixOS configuration, and as installed from
infra/systemd, the units pass systemd-analyze --user verify.
2026-10-09 20:34:33 +00:00
|
|
|
before = [ "graphical-session.target" ];
|
2026-03-12 14:41:33 +00:00
|
|
|
partOf = [ "graphical-session.target" ];
|
fix(session): start the session as user units through its own target
The tty1 login hook ran systemctl --user start graphical-session.target,
which systemd refuses (RefuseManualStart=yes), so none of the NixOS
session's services started. The units in infra/systemd were wanted by
graphical.target, a system target, although weft-appd's needs the
session user's runtime and home directories and the compositor publishes
its socket to the user manager; run as system units the shell could
never learn the socket.
weft-session.target binds graphical-session.target and wants the
compositor, shell and weft-appd, in the NixOS configuration and as a
user unit in infra/systemd; the login hook starts it. The services are
part of the graphical session, the shell no longer hardcodes the
compositor's socket, and the compositor's units unset WAYLAND_DISPLAY
and DISPLAY so a restarted compositor does not take them for an
enclosing session and pick the nested backend. As a user unit, weft-appd
drops ProtectSystem= and PrivateTmp=, which a user manager implements
with PrivateUsers=yes, under which the setuid mount helper cannot mount
verified images. docs/building.md adds the VM's disabled graphics and
its mount helper, which the Nix store cannot hold setuid, to what still
keeps the image from a working desktop.
Rendered from the NixOS configuration, and as installed from
infra/systemd, the units pass systemd-analyze --user verify.
2026-10-09 20:34:33 +00:00
|
|
|
wantedBy = [ "weft-session.target" ];
|
2026-03-12 14:41:33 +00:00
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "notify";
|
|
|
|
|
ExecStart = "${pkgs.weft.weft-compositor}/bin/weft-compositor";
|
fix(session): start the session as user units through its own target
The tty1 login hook ran systemctl --user start graphical-session.target,
which systemd refuses (RefuseManualStart=yes), so none of the NixOS
session's services started. The units in infra/systemd were wanted by
graphical.target, a system target, although weft-appd's needs the
session user's runtime and home directories and the compositor publishes
its socket to the user manager; run as system units the shell could
never learn the socket.
weft-session.target binds graphical-session.target and wants the
compositor, shell and weft-appd, in the NixOS configuration and as a
user unit in infra/systemd; the login hook starts it. The services are
part of the graphical session, the shell no longer hardcodes the
compositor's socket, and the compositor's units unset WAYLAND_DISPLAY
and DISPLAY so a restarted compositor does not take them for an
enclosing session and pick the nested backend. As a user unit, weft-appd
drops ProtectSystem= and PrivateTmp=, which a user manager implements
with PrivateUsers=yes, under which the setuid mount helper cannot mount
verified images. docs/building.md adds the VM's disabled graphics and
its mount helper, which the Nix store cannot hold setuid, to what still
keeps the image from a working desktop.
Rendered from the NixOS configuration, and as installed from
infra/systemd, the units pass systemd-analyze --user verify.
2026-10-09 20:34:33 +00:00
|
|
|
# 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";
|
2026-03-12 14:41:33 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
|
RestartSec = "1";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-12 20:07:39 +00:00
|
|
|
weft-servo-shell = {
|
|
|
|
|
description = "WEFT OS System Shell";
|
|
|
|
|
requires = [ "weft-compositor.service" ];
|
|
|
|
|
after = [ "weft-compositor.service" ];
|
fix(session): start the session as user units through its own target
The tty1 login hook ran systemctl --user start graphical-session.target,
which systemd refuses (RefuseManualStart=yes), so none of the NixOS
session's services started. The units in infra/systemd were wanted by
graphical.target, a system target, although weft-appd's needs the
session user's runtime and home directories and the compositor publishes
its socket to the user manager; run as system units the shell could
never learn the socket.
weft-session.target binds graphical-session.target and wants the
compositor, shell and weft-appd, in the NixOS configuration and as a
user unit in infra/systemd; the login hook starts it. The services are
part of the graphical session, the shell no longer hardcodes the
compositor's socket, and the compositor's units unset WAYLAND_DISPLAY
and DISPLAY so a restarted compositor does not take them for an
enclosing session and pick the nested backend. As a user unit, weft-appd
drops ProtectSystem= and PrivateTmp=, which a user manager implements
with PrivateUsers=yes, under which the setuid mount helper cannot mount
verified images. docs/building.md adds the VM's disabled graphics and
its mount helper, which the Nix store cannot hold setuid, to what still
keeps the image from a working desktop.
Rendered from the NixOS configuration, and as installed from
infra/systemd, the units pass systemd-analyze --user verify.
2026-10-09 20:34:33 +00:00
|
|
|
partOf = [ "graphical-session.target" ];
|
|
|
|
|
wantedBy = [ "weft-session.target" ];
|
2026-03-12 20:07:39 +00:00
|
|
|
environment = {
|
fix(nixos): start weft-appd and give the session its shell page and app shell
The reference session could not show the system UI or open an app, even
with every package built:
- weft-servo-shell ignores command-line arguments, yet
infra/systemd/servo-shell.service passed it the page path, and the
binary's packaged fallback named a path no package provides. The
Nix package did not install the page and its NixOS service did not
name it either, so the shell exited at startup.
- The NixOS weft-appd user service was wanted by nothing, so it never
started, and it had no WEFT_APP_SHELL_BIN, so every launch would stop
before its UI host started.
The weft-servo-shell package now installs the page as
share/weft/shell/system-ui.html, the binary falls back to that path in
the package's active revision, the systemd unit drops the ignored
argument, and the NixOS service sets WEFT_SYSTEM_UI_HTML to the package's
copy. weft-appd is wanted by the graphical session and is given the app
shell. docs/building.md lists what still keeps the image from a working
desktop: the Servo source hash, servo-embed in the shell packages and the
fixed Wayland socket name.
2026-10-09 20:26:05 +00:00
|
|
|
WEFT_SYSTEM_UI_HTML = "${pkgs.weft.weft-servo-shell}/share/weft/shell/system-ui.html";
|
2026-10-11 08:44:16 +00:00
|
|
|
WEFT_UI_KIT_JS = "${pkgs.weft.weft-servo-shell}/share/weft/system/weft-ui-kit.js";
|
2026-03-12 20:07:39 +00:00
|
|
|
};
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "simple";
|
|
|
|
|
ExecStart = "${pkgs.weft.weft-servo-shell}/bin/weft-servo-shell";
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
RestartSec = "2";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-12 14:41:33 +00:00
|
|
|
weft-appd = {
|
|
|
|
|
description = "WEFT Application Daemon";
|
|
|
|
|
requires = [ "weft-compositor.service" ];
|
|
|
|
|
after = [ "weft-compositor.service" "weft-servo-shell.service" ];
|
fix(session): start the session as user units through its own target
The tty1 login hook ran systemctl --user start graphical-session.target,
which systemd refuses (RefuseManualStart=yes), so none of the NixOS
session's services started. The units in infra/systemd were wanted by
graphical.target, a system target, although weft-appd's needs the
session user's runtime and home directories and the compositor publishes
its socket to the user manager; run as system units the shell could
never learn the socket.
weft-session.target binds graphical-session.target and wants the
compositor, shell and weft-appd, in the NixOS configuration and as a
user unit in infra/systemd; the login hook starts it. The services are
part of the graphical session, the shell no longer hardcodes the
compositor's socket, and the compositor's units unset WAYLAND_DISPLAY
and DISPLAY so a restarted compositor does not take them for an
enclosing session and pick the nested backend. As a user unit, weft-appd
drops ProtectSystem= and PrivateTmp=, which a user manager implements
with PrivateUsers=yes, under which the setuid mount helper cannot mount
verified images. docs/building.md adds the VM's disabled graphics and
its mount helper, which the Nix store cannot hold setuid, to what still
keeps the image from a working desktop.
Rendered from the NixOS configuration, and as installed from
infra/systemd, the units pass systemd-analyze --user verify.
2026-10-09 20:34:33 +00:00
|
|
|
partOf = [ "graphical-session.target" ];
|
|
|
|
|
wantedBy = [ "weft-session.target" ];
|
2026-03-12 14:41:33 +00:00
|
|
|
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"
|
fix(nixos): start weft-appd and give the session its shell page and app shell
The reference session could not show the system UI or open an app, even
with every package built:
- weft-servo-shell ignores command-line arguments, yet
infra/systemd/servo-shell.service passed it the page path, and the
binary's packaged fallback named a path no package provides. The
Nix package did not install the page and its NixOS service did not
name it either, so the shell exited at startup.
- The NixOS weft-appd user service was wanted by nothing, so it never
started, and it had no WEFT_APP_SHELL_BIN, so every launch would stop
before its UI host started.
The weft-servo-shell package now installs the page as
share/weft/shell/system-ui.html, the binary falls back to that path in
the package's active revision, the systemd unit drops the ignored
argument, and the NixOS service sets WEFT_SYSTEM_UI_HTML to the package's
copy. weft-appd is wanted by the graphical session and is given the app
shell. docs/building.md lists what still keeps the image from a working
desktop: the Servo source hash, servo-embed in the shell packages and the
fixed Wayland socket name.
2026-10-09 20:26:05 +00:00
|
|
|
"WEFT_APP_SHELL_BIN=${pkgs.weft.weft-app-shell}/bin/weft-app-shell"
|
2026-03-12 14:41:33 +00:00
|
|
|
"WEFT_FILE_PORTAL_BIN=${pkgs.weft.weft-file-portal}/bin/weft-file-portal"
|
2026-10-09 20:56:52 +00:00
|
|
|
"WEFT_MOUNT_HELPER=/run/wrappers/bin/weft-mount-helper"
|
2026-10-11 08:44:16 +00:00
|
|
|
"WEFT_UI_KIT_JS=${pkgs.weft.weft-app-shell}/share/weft/system/weft-ui-kit.js"
|
2026-03-12 14:41:33 +00:00
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
programs.bash.loginShellInit = ''
|
|
|
|
|
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
|
fix(session): start the session as user units through its own target
The tty1 login hook ran systemctl --user start graphical-session.target,
which systemd refuses (RefuseManualStart=yes), so none of the NixOS
session's services started. The units in infra/systemd were wanted by
graphical.target, a system target, although weft-appd's needs the
session user's runtime and home directories and the compositor publishes
its socket to the user manager; run as system units the shell could
never learn the socket.
weft-session.target binds graphical-session.target and wants the
compositor, shell and weft-appd, in the NixOS configuration and as a
user unit in infra/systemd; the login hook starts it. The services are
part of the graphical session, the shell no longer hardcodes the
compositor's socket, and the compositor's units unset WAYLAND_DISPLAY
and DISPLAY so a restarted compositor does not take them for an
enclosing session and pick the nested backend. As a user unit, weft-appd
drops ProtectSystem= and PrivateTmp=, which a user manager implements
with PrivateUsers=yes, under which the setuid mount helper cannot mount
verified images. docs/building.md adds the VM's disabled graphics and
its mount helper, which the Nix store cannot hold setuid, to what still
keeps the image from a working desktop.
Rendered from the NixOS configuration, and as installed from
infra/systemd, the units pass systemd-analyze --user verify.
2026-10-09 20:34:33 +00:00
|
|
|
systemctl --user start weft-session.target
|
2026-03-12 14:41:33 +00:00
|
|
|
fi
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
nix.settings = {
|
|
|
|
|
experimental-features = [ "nix-command" "flakes" ];
|
|
|
|
|
trusted-users = [ "root" "weft" ];
|
|
|
|
|
};
|
|
|
|
|
}
|