Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NVIDIA module build #167

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions linux-bore/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ _use_kcfi=${_use_kcfi-}
# If you use ZFS, refrain from building the RT kernel
_build_zfs=${_build_zfs-}

# Build the nvidia module in to the kernel
_build_nvidia=${_build_nvidia-}

ventureoo marked this conversation as resolved.
Show resolved Hide resolved
# Enable bcachefs
_bcachefs=${_bcachefs-}

Expand Down Expand Up @@ -196,6 +199,8 @@ if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_k
)
fi
_patchsource="https://raw.githubusercontent.com/cachyos/kernel-patches/master/${_major}"
_nv_ver=535.104.05
_nv_pkg="NVIDIA-Linux-x86_64-${_nv_ver}"
source=(
"https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/${_srcname}.tar.xz"
"config"
Expand All @@ -208,6 +213,11 @@ if [ -n "$_build_zfs" ]; then
source+=("git+https://github.com/cachyos/zfs.git#commit=8ce2eba9e6a384feef93d77c397f37d17dc588ce")
fi

# NVIDIA pre-build module support
if [ -n "$_build_nvidia" ]; then
source+=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${_nv_ver}/${_nv_pkg}.run")
fi

case "$_cpusched" in
cachyos) # CachyOS Scheduler (EEVDF + BORE)
source+=("${_patchsource}/sched/0001-EEVDF-cachy.patch"
Expand Down Expand Up @@ -637,12 +647,28 @@ prepare() {
echo "Save configuration for later reuse..."
cat .config > "${startdir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}"
sh "${_nv_pkg}.run" --extract-only
fi
}

build() {
cd ${srcdir}/${_srcname}
make ${BUILD_FLAGS[*]} -j$(nproc) all

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}/${_nv_pkg}/kernel"
local MODULE_FLAGS=(
KERNEL_UNAME="${pkgver}-${pkgsuffix}"
IGNORE_PREEMPT_RT_PRESENCE=1
NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES'
SYSSRC="${srcdir}/${_srcname}"
SYSOUT="${srcdir}/${_srcname}"
)
make ${BUILD_FLAGS[*]} ${MODULE_FLAGS[*]} -j$(nproc) modules
fi

if [ -n "$_build_zfs" ]; then
cd ${srcdir}/"zfs"

Expand Down Expand Up @@ -784,10 +810,20 @@ _package-zfs(){
# sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${pkgver}-${pkgbase}'/" "$startdir/zfs.install"
}

_package-nvidia(){
pkgdesc="nvidia module of ${_nv_ver} driver for the linux-$pkgsuffix kernel"
depends=("linux-$pkgsuffix=$_kernver" "nvidia-utils=${_nv_ver}" "libglvnd")
provides=('NVIDIA-MODULE')

cd "${srcdir}/${_nv_pkg}/"
install -dm755 "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
install -m644 kernel/*.ko "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
find "$pkgdir" -name '*.ko' -exec zstd --rm -10 {} +
}

pkgname=("$pkgbase" "$pkgbase-headers")
if [ -n "$_build_zfs" ]; then
pkgname+=("$pkgbase-zfs")
fi
[ -n "$_build_zfs" ] && pkgname+=("$pkgbase-zfs")
[ -n "$_build_nvidia" ] && pkgname+=("$pkgbase-nvidia")
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
Expand Down
42 changes: 39 additions & 3 deletions linux-cachyos-bmq/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ _use_kcfi=${_use_kcfi-}
# If you use ZFS, refrain from building the RT kernel
_build_zfs=${_build_zfs-}

# Build the nvidia module in to the kernel
_build_nvidia=${_build_nvidia-}

# Enable bcachefs
_bcachefs=${_bcachefs-}

Expand Down Expand Up @@ -196,6 +199,8 @@ if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_k
)
fi
_patchsource="https://raw.githubusercontent.com/cachyos/kernel-patches/master/${_major}"
_nv_ver=535.104.05
_nv_pkg="NVIDIA-Linux-x86_64-${_nv_ver}"
source=(
"https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/${_srcname}.tar.xz"
"config"
Expand All @@ -208,6 +213,11 @@ if [ -n "$_build_zfs" ]; then
source+=("git+https://github.com/cachyos/zfs.git#commit=8ce2eba9e6a384feef93d77c397f37d17dc588ce")
fi

# NVIDIA pre-build module support
if [ -n "$_build_nvidia" ]; then
source+=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${_nv_ver}/${_nv_pkg}.run")
fi

case "$_cpusched" in
cachyos) # CachyOS Scheduler (EEVDF + BORE)
source+=("${_patchsource}/sched/0001-EEVDF-cachy.patch"
Expand Down Expand Up @@ -637,12 +647,28 @@ prepare() {
echo "Save configuration for later reuse..."
cat .config > "${startdir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}"
sh "${_nv_pkg}.run" --extract-only
fi
}

build() {
cd ${srcdir}/${_srcname}
make ${BUILD_FLAGS[*]} -j$(nproc) all

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}/${_nv_pkg}/kernel"
local MODULE_FLAGS=(
KERNEL_UNAME="${pkgver}-${pkgsuffix}"
IGNORE_PREEMPT_RT_PRESENCE=1
NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES'
SYSSRC="${srcdir}/${_srcname}"
SYSOUT="${srcdir}/${_srcname}"
)
make ${BUILD_FLAGS[*]} ${MODULE_FLAGS[*]} -j$(nproc) modules
fi

if [ -n "$_build_zfs" ]; then
cd ${srcdir}/"zfs"

Expand Down Expand Up @@ -784,10 +810,20 @@ _package-zfs(){
# sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${pkgver}-${pkgbase}'/" "$startdir/zfs.install"
}

_package-nvidia(){
pkgdesc="nvidia module of ${_nv_ver} driver for the linux-$pkgsuffix kernel"
depends=("linux-$pkgsuffix=$_kernver" "nvidia-utils=${_nv_ver}" "libglvnd")
provides=('NVIDIA-MODULE')

cd "${srcdir}/${_nv_pkg}/"
install -dm755 "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
install -m644 kernel/*.ko "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
find "$pkgdir" -name '*.ko' -exec zstd --rm -10 {} +
}

pkgname=("$pkgbase" "$pkgbase-headers")
if [ -n "$_build_zfs" ]; then
pkgname+=("$pkgbase-zfs")
fi
[ -n "$_build_zfs" ] && pkgname+=("$pkgbase-zfs")
[ -n "$_build_nvidia" ] && pkgname+=("$pkgbase-nvidia")
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
Expand Down
42 changes: 39 additions & 3 deletions linux-cachyos-bore/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ _use_kcfi=${_use_kcfi-}
# If you use ZFS, refrain from building the RT kernel
_build_zfs=${_build_zfs-}

# Build the nvidia module in to the kernel
_build_nvidia=${_build_nvidia-}

# Enable bcachefs
_bcachefs=${_bcachefs-}

Expand Down Expand Up @@ -196,6 +199,8 @@ if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_k
)
fi
_patchsource="https://raw.githubusercontent.com/cachyos/kernel-patches/master/${_major}"
_nv_ver=535.104.05
_nv_pkg="NVIDIA-Linux-x86_64-${_nv_ver}"
source=(
"https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/${_srcname}.tar.xz"
"config"
Expand All @@ -208,6 +213,11 @@ if [ -n "$_build_zfs" ]; then
source+=("git+https://github.com/cachyos/zfs.git#commit=8ce2eba9e6a384feef93d77c397f37d17dc588ce")
fi

# NVIDIA pre-build module support
if [ -n "$_build_nvidia" ]; then
source+=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${_nv_ver}/${_nv_pkg}.run")
fi

case "$_cpusched" in
cachyos) # CachyOS Scheduler (EEVDF + BORE)
source+=("${_patchsource}/sched/0001-EEVDF-cachy.patch"
Expand Down Expand Up @@ -637,12 +647,28 @@ prepare() {
echo "Save configuration for later reuse..."
cat .config > "${startdir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}"
sh "${_nv_pkg}.run" --extract-only
fi
}

build() {
cd ${srcdir}/${_srcname}
make ${BUILD_FLAGS[*]} -j$(nproc) all

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}/${_nv_pkg}/kernel"
local MODULE_FLAGS=(
KERNEL_UNAME="${pkgver}-${pkgsuffix}"
IGNORE_PREEMPT_RT_PRESENCE=1
NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES'
SYSSRC="${srcdir}/${_srcname}"
SYSOUT="${srcdir}/${_srcname}"
)
make ${BUILD_FLAGS[*]} ${MODULE_FLAGS[*]} -j$(nproc) modules
fi

if [ -n "$_build_zfs" ]; then
cd ${srcdir}/"zfs"

Expand Down Expand Up @@ -784,10 +810,20 @@ _package-zfs(){
# sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${pkgver}-${pkgbase}'/" "$startdir/zfs.install"
}

_package-nvidia(){
pkgdesc="nvidia module of ${_nv_ver} driver for the linux-$pkgsuffix kernel"
depends=("linux-$pkgsuffix=$_kernver" "nvidia-utils=${_nv_ver}" "libglvnd")
provides=('NVIDIA-MODULE')

cd "${srcdir}/${_nv_pkg}/"
install -dm755 "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
install -m644 kernel/*.ko "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
find "$pkgdir" -name '*.ko' -exec zstd --rm -10 {} +
}

pkgname=("$pkgbase" "$pkgbase-headers")
if [ -n "$_build_zfs" ]; then
pkgname+=("$pkgbase-zfs")
fi
[ -n "$_build_zfs" ] && pkgname+=("$pkgbase-zfs")
[ -n "$_build_nvidia" ] && pkgname+=("$pkgbase-nvidia")
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
Expand Down
42 changes: 39 additions & 3 deletions linux-cachyos-cfs/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ _use_kcfi=${_use_kcfi-}
# If you use ZFS, refrain from building the RT kernel
_build_zfs=${_build_zfs-}

# Build the nvidia module in to the kernel
_build_nvidia=${_build_nvidia-}

# Enable bcachefs
_bcachefs=${_bcachefs-}

Expand Down Expand Up @@ -196,6 +199,8 @@ if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_k
)
fi
_patchsource="https://raw.githubusercontent.com/cachyos/kernel-patches/master/${_major}"
_nv_ver=535.104.05
_nv_pkg="NVIDIA-Linux-x86_64-${_nv_ver}"
source=(
"https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/${_srcname}.tar.xz"
"config"
Expand All @@ -208,6 +213,11 @@ if [ -n "$_build_zfs" ]; then
source+=("git+https://github.com/cachyos/zfs.git#commit=8ce2eba9e6a384feef93d77c397f37d17dc588ce")
fi

# NVIDIA pre-build module support
if [ -n "$_build_nvidia" ]; then
source+=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${_nv_ver}/${_nv_pkg}.run")
fi

case "$_cpusched" in
cachyos) # CachyOS Scheduler (EEVDF + BORE)
source+=("${_patchsource}/sched/0001-EEVDF-cachy.patch"
Expand Down Expand Up @@ -637,12 +647,28 @@ prepare() {
echo "Save configuration for later reuse..."
cat .config > "${startdir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}"
sh "${_nv_pkg}.run" --extract-only
fi
}

build() {
cd ${srcdir}/${_srcname}
make ${BUILD_FLAGS[*]} -j$(nproc) all

if [ -n "$_build_nvidia" ]; then
cd "${srcdir}/${_nv_pkg}/kernel"
local MODULE_FLAGS=(
KERNEL_UNAME="${pkgver}-${pkgsuffix}"
IGNORE_PREEMPT_RT_PRESENCE=1
NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES'
SYSSRC="${srcdir}/${_srcname}"
SYSOUT="${srcdir}/${_srcname}"
)
make ${BUILD_FLAGS[*]} ${MODULE_FLAGS[*]} -j$(nproc) modules
fi

if [ -n "$_build_zfs" ]; then
cd ${srcdir}/"zfs"

Expand Down Expand Up @@ -784,10 +810,20 @@ _package-zfs(){
# sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${pkgver}-${pkgbase}'/" "$startdir/zfs.install"
}

_package-nvidia(){
pkgdesc="nvidia module of ${_nv_ver} driver for the linux-$pkgsuffix kernel"
depends=("linux-$pkgsuffix=$_kernver" "nvidia-utils=${_nv_ver}" "libglvnd")
provides=('NVIDIA-MODULE')

cd "${srcdir}/${_nv_pkg}/"
install -dm755 "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
install -m644 kernel/*.ko "$pkgdir/usr/lib/modules/${_kernver}-${pkgsuffix}"
find "$pkgdir" -name '*.ko' -exec zstd --rm -10 {} +
}

pkgname=("$pkgbase" "$pkgbase-headers")
if [ -n "$_build_zfs" ]; then
pkgname+=("$pkgbase-zfs")
fi
[ -n "$_build_zfs" ] && pkgname+=("$pkgbase-zfs")
[ -n "$_build_nvidia" ] && pkgname+=("$pkgbase-nvidia")
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
Expand Down
Loading