Compare commits

...
8 Commits
Author SHA1 Message Date
yuri 847e76614a Merge pull request 'Polkit agent + libvirt group (fixes virt-manager connection failure)' (#4) from fix/polkit-agent-libvirt into main 2026-10-27 15:28:59 +01:00
Pathfinder c552b30112 Advanced menu libvirt wiring: use SUDO_USER fallback like session prereqs
usermod used $USER directly; under sudo $USER can be root. All other
user-scoped calls already use ${SUDO_USER:-$USER} — aligned. No hardcoded
usernames anywhere in the repo (verified by grep; only the dotfiles repo
URL, which is overridable via DOTFILES_REPO).
2026-10-27 15:19:08 +01:00
Pathfinder e99c60a073 Session prereqs: libvirt group membership when libvirt is installed
The error CHANGED on the VM: 'no polkit agent' -> 'access denied by
policy' — the agent unit works; polkit now denies because the user is
not in the libvirt group (fresh run without picking QEMU from the menu,
or no re-login after the pick).

install_session_prereqs now adds the user to the libvirt group whenever
libvirt is installed (idempotent via id -nG check), decoupled from the
advanced-menu choice. Applies after re-login.
2026-10-27 15:14:22 +01:00
Pathfinder 0814c5bde7 polkit agent via user systemd unit, not XDG autostart
Second VM failure: Fedora's polkit-kde .desktop carries
X-systemd-skip=true (and OnlyShowIn on some versions), so niri's
xdg-desktop-autostart.target skips the agent regardless — package
installed, agent dead, same error.

Stop fighting .desktop semantics: install a polkit-agent.service USER
unit (WantedBy=graphical-session.target, which niri/Hyprland/Mango all
bring up) with the Fedora kf6 binary path, pre-linked into
graphical-session.target.wants. Idempotent on both file and symlink.
2026-10-27 14:51:44 +01:00
Pathfinder 6a9941771a polkit-kde agent never starts in niri: strip OnlyShowIn=KDE
The VM error persisted with polkit-kde installed: the package's autostart
.desktop carries OnlyShowIn=KDE;, so XDG autostart (which niri honors via
xdg-desktop-autostart.target) skips the agent in a niri session. Package
present, agent never running — exactly the observed behavior.

install_session_prereqs now rewrites the .desktop without the OnlyShowIn
line in place (idempotent: only rewrites when the line is present).
2026-10-27 14:37:41 +01:00
Pathfinder dbf75d1239 qemu/libvirt belongs to the advanced menu, not the niri module
A clean-snapshot run showed qemu/virt-manager installed without choosing
it: PR #4 had embedded the install in the niri module. Removed from there
(zero virt packages in a plain niri run, harness-verified) and moved into
install_category_pkgs Virtualisation: picking qemu/virt-manager there now
also enables libvirtd and adds the user to the libvirt group.
2026-10-27 14:19:26 +01:00
Pathfinder eacceee296 polkit agent: polkit-gnome is orphaned/EPEL-only on F44; use polkit-kde
VM run failed: 'No match for argument: polkit-gnome'. polkit-gnome is
orphaned in Fedora (EPEL9 only). polkit-kde 6.6.4 is in F44 and ships its
agent's /etc/xdg/autostart .desktop itself, so the manual symlink wiring
is gone too — installing the package is the whole fix.
2026-10-27 14:07:49 +01:00
Pathfinder 8ca045de4a Polkit agent for compositor sessions; libvirt group for virt-manager
virt-manager on niri/Noctalia failed with 'authentication unavailable:
no polkit agent available to authenticate action org.libvirt.unix.manage'
- bare compositors ship no polkit agent, unlike GNOME/KDE.

Two fixes:
- install_session_prereqs installs polkit-gnome and wires its agent
  .desktop into /etc/xdg/autostart (paths overridable for testing).
- niri module optionally installs the qemu/libvirt stack, enables
  libvirtd, and adds the user to the libvirt group: members manage
  qemu:///system with no polkit prompt at all (the real fix; applies
  after re-login).
2026-10-27 14:01:31 +01:00
2 changed files with 63 additions and 0 deletions
+48
View File
@@ -82,10 +82,58 @@ write_x11_session() {
# Common login-time plumbing every Wayland compositor wants on a bare install. # Common login-time plumbing every Wayland compositor wants on a bare install.
install_session_prereqs() { install_session_prereqs() {
# polkit-kde ships the agent (polkit-gnome is orphaned, EPEL-only).
# BUT Fedora's autostart .desktop carries X-systemd-skip=true (and a
# OnlyShowIn on some versions): niri starts apps via systemd's
# xdg-desktop-autostart.target, which honors those flags -> agent never
# starts in a niri session (VM-proven twice). Fighting .desktop semantics
# is fragile, so we ship our own user unit bound to
# graphical-session.target, which niri/Hyprland/MangoWC all bring up.
install_packages \ install_packages \
xdg-desktop-portal \ xdg-desktop-portal \
polkit \ polkit \
polkit-kde \
pipewire \ pipewire \
pipewire-pulseaudio \ pipewire-pulseaudio \
wireplumber wireplumber
local unit_dir="/etc/systemd/user"
if [[ ! -f "$unit_dir/polkit-agent.service" ]]; then
info "Installing polkit-agent user unit (compositor-safe)..."
sudo mkdir -p "$unit_dir"
sudo tee "$unit_dir/polkit-agent.service" >/dev/null <<'UNIT'
[Unit]
Description=PolicyKit Authentication Agent (for bare compositors)
PartOf=graphical-session.target
[Service]
# polkit-kde's binary on Fedora (kf6 path). Restart in case the agent dies
# before the session settles.
ExecStart=/usr/libexec/kf6/polkit-kde-authentication-agent-1
Restart=on-failure
RestartSec=2
[Install]
WantedBy=graphical-session.target
UNIT
fi
# Enable per-user: preset-all would also do, but be explicit. This is a
# global unit dir; each user links it at first login via the preset.
if [[ ! -f /etc/systemd/user/graphical-session.target.wants/polkit-agent.service ]]; then
sudo mkdir -p /etc/systemd/user/graphical-session.target.wants
sudo ln -sf ../polkit-agent.service \
/etc/systemd/user/graphical-session.target.wants/polkit-agent.service
fi
# libvirt group: members manage qemu:///system without a polkit prompt.
# Without this, virt-manager dies on "access denied by policy" even with
# a working agent (VM-proven). Idempotent; applies after re-login.
if pkg_installed libvirt; then
local real_user="${SUDO_USER:-$USER}"
if ! id -nG "$real_user" 2>/dev/null | grep -qw libvirt; then
info "Adding $real_user to the libvirt group (re-login to apply)..."
sudo usermod -aG libvirt "$real_user"
fi
fi
} }
+15
View File
@@ -533,6 +533,21 @@ run_advanced_menu() {
install_category_pkgs() { install_category_pkgs() {
local cat="$1"; shift local cat="$1"; shift
case "$cat" in case "$cat" in
Virtualisation)
# qemu:///system without password prompts: libvirt group + enabled
# daemon. Only when the picked packages actually use libvirt.
local wants_libvirt=false item
for item in "$@"; do
[[ "$item" == *libvirt* || "$item" == *virt-manager* || "$item" == *virt-install* ]] && wants_libvirt=true
done
if $wants_libvirt; then
local real_user="${SUDO_USER:-$USER}"
info "Enabling libvirtd and adding $real_user to the libvirt group..."
sudo systemctl enable --now libvirtd 2>/dev/null || true
sudo usermod -aG libvirt "$real_user" || true
warn "libvirt group membership applies after re-login."
fi
;;
Browsers) Browsers)
local needs_chrome=false needs_brave=false item local needs_chrome=false needs_brave=false item
for item in "$@"; do for item in "$@"; do