From c9e6b52836b55f141dd3dc53bffb4940a8ce990e Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 12 Aug 2024 19:41:39 +0200
Subject: [PATCH] Improve h610m testing nvidia setup.

---
 testing/apt-mark/h610m                 |  6 +-
 testing/setup_scripts/setup_desktop.sh | 27 +++-----
 testing/setup_scripts/setup_home.sh    | 86 +++++++++++++-------------
 3 files changed, 53 insertions(+), 66 deletions(-)

diff --git a/testing/apt-mark/h610m b/testing/apt-mark/h610m
index fac5b05..645086f 100644
--- a/testing/apt-mark/h610m
+++ b/testing/apt-mark/h610m
@@ -1,10 +1,10 @@
 # for X to start at all
 linux-headers-amd64
-#nvidia-driver
-#firmware-misc-nonfree
+nvidia-driver
+firmware-misc-nonfree
 # X input: keyboard
 xserver-xorg-input-evdev
-# CUDA
+## CUDA
 #nvidia-cuda-dev
 #nvidia-cuda-toolkit
 
diff --git a/testing/setup_scripts/setup_desktop.sh b/testing/setup_scripts/setup_desktop.sh
index 1947321..b9eba61 100755
--- a/testing/setup_scripts/setup_desktop.sh
+++ b/testing/setup_scripts/setup_desktop.sh
@@ -13,26 +13,13 @@ else
     ./_setup.sh "${system_name}" "" user desktop "${system_name}"
 fi
 
-# # Set up NVIDIA eGPU config.
-# if [ "$system_name" = "w530" ]; then
-#     cd
-#     git clone https://github.com/NVIDIA/open-gpu-kernel-modules
-#     cd open-gpu-kernel-modules
-#     git checkout 337e28e
-#     # git checkout 4c29105335610933e744f4ab2524ea63fc39edaf
-#     make modules -j$(nproc)
-#     make modules_install
-#     cd
-#     driver_version=535.86.05
-#     # driver_version=545.29.06
-#     runscript=NVIDIA-Linux-x86_64-${driver_version}.run
-#     wget https://us.download.nvidia.com/XFree86/Linux-x86_64/${driver_version}/${runscript}
-#     rmmod nouveau
-#     chmod u+x ${runscript} 
-#     ./${runscript} --no-kernel-modules --silent
-#     depmod
-#     # TODO I suspect that the GPU falling of the bus may be mildened by running nvidia-persistenced, check https://github.com/NVIDIA/nvidia-persistenced/tree/main/init  
-# fi
+# Upgrade to testing, but hold kernel known to work with nvidia-drivers.
+sed -i 's/bookworm/testing/g' /etc/apt/sources.list
+if [ "$system_name" = "h610m" ]; then
+    apt-mark hold linux-image-amd64 linux-headers-amd64
+fi
+apt update
+apt dist-upgrade
 
 # Set up user environments.
 cd "${setup_scripts_dir}"
diff --git a/testing/setup_scripts/setup_home.sh b/testing/setup_scripts/setup_home.sh
index 130bbad..592573a 100755
--- a/testing/setup_scripts/setup_home.sh
+++ b/testing/setup_scripts/setup_home.sh
@@ -26,49 +26,49 @@ cd $setup_scripts_dir
 # sudo chown -R plom:plom "${target_dir_secrets}"
 # sudo pumount "${secrets_dev}"
 # echo "You can remove /dev/${secrets_dev} now."
-
-# Set up iniitial non-public parts of infrastructure: SSH authentication.
-ssh_dir=~/.ssh
-cd "${target_dir_secrets}"
-mkdir -p "${ssh_dir}"
-echo "Setting up .ssh"
-cp id_rsa ~/.ssh
-stty -echo
-ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
-stty echo
-eval $(ssh-agent)
-ssh-add
-ssh-keyscan -H "plomlompom.com" >> ~/.ssh/known_hosts
-
-# Fill ~/public_repos.
-public_repos_dir="${HOME}/public_repos"
-repos_list_file="${public_repos_dir}/repos"
-mkdir -p "${public_repos_dir}"
-cat "${repos_list_file}" | while read line; do
-    first_char=$(echo "${line}" | cut -c1)
-    if [ "${first_char}" = "#" ]; then
-        continue
-    fi
-    repo_name="${line}"
-    if [ ! -d "${public_repos_dir}/${repo_name}" ]; then
-        cd "${public_repos_dir}"
-        git clone plom@plomlompom.com:/var/repos/${repo_name}
-    fi
-done
-
-# Remove redundant config repo copy.
-config_tree_prefix="${public_repos_dir}/config/${debian_version}"
-rm -rf ~/config
-
+# 
+# # Set up iniitial non-public parts of infrastructure: SSH authentication.
+# ssh_dir=~/.ssh
+# cd "${target_dir_secrets}"
+# mkdir -p "${ssh_dir}"
+# echo "Setting up .ssh"
+# cp id_rsa ~/.ssh
+# stty -echo
+# ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
+# stty echo
+# eval $(ssh-agent)
+# ssh-add
+# ssh-keyscan -H "plomlompom.com" >> ~/.ssh/known_hosts
+# 
+# # Fill ~/public_repos.
+# public_repos_dir="${HOME}/public_repos"
+# repos_list_file="${public_repos_dir}/repos"
+# mkdir -p "${public_repos_dir}"
+# cat "${repos_list_file}" | while read line; do
+#     first_char=$(echo "${line}" | cut -c1)
+#     if [ "${first_char}" = "#" ]; then
+#         continue
+#     fi
+#     repo_name="${line}"
+#     if [ ! -d "${public_repos_dir}/${repo_name}" ]; then
+#         cd "${public_repos_dir}"
+#         git clone plom@plomlompom.com:/var/repos/${repo_name}
+#     fi
+# done
+# 
+# # Remove redundant config repo copy.
+# config_tree_prefix="${public_repos_dir}/config/${debian_version}"
+# rm -rf ~/config
+# 
 # # Set up native messenger for tridactyl.
 # version='ef9f02d0da258f68d7faf8898707f6d83d90d07a'
 # curl -fsSl "https://raw.githubusercontent.com/tridactyl/tridactyl/${version}/native/install.sh" | bash
-
-# Set up further non-public parts of infrastructure.
-cd "${target_dir_secrets}"
-script -c 'gpg --import secret_keys.asc' /dev/null
-path_borgscript="${config_tree_prefix}//borg.sh"
-
+# 
+# # Set up further non-public parts of infrastructure.
+# cd "${target_dir_secrets}"
+# script -c 'gpg --import secret_keys.asc' /dev/null
+# path_borgscript="${config_tree_prefix}//borg.sh"
+# 
 # # borg setup
 # borgkeys_dir=~/.config/borg/keys
 # borgrepos_file=~/.borgrepos
@@ -103,6 +103,6 @@ path_borgscript="${config_tree_prefix}//borg.sh"
 #     mbsync -a
 #     notmuch new
 # fi
-
-# # Final note on how to integrate tridactyl.
-# echo "TODO: As tridactyl user, don't forget to do :source on the first Firefox run, wait a little while (Tridactyl needs to walk through all commands in the .tridactylrc) and then re-start."
+# 
+# # # Final note on how to integrate tridactyl.
+# # echo "TODO: As tridactyl user, don't forget to do :source on the first Firefox run, wait a little while (Tridactyl needs to walk through all commands in the .tridactylrc) and then re-start."
-- 
2.30.2