diff --git a/files/scripts/cachyos-kernel.sh b/files/scripts/cachyos-kernel.sh new file mode 100644 index 0000000..6a42c13 --- /dev/null +++ b/files/scripts/cachyos-kernel.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Replaces the stock Fedora kernel with the CachyOS LTO kernel. +# CachyOS LTO kernel is compiled with Link-Time Optimization and ships +# sched-ext (SCX) support, giving lower latency for realtime audio workloads. +# +# Adapted from the Zena project (https://github.com/zena-linux/zena), +# specifically build-scripts/modules/base/kernel.sh. +# Zena is licensed under the Apache License 2.0. +# Credit to the Zena contributors: https://github.com/zena-linux/zena/graphs/contributors + +set -ouex pipefail + +shopt -s nullglob + +KERNEL_PACKAGES=( + kernel-cachyos-lto + kernel-cachyos-lto-core + kernel-cachyos-lto-devel-matched + kernel-cachyos-lto-modules +) + +# Disable kernel install hooks so the custom kernel installs cleanly into the image +pushd /usr/lib/kernel/install.d +printf '%s\n' '#!/bin/sh' 'exit 0' > 05-rpmostree.install +printf '%s\n' '#!/bin/sh' 'exit 0' > 50-dracut.install +chmod +x 05-rpmostree.install 50-dracut.install +popd + +# Remove stock Fedora kernel packages +for pkg in kernel kernel-core kernel-modules kernel-modules-core; do + rpm --erase "$pkg" --nodeps || true +done + +# Remove leftover kernel module directory +CURRENT_MODULES=$(ls /usr/lib/modules | head -n1) +if [ -n "$CURRENT_MODULES" ]; then + rm -rf "/usr/lib/modules/$CURRENT_MODULES" +fi + +# Install the CachyOS LTO kernel (repos were added via the preceding dnf module) +dnf5 -y install "${KERNEL_PACKAGES[@]}" + +# Version-lock to prevent the kernel from being overwritten by base image updates +dnf5 versionlock add "${KERNEL_PACKAGES[@]}" || true + +# /boot is not used in atomic container images +rm -rf /boot/* diff --git a/recipes/common/copr-packages.yml b/recipes/common/copr-packages.yml index dd533ea..0319387 100644 --- a/recipes/common/copr-packages.yml +++ b/recipes/common/copr-packages.yml @@ -2,6 +2,8 @@ modules: - type: dnf repos: copr: + - bieszczaders/kernel-cachyos-lto + - bieszczaders/kernel-cachyos-addons - patrickl/wine-tkg - timlau/audio - alternateved/eza diff --git a/recipes/common/fedora-packages.yml b/recipes/common/fedora-packages.yml index 1600d80..6637711 100644 --- a/recipes/common/fedora-packages.yml +++ b/recipes/common/fedora-packages.yml @@ -2,6 +2,17 @@ modules: - type: dnf install: packages: + # CachyOS kernel performance companion packages + # cachyos-settings: kernel tunables and sysctl optimisations from CachyOS + # cachyos-ksm-settings: Kernel Samepage Merging tuning (reduces RAM usage) + # scx-manager / scx-scheds / scx-tools: sched-ext schedulers; + # scx_lavd is ideal for low-latency realtime audio workloads + - cachyos-settings + - cachyos-ksm-settings + - scx-manager + - scx-scheds-git + - scx-tools-git + # useful tools - zsh - openssl diff --git a/recipes/recipe.yml b/recipes/recipe.yml index 394ee54..9b16fd7 100644 --- a/recipes/recipe.yml +++ b/recipes/recipe.yml @@ -3,13 +3,25 @@ # image will be published to ghcr.io// name: miasma-os # description will be included in the image's metadata -description: An personal spin based on Bazzite targeted towards musicians and music producers inspired by Fedora Jam +description: A personal spin based on Kinoite targeted towards musicians and music producers, with the CachyOS kernel for low-latency performance # the base image to build on top of (FROM) and the version tag to use -base-image: ghcr.io/ublue-os/bazzite +base-image: ghcr.io/ublue-os/kinoite-main image-version: latest # latest is also supported if you want new updates ASAP modules: + # Add CachyOS repos first so the kernel swap script can use them + - type: dnf + repos: + copr: + - bieszczaders/kernel-cachyos-lto + - bieszczaders/kernel-cachyos-addons + + # Swap stock Fedora kernel for CachyOS LTO kernel + - type: script + scripts: + - cachyos-kernel.sh + - type: dnf install: packages: