I wanted to run sway from upstream
master branch to tests the yet-unreleased
fractional scaling support. This recipe also works for trying to build sway
with custom patches.
First, I needed to clone sway itself and
wlroots as a subproject. Building
wlroots as a subproject is required since I need to use the current
wlroots. Using the distribution/system provided
wlroots is unlikely to
work (due to it being the latest stable release).
git clone https://github.com/swaywm/sway.git cd sway mkdir subprojects cd subprojects git clone https://gitlab.freedesktop.org/wlroots/wlroots cd ..
Next up, install all the build dependencies for both sway and
-t .sway-dev installs a virtual package called
.sway-dev which has all the
packages listed below as dependencies. This makes cleaning up very simple later
doas apk add -t .sway-dev \ basu-dev \ cairo-dev \ eudev-dev \ eudev-dev \ gdk-pixbuf-dev \ glslang-dev \ hwdata-dev \ json-c-dev \ libcap-dev \ libcap-utils \ libdisplay-info-dev \ libevdev-dev \ libinput-dev \ libliftoff-dev \ libseat-dev \ libxcb-dev \ libxkbcommon-dev \ linux-pam-dev \ mesa-dev \ meson \ ninja \ pango-dev \ pcre2-dev \ pixman-dev \ scdoc \ vulkan-loader-dev \ wayland-dev \ wayland-protocols \ wlroots-dev \ xcb-util-image-dev \ xcb-util-renderutil-dev \ xcb-util-wm-dev \ xkeyboard-config-dev \ xwayland-dev
As mentioned in the packaging recommendations, it’s best to statically link
wlroots. This results in it being bundled into sway’s binary, instead of sway
loading the system
meson -DDwlroots:default_library=static build meson compile -C build doas meson install -C build
meson install will install sway into
/usr/local, and it won’t
overwrite the distribution-provided sway or any of its files. Since
/usr/local/bin/sway has precedence over
/usr/bin/sway, then this version
will be used by default when running
meson uninstall -C build will remove this version of sway and
un-shadow the stable one installed via distribution packages.