jupiter-hw-support: hook up udev rules

This commit is contained in:
K900
2024-03-14 10:33:28 +03:00
parent ffa51458ae
commit 041f801bda
4 changed files with 69 additions and 12 deletions

View File

@@ -57,8 +57,15 @@ in
HandlePowerKey=ignore
'';
# Required by automount scripts
services.udisks2.enable = true;
systemd.tmpfiles.rules = [
"d /run/media 0755 root root"
];
services.udev.packages = [
pkgs.powerbuttond
pkgs.jupiter-hw-support
];
# This rule allows the user to configure Wi-Fi in Deck UI.
@@ -79,13 +86,6 @@ in
}
});
'';
jovian.steam.environment = {
# We don't support adopting a drive, yet.
STEAM_ALLOW_DRIVE_ADOPT = mkDefault "0";
# Ejecting doesn't work, either.
STEAM_ALLOW_DRIVE_UNMOUNT = mkDefault "0";
};
}
]);
}

View File

@@ -22,7 +22,7 @@ let
src = callPackage ./src.nix { };
solution = {
scripts = [ "bin/*" "lib/hwsupport/*.sh" ];
scripts = [ "bin/*" "lib/hwsupport/*.sh" "lib/hwsupport/common-functions" ];
interpreter = "${bash}/bin/bash";
inputs = [
coreutils
@@ -66,6 +66,8 @@ let
# FIXME: why do we need to discard string context here?
"${builtins.unsafeDiscardStringContext "${systemd}/bin/systemd-run"}" = true;
"source:${placeholder "out"}/lib/hwsupport/common-functions" = true;
"${placeholder "out"}/lib/hwsupport/format-device.sh" = true;
"${placeholder "out"}/lib/hwsupport/steamos-automount.sh" = true;
};
};
in
@@ -85,10 +87,10 @@ stdenv.mkDerivation {
cp usr/bin/jupiter-check-support $out/bin
mkdir -p $out/lib
cp -r usr/lib/hwsupport $out/lib
cp -r usr/lib/{hwsupport,udev} $out/lib
substituteInPlace $out/lib/hwsupport/* \
--replace-warn ". /usr/lib/hwsupport" ". $out/lib/hwsupport"
substituteInPlace $out/lib/{hwsupport/*,udev/rules.d/*} \
--replace-warn "/usr/lib/hwsupport" "$out/lib/hwsupport"
${resholve.phraseSolution "jupiter-hw-support" solution}

View File

@@ -1,5 +1,5 @@
diff --git a/usr/lib/hwsupport/steamos-automount.sh b/usr/lib/hwsupport/steamos-automount.sh
index 386f4d8..cf79351 100755
index 386f4d8..d9ae25e 100755
--- a/usr/lib/hwsupport/steamos-automount.sh
+++ b/usr/lib/hwsupport/steamos-automount.sh
@@ -22,8 +22,9 @@ fi
@@ -23,3 +23,54 @@ index 386f4d8..cf79351 100755
echo "Sent URL to steam: steam://${command}/${arg} (steam://${command}/${encoded})"
else
echo "Could not send steam URL steam://${command}/${arg} (steam://${command}/${encoded}) -- steam not running"
@@ -90,12 +91,12 @@ do_mount()
"block_devices/${DEVBASE}" \
Filesystem Mount \
'a{sv}' 3 \
- as-user s deck \
+ as-user s "$(id -nu ${DECK_UID})" \
auth.no_user_interaction b true \
options s "$OPTS")
# Ensure that the deck user can write to the root directory
- if ! setpriv --clear-groups --reuid "${DECK_UID}" --regid "${DECK_GID}" test -w "${mount_point}"; then
+ if ! setpriv --clear-groups --reuid "${DECK_UID}" --regid "${DECK_GID}" @coreutils@/bin/test -w "${mount_point}"; then
chmod 777 "${mount_point}" || true
fi
diff --git a/usr/lib/udev/rules.d/80-gpu-reset.rules b/usr/lib/udev/rules.d/80-gpu-reset.rules
index 19727ba..7b4de4b 100644
--- a/usr/lib/udev/rules.d/80-gpu-reset.rules
+++ b/usr/lib/udev/rules.d/80-gpu-reset.rules
@@ -1,5 +1,6 @@
# If a GPU crash is caused by a specific process, kill the PID
-ACTION=="change", ENV{DEVNAME}=="/dev/dri/card0", ENV{RESET}=="1", ENV{PID}!="0", RUN+="/sbin/kill -9 %E{PID}"
+ACTION=="change", ENV{DEVNAME}=="/dev/dri/card0", ENV{RESET}=="1", ENV{PID}!="0", RUN+="@utilLinux@/bin/kill -9 %E{PID}"
# Kill SDDM and Gamescope if the GPU crashes and VRAM is lost
-ACTION=="change", ENV{DEVNAME}=="/dev/dri/card0", ENV{RESET}=="1", ENV{FLAGS}=="1", RUN+="/usr/sbin/systemctl restart sddm"
+# Jovian: also kill greetd
+ACTION=="change", ENV{DEVNAME}=="/dev/dri/card0", ENV{RESET}=="1", ENV{FLAGS}=="1", RUN+="@systemd@/bin/systemctl restart display-manager greetd"
diff --git a/usr/lib/udev/rules.d/99-sdcard-rescan.rules b/usr/lib/udev/rules.d/99-sdcard-rescan.rules
index 05b6167..7cc487e 100644
--- a/usr/lib/udev/rules.d/99-sdcard-rescan.rules
+++ b/usr/lib/udev/rules.d/99-sdcard-rescan.rules
@@ -1,3 +1,3 @@
# Work around the misdetection of some SanDisk microSD cards
-ACTION=="add", SUBSYSTEM=="mmc", ENV{MMC_NAME}=="SD032", RUN+="/bin/systemd-run --no-block --collect /usr/lib/hwsupport/sdcard-rescan.sh %k"
+ACTION=="add", SUBSYSTEM=="mmc", ENV{MMC_NAME}=="SD032", RUN+="@systemd@/bin/systemd-run --no-block --collect /usr/lib/hwsupport/sdcard-rescan.sh %k"
diff --git a/usr/lib/udev/rules.d/99-steamos-automount.rules b/usr/lib/udev/rules.d/99-steamos-automount.rules
index 49a5968..1344fa5 100644
--- a/usr/lib/udev/rules.d/99-steamos-automount.rules
+++ b/usr/lib/udev/rules.d/99-steamos-automount.rules
@@ -5,7 +5,7 @@ KERNEL!="mmcblk*|sd*", GOTO="steamos_automount_end"
ENV{ID_FS_USAGE}!="filesystem", GOTO="steamos_automount_end"
# The service expects to be asynchronous and shouldn't block udev rules
-ACTION=="add", RUN+="/bin/systemd-run --no-block --collect /usr/lib/hwsupport/block-device-event.sh add %k"
-ACTION=="remove", RUN+="/bin/systemd-run --no-block --collect /usr/lib/hwsupport/block-device-event.sh remove %k"
+ACTION=="add", RUN+="@systemd@/bin/systemd-run --no-block --collect /usr/lib/hwsupport/block-device-event.sh add %k"
+ACTION=="remove", RUN+="@systemd@/bin/systemd-run --no-block --collect /usr/lib/hwsupport/block-device-event.sh remove %k"
LABEL="steamos_automount_end"

View File

@@ -3,7 +3,9 @@
fetchFromGitHub,
substituteAll,
jovian-steam-protocol-handler,
coreutils,
systemd,
util-linux,
}:
stdenv.mkDerivation rec {
@@ -20,7 +22,9 @@ stdenv.mkDerivation rec {
patches = [
(substituteAll {
handler = jovian-steam-protocol-handler;
coreutils = coreutils;
systemd = systemd;
utilLinux = util-linux;
src = ./jovian.patch;
})
# Fix controller updates with python-hid >= 1.0.6