From 3538e07ef2278bb9e810345561a5d3d8e22e7183 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 1 Aug 2023 21:10:14 +0200
Subject: [PATCH] Improve w530 setup.

---
 bookworm/apt-mark/w530                           | 13 +++++++++++++
 .../w530/etc/modprobe.d/blacklist-nouveau.conf   |  3 +++
 bookworm/setup_scripts/setup_desktop.sh          | 16 ++++++++++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 bookworm/apt-mark/w530
 create mode 100644 bookworm/etc_files/w530/etc/modprobe.d/blacklist-nouveau.conf

diff --git a/bookworm/apt-mark/w530 b/bookworm/apt-mark/w530
new file mode 100644
index 0000000..46d4321
--- /dev/null
+++ b/bookworm/apt-mark/w530
@@ -0,0 +1,13 @@
+# for open-gpu-kernel-modules building
+gcc
+g++
+make
+linux-headers-6.1.0-10-amd64
+xz-utils
+# for NVIDIA driver .run --no-kernel-modules
+libvulkan1
+libglvnd-dev
+pkg-config
+# so we can add nvidia.NVreg_OpenRmEnableUnsupportedGpus=1 to default grub
+grub-efi-amd64
+
diff --git a/bookworm/etc_files/w530/etc/modprobe.d/blacklist-nouveau.conf b/bookworm/etc_files/w530/etc/modprobe.d/blacklist-nouveau.conf
new file mode 100644
index 0000000..9699336
--- /dev/null
+++ b/bookworm/etc_files/w530/etc/modprobe.d/blacklist-nouveau.conf
@@ -0,0 +1,3 @@
+blacklist nouveau
+options nouveau modeset=0
+
diff --git a/bookworm/setup_scripts/setup_desktop.sh b/bookworm/setup_scripts/setup_desktop.sh
index f265697..4b5a554 100755
--- a/bookworm/setup_scripts/setup_desktop.sh
+++ b/bookworm/setup_scripts/setup_desktop.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 set -e
+set -x
 debian_version="bookworm"
 legal_system_names="x220 w530"
 
@@ -25,3 +26,18 @@ config_tree_prefix="${HOME}/config/${debian_version}"
 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
 cd "${setup_scripts_dir}"
 ./setup.sh "${system_name}" "" user desktop thinkpad "${system_name}"
+
+if [ "$system_name" = "w530" ]; then
+    cd
+    git clone https://github.com/NVIDIA/open-gpu-kernel-modules
+    cd open-gpu-kernel-modules
+    git checkout 337e28e
+    make modules -j($nproc)
+    make modules_install
+    cd
+    driver_version=535.86.05
+    runscript=NVIDIA-Linux-x86_64-${driver_version}.run
+    wget https://us.download.nvidia.com/XFree86/Linux-x86_64/${driver_version}/${runscript}
+    chmod u+x ${runscript} 
+    ./${runscript} --no-kernel-modules
+fi
-- 
2.30.2