Fiw-Gentoo-Dots/optional/fiw-nyx-bump
Fi3w0 8dc93f7ff9
All checks were successful
Check and mirror to GitHub / checks (push) Successful in 22s
Check and mirror to GitHub / github-mirror (push) Successful in 11s
Add opt-in Nyx 7.4-rc1 with an NVIDIA compat patch
The live system moved from 7.3.1 to CachyOS 7.4-rc1 after 7.3 misbehaved on the
MT7925, and it boots on the RTX 3060 with KWin and Plasma running. Early check
only, so installs stay on 7.3.1.

- Bundle fiw-nyx-kernel-7.4_rc1-r1 and its virtual. Empty KEYWORDS and the
  unchanged snapshot.json keep installers from picking it.
- Add a patch for NVIDIA 595.104.02, which does not build against 7.4. It is
  ported from the unmerged NVIDIA/open-gpu-kernel-modules PR 1414, without the
  dmem hunks 595 has no code for.
- Stop fiw-nyx-bump copying or pruning rc ebuilds, and follow an rc in the mask
  only where Portage can see it.
- Document the opt-in steps.
2026-11-05 18:57:36 +01:00

77 lines
3.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# fiw-nyx-bump [series]
# Keeps sys-kernel/fiw-nyx-kernel::fiw on CachyOS's newest release in the
# kernel series it is on (or in [series], e.g. 7.3, to move to a new one):
# - copies the newest fiw-nyx-kernel ebuild to <ver>-r<cachyos release>,
# taking the Gentoo patchset and config versions from ::gentoo's
# gentoo-kernel for that series, plus a matching virtual/dist-kernel
# (so nvidia-drivers and other dist-kernel modules rebuild for it),
# with Manifests;
# - writes /etc/portage/package.mask/fiw-nyx so virtual/dist-kernel and
# gentoo-kernel-bin never run ahead of the Nyx kernel (modules build for
# the newest kernel installed, which must be Nyx).
# Release-candidate ebuilds are opt-in: they are never copied or pruned here,
# and the mask only follows one that Portage can see (accept_keywords **).
# Run as root (the postsync hook does). Keeps the two newest Nyx versions.
set -euo pipefail
repo=${FIW_NYX_REPO:-$(portageq get_repo_path / fiw)}
gentoo=$(portageq get_repo_path / gentoo)
pkgdir=$repo/sys-kernel/fiw-nyx-kernel
vdir=$repo/virtual/dist-kernel
mask=${FIW_NYX_MASK:-/etc/portage/package.mask/fiw-nyx}
newest=$(ls "$pkgdir"/fiw-nyx-kernel-*.ebuild | grep -v _rc | sort -V | tail -1)
cur=$(basename "$newest" .ebuild); cur=${cur#fiw-nyx-kernel-} # 7.2.11-r1
cur_ver=${cur%-r*}
series=${1:-${cur_ver%.*}}
tag=$(curl -fsSL "https://api.github.com/repos/CachyOS/linux/releases?per_page=100" |
grep -oE "\"tag_name\": *\"cachyos-${series//./\\.}\.[0-9]+-[0-9]+\"" |
grep -oE "cachyos-[0-9.]+-[0-9]+" | sort -uV | tail -1) || true
if [[ -z $tag ]]; then
echo "fiw-nyx-bump: CachyOS has no ${series}.x release; staying on ${cur}"
tag=cachyos-${cur%-r*}-${cur##*-r}
fi
ver=${tag#cachyos-}; rel=${ver##*-}; ver=${ver%-*}
target=$pkgdir/fiw-nyx-kernel-${ver}-r${rel}.ebuild
if [[ ! -e $target ]]; then
echo "fiw-nyx-bump: adding fiw-nyx-kernel-${ver}-r${rel} (${tag})"
cp "$newest" "$target"
# Gentoo's patchset/config for this series, from its own gentoo-kernel.
ref=$(ls "$gentoo"/sys-kernel/gentoo-kernel/gentoo-kernel-"${series}".*.ebuild 2>/dev/null | sort -V | tail -1 || true)
if [[ -n $ref ]]; then
for var in PATCHSET CONFIG_VER GENTOO_CONFIG_P; do
val=$(sed -n "s/^${var}=//p" "$ref" | head -1)
[[ -n $val ]] && sed -i "s|^${var}=.*|${var}=${val}|" "$target"
done
# the patchset's directory on distfiles.gentoo.org follows its series
pset=$(sed -n 's/^PATCHSET=linux-gentoo-patches-//p' "$target")
sed -i "s|patchsets/[0-9]*\.[0-9]*/|patchsets/${pset%.*}/|" "$target"
fi
vnewest=$(ls "$vdir"/dist-kernel-*.ebuild | sort -V | tail -1)
cp "$vnewest" "$vdir/dist-kernel-${ver}-r${rel}.ebuild"
# Keep the two newest versions (and their virtuals), then the Manifests
# (thin: they fetch every listed version's sources, so prune first).
ls "$pkgdir"/fiw-nyx-kernel-*.ebuild | grep -v _rc | sort -V | head -n -2 | while read -r old; do
v=$(basename "$old" .ebuild); v=${v#fiw-nyx-kernel-}
rm -f "$old" "$vdir/dist-kernel-${v}.ebuild"
done
ebuild "$target" manifest
ebuild "$vdir/dist-kernel-${ver}-r${rel}.ebuild" manifest
chown -R --reference="$repo" "$pkgdir" "$vdir"
fi
mask_pvr=${ver}-r${rel}
best=$(portageq best_visible / ebuild sys-kernel/fiw-nyx-kernel 2>/dev/null) || true
[[ $best == *_rc* ]] && mask_pvr=${best##*/fiw-nyx-kernel-}
cat >"$mask.tmp" <<EOF
# Written by fiw-nyx-bump: dist-kernel modules (nvidia-drivers) build for
# the newest installed kernel, so nothing may get ahead of fiw-nyx-kernel.
>virtual/dist-kernel-${mask_pvr}
>sys-kernel/gentoo-kernel-bin-${mask_pvr%-r*}
EOF
mv "$mask.tmp" "$mask"
echo "fiw-nyx-bump: Nyx is at ${mask_pvr} (newest stable ${ver}-r${rel}, ${tag})"