Refactor GUI combinators

This refactors the `gui` combinator to be a composition of pipewire, and
the new combinators `wayland` and `pulse`.
This commit is contained in:
Alex David 2025-06-07 13:45:31 -07:00
commit 35347831a2

View file

@ -338,18 +338,20 @@
gui = { gui = {
sig = "Combinator"; sig = "Combinator";
doc = '' doc = ''
Exposes everything required to get gui applications to work normally. Exposes everything required to get graphical applications to work.
This composes [pulse](#pulse), [pipewire](#pipewire),
[wayland](#wayland), and forwards/binds a few other paths to get fonts
and cursor to render correctly.
''; '';
impl = combinators: with combinators; impl = combinators: with combinators;
compose [ compose [
(readonly (noescape "/etc/fonts")) pulse
(readonly (noescape "\"$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY\"")) pipewire
(readwrite (noescape "\"$XDG_RUNTIME_DIR/pulse\"")) wayland
(readonly (noescape "~/.config/dconf"))
(try-fwd-env "DISPLAY")
(fwd-env "WAYLAND_DISPLAY")
(fwd-env "XDG_RUNTIME_DIR") (fwd-env "XDG_RUNTIME_DIR")
(fwd-env "XDG_SESSION_TYPE") (readonly (noescape "/etc/fonts"))
(readonly (noescape "~/.config/dconf"))
# Cursor # Cursor
(fwd-env "XCURSOR_THEME") (fwd-env "XCURSOR_THEME")
@ -360,6 +362,52 @@
; ;
}; };
wayland = {
sig = "Combinator";
doc = ''
Exposes your wayland compositor to the jail.
'';
impl = combinators: with combinators;
compose [
(fwd-env "WAYLAND_DISPLAY")
(fwd-env "XDG_RUNTIME_DIR")
(fwd-env "XDG_SESSION_TYPE")
(readonly (noescape "\"$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY\""))
]
;
};
unsafe-x11 = {
sig = "Combinator";
doc = ''
Exposes X11 to the jailed application.
Note that applications may be able to break out of the jail because X11
is not designed to be a security boundary.
'';
impl = combinators: with combinators;
compose [
(fwd-env "DISPLAY")
(readwrite "/tmp/.X11-unix")
]
;
};
pulse = {
sig = "Combinator";
doc = ''
Exposes pulseaudio to the jailed application.
'';
impl = combinators: with combinators;
compose [
(fwd-env "XDG_RUNTIME_DIR")
(try-fwd-env "PULSE_SERVER")
(unsafe-add-raw-args "--bind-try /run/pulse /run/pulse")
(unsafe-add-raw-args "--bind-try \"$XDG_RUNTIME_DIR/pulse\" \"$XDG_RUNTIME_DIR/pulse\"")
]
;
};
pipewire = { pipewire = {
sig = "Combinator"; sig = "Combinator";
doc = '' doc = ''
@ -367,7 +415,7 @@
''; '';
impl = combinators: with combinators; impl = combinators: with combinators;
compose [ compose [
# TODO - fwd-env XDG_RUNTIME_DIR but first it should update a record in state instead of appending args (fwd-env "XDG_RUNTIME_DIR")
(unsafe-add-raw-args "--bind-try \"$XDG_RUNTIME_DIR/pipewire-0\" \"$XDG_RUNTIME_DIR/pipewire-0\"") (unsafe-add-raw-args "--bind-try \"$XDG_RUNTIME_DIR/pipewire-0\" \"$XDG_RUNTIME_DIR/pipewire-0\"")
(unsafe-add-raw-args "--bind-try /run/pipewire /run/pipewire") (unsafe-add-raw-args "--bind-try /run/pipewire /run/pipewire")
] ]