This post was inspired by bootc for Desktops?? Tell me more!, with the assumption that if KDE is a viable option for bootc why not swaywm?
In the past 5 years I’ve been playing around rpm-ostree and immutable versions of Fedora, my Dekstop that I’m using for Games run Fedora Silverblue since F35. My working laptop is another story, it’s running the i3Spin from Fedora and trying to find time to build the Immutable version of i3Spin was challenging.
Since it’s 2024 and Fedora 41 just launched today, why not go for swaywm, the goal of this post is to breakdown how I did the build of my Desktop and how easy is for you to reproduce:
As mentioned before my journey started with Ben Breard blog post on how he created the KDE Desktop with bootc. My 1st step was to create this repo on Github to add my Containerfile
:
FROM quay.io/fedora/fedora-bootc:41
LABEL org.opencontainers.image.source="https://github.com/Odilhao/bootc-sway"
RUN mkdir -p /var/roothome /data /var/home
RUN dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
RUN dnf install -y fedora-release-sway && \
dnf group install -y "swaywm-extended"
#Spliting into 2 layers to reduce pul time with more layers
RUN dnf install -y firefox bash-completion bcache-tools bwm-ng cups cups-browsed dmraid ethtool firefox firewalld fwupd gdb git htop input-leap lm_sensors nfs-utils nss-mdns pcp pcp-selinux powertop qemu-kvm samba sysstat thermald tuned vim-enhanced vulkan-tools xdpyinfo wget && \
dnf swap -y ffmpeg-free ffmpeg --allowerasing && dnf install -y @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin && dnf group install -y "Sound and Video" && dnf swap -y mesa-va-drivers mesa-va-drivers-freeworld && dnf swap -y mesa-vdpau-drivers mesa-vdpau-drivers-freeworld && \
dnf install -y krb5-workstation podman libvirt-daemon pavucontrol vim git-annex virt-install virt-manager openvpn blueman bluez NetworkManager-bluetooth
RUN systemctl enable lm_sensors sysstat tuned fstrim.timer libvirtd.socket sddm && \
systemctl set-default graphical.target
I tried to stay as close as possible to the kickstart that is maintened on Fedora by the SIGs/Sway, you can find the links for the kickstart files at the end of this post.
After building the Container Image with:
sudo podman build -t sway-bootc -f Containerfile
You can generate your anaconda ISO to install the OS into your baremetal/laptop/desktop/mini-pc/anything is possible.
mkdir output
sudo podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./output:/output \
-v ./config.toml:/config.toml:ro \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type anaconda-iso \
--rootfs btrfs \
ghcr.io/odilhao/bootc-sway:latest
Note that in the command above we have config.toml
being mounted inside of the container, if you don’t have any config.toml
right now you use the example that I have in the repo:
cp config.toml.example config.toml
The file have this content:
[customizations.installer.kickstart]
contents = """
text --non-interactive
zerombr
network --bootproto=dhcp --device=link --activate --onboot=on
clearpart --all --initlabel
part btrfs.boot --fstype=btrfs --size=1024
part btrfs.main --fstype=btrfs --encrypted --grow --fsoptions="compress=zstd:1,space_cache=v2"
btrfs /boot --label=fedora-boot btrfs.boot
btrfs none --label=fedora-btrfs btrfs.main
btrfs / --subvol --name=root fedora-btrfs
btrfs /var/home --subvol --name=home fedora-btrfs
ostreecontainer --url docker pull ghcr.io/odilhao/bootc-sway:latest
firewall --disabled
services --enabled=sshd
# Only inject a SSH key for root
rootpw --iscrypted locked
sshkey --username root "<your key here>"
"""
I’m using btrfs as filesystem, you can use xfs as well, just change the --rootfs btrfs
to --rootfs xfs
and do the adjustments in the kickstart file. I’m also showing on the kickstart how you can create the root account, you can add the steps in the kickstart to create your regular use.
The ISO will be located in the output/bootiso/
directory, you can use any tool to write the iso to one USB stick and load into your target device. The installation will be automated and it will use the image that was given at ostreecontainer
line in the kickstart, this is the step that you need to have your image published in one OCI Registry in your network. Since the instalation method is kickstart based, you use your wifi by adding the wireless configuration.
This is all the necessary setup to have your swaywm Desktop.
I’ll probably write more about this in the future, since my intention is to daily drive this for at least 6 months.
References:
1 - https://mrguitar.net/?p=2627
2 - https://github.com/Odilhao/bootc-sway
3 - https://docs.fedoraproject.org/en-US/bootc/qemu-and-libvirt/
4 - https://pagure.io/fedora-kickstarts/blob/main/f/fedora-live-sway.ks
5 - https://pagure.io/fedora-kickstarts/blob/main/f/fedora-sway-common.ks
6 - https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#network