diff --git a/lib/modules/hardware.nix b/lib/modules/hardware.nix index b4167afd..d04ea602 100644 --- a/lib/modules/hardware.nix +++ b/lib/modules/hardware.nix @@ -14,6 +14,18 @@ default = []; }; + surfaceBook = mkOption { + type = types.bool; + description = "A value indicating whether the system is a Surface Book 2."; + default = false; + }; + + xoneReceiver = mkOption { + type = types.bool; + description = "A value indicating whether an Xbox receiver is present."; + default = false; + }; + eyeX = mkOption { type = types.bool; description = "A value indicating whether a Tobii EyeX device is present."; diff --git a/profiles/machines/manuel/DerGeret/config.nix b/profiles/machines/manuel/DerGeret/config.nix index c93b195b..69c7fb8d 100644 --- a/profiles/machines/manuel/DerGeret/config.nix +++ b/profiles/machines/manuel/DerGeret/config.nix @@ -42,6 +42,7 @@ "Predator Z301C" ]; + xoneReceiver = true; eyeX = true; amdCPU = true; nvidiaGPU = true; diff --git a/profiles/machines/manuel/ManuSurface/config.nix b/profiles/machines/manuel/ManuSurface/config.nix index 5f59a796..c9e56677 100644 --- a/profiles/machines/manuel/ManuSurface/config.nix +++ b/profiles/machines/manuel/ManuSurface/config.nix @@ -7,6 +7,12 @@ valhalla = { hostname = "manu-surface"; linux.secureBoot = true; + + hardware = { + surfaceBook = true; + xoneReceiver = true; + }; + partition.os.deviceName = "nvme0n1"; }; }; diff --git a/scripts/Arch/Drivers/Surface/main.fish b/scripts/Arch/Drivers/Surface/main.fish new file mode 100755 index 00000000..1e674f46 --- /dev/null +++ b/scripts/Arch/Drivers/Surface/main.fish @@ -0,0 +1,44 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../Scripts/software.fish" + + function installSW -V dir + set -l repo "linux-surface" + set -l file "/etc/pacman.conf" + + curl -s https://raw.githubusercontent.com/linux-surface/linux-surface/master/pkg/keys/surface.asc \ + | sudo pacman-key --add - + + sudo pacman-key --finger 56C464BAAC421453 + sudo pacman-key --lsign-key 56C464BAAC421453 + + if ! grep "^\[$repo\]\$" $file + begin + printf %s\n \ + "" \ + "[$repo]" \ + "Server = https://pkg.surfacelinux.com/arch/" + end | sudo tee -a $file > /dev/null + + sudo pacinst + + sudo pacinst \ + intel-ucode \ + linux-surface \ + linux-surface-headers \ + linux-surface-secureboot-mok \ + iptsd \ + linux-firmware-marvell + + yes | runYay libwacom-surface + yayinst libcamera-git + end + end + + function configureSW -V dir + fish "$dir/../../Software/GRUB/main.fish" configure + end + + runInstaller $argv +end diff --git a/scripts/Arch/Drivers/SurfaceBook2/main.fish b/scripts/Arch/Drivers/SurfaceBook2/main.fish new file mode 100755 index 00000000..79185a03 --- /dev/null +++ b/scripts/Arch/Drivers/SurfaceBook2/main.fish @@ -0,0 +1,25 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../Scripts/software.fish" + + function installSW -V dir + yayinst \ + surface-dtx-daemon-bin \ + surface-control-bin + end + + function configureSW -V dir + begin + printf %s\n \ + "# vim:set ft=sh" \ + "MODULES+=(pinctrl_sunrisepoint surface_dtx)" + end | sudo tee /etc/mkinitcpio.conf.d/surface-book-2.conf > /dev/null + + sudo systemctl enable surface-dtx-daemon.service + sudo systemctl enable --global surface-dtx-userd.service + end + + runInstaller $argv + fish "$dir/../Surface/main.fish" $argv +end diff --git a/scripts/Arch/Scripts/deploy.fish b/scripts/Arch/Scripts/deploy.fish index 440dbf6c..5aea0650 100644 --- a/scripts/Arch/Scripts/deploy.fish +++ b/scripts/Arch/Scripts/deploy.fish @@ -18,6 +18,18 @@ function deploySoftware -d "Deploys a the specified software action" -a action source "$dir/../Config/SecureBoot/main.fish" $argv end + and if isEnabled valhalla.linux.hardware.surfaceBook + source "$dir/../Drivers/SurfaceBook2/main.fish" $argv + end + + and if isEnabled valhalla.linux.hardware.nvidiaGPU + source "$dir/../Software/nvidia-dkms/main.fish" $argv + end + + and if isEnabled valhalla.linux.hardware.xoneReceiver + source "$dir/../Software/xone/main.fish" $argv + end + and if isEnabled valhalla.windows.dualboot.enable && $isInstall yayinst bt-dualboot end diff --git a/scripts/Arch/Software/nvidia-dkms/main.fish b/scripts/Arch/Software/nvidia-dkms/main.fish new file mode 100755 index 00000000..2b587e86 --- /dev/null +++ b/scripts/Arch/Software/nvidia-dkms/main.fish @@ -0,0 +1,28 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../Scripts/software.fish" + + function installSW + yayinst \ + nvidia-beta-dkms \ + lib32-nvidia-utils-beta + end + + function configureSW -V dir + begin + printf %s\n \ + "MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)" \ + "" \ + 'for i in "${!HOOKS[@]}"; do' \ + ' if [ "${HOOKS[i]}" = "kms" ]; then' \ + ' unset "HOOKS[i]"' \ + " fi" \ + "done" + end | sudo tee /etc/mkinitcpio.conf.d/nvidia.conf > /dev/null + + fish "$dir/../../../Common/Software/nvidia-dkms/main.fish" configure + end + + runInstaller $argv +end diff --git a/scripts/Arch/Software/xone/main.fish b/scripts/Arch/Software/xone/main.fish new file mode 100755 index 00000000..b3ef9ede --- /dev/null +++ b/scripts/Arch/Software/xone/main.fish @@ -0,0 +1,22 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../Scripts/software.fish" + + function installSW + set -l contextRoot (mktemp -d) + set -l repo https://github.com/manuth/xone.git + yayinst cabextract + + if not dkms status --all | grep xone > /dev/null + git clone "$repo" "$contextRoot" + sudo env -C "$contextRoot" ./install.sh --release + sudo chmod -R a+rx /usr/src/xone* + yes "" | sudo xone-get-firmware.sh + end + + rm -rf "$contextRoot" > /dev/null + end + + runInstaller $argv +end diff --git a/scripts/Common/Software/nvidia-dkms/main.fish b/scripts/Common/Software/nvidia-dkms/main.fish new file mode 100755 index 00000000..5eac86a2 --- /dev/null +++ b/scripts/Common/Software/nvidia-dkms/main.fish @@ -0,0 +1,34 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../Scripts/software.fish" + + function configureSW -V dir + set -l indicator "GRUB_CMDLINE_LINUX_DEFAULT=\"" + set -l config "nvidia_drm.fbdev=1" + + # According to: https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks + begin + printf %s\n \ + "options nvidia NVreg_PreserveVideoMemoryAllocations=1" \ + "options nvidia NVreg_TemporaryFilePath=/var/tmp" + end | sudo tee /etc/modprobe.d/nvidia-power-management.conf > /dev/null + + sudo systemctl enable \ + nvidia-suspend.service \ + nvidia-hibernate.service \ + nvidia-resume.service + + if ! cat /etc/default/grub | grep "$indicator.*$config" > /dev/null + sudo sed -i /etc/default/grub \ + -e "/$indicator/{" \ + -e "s/\($indicator.*[^ ]\)\(\"\)/\1 \2/" \ + -e "s/\($indicator.*\)\(\"\)/\1$config\2/" \ + -e "}" + + fish "$dir/../GRUB/main.fish" configure + end + end + + runInstaller $argv +end