-
Notifications
You must be signed in to change notification settings - Fork 54
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
steamdeck: Enable automount #413
Merged
samueldr
merged 11 commits into
Jovian-Experiments:development
from
hotburger:fix-automount
Oct 6, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ca1ac33
package udev rule
hotburger f9dbf9e
add automount option
hotburger bed1c6f
also package sdcard rescan rules
hotburger 02cd8a9
jupiter-hw-support: Isolate patching paths into a patch...
samueldr 91f86eb
jupiter-hw-support: Bring back UID/GID fix, but also username
samueldr 81d4c94
jupiter-hw-support: Two minor fixes for silly system configs
samueldr e35aa62
jupiter-hw-support/polkit-helpers: Use --replace-fail
samueldr 660806b
steam: Allow unmounting devices
samueldr 616d08e
steam: Ensure steamos-manager can call umount
samueldr 0068865
jupiter-hw-support: Update package description for what it's become
samueldr a4109a5
automount: Move into `steamos` namespace
samueldr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkIf | ||
mkMerge | ||
mkOption | ||
types | ||
; | ||
cfg = config.jovian.steamos; | ||
in | ||
{ | ||
options = { | ||
jovian.steamos = { | ||
enableAutoMountUdevRules = mkOption { | ||
default = cfg.useSteamOSConfig; | ||
defaultText = lib.literalExpression "config.jovian.steamos.useSteamOSConfig"; | ||
type = types.bool; | ||
description = '' | ||
Whether to enable udev rules to automatically mount SD cards upon insertion. | ||
''; | ||
}; | ||
}; | ||
}; | ||
config = mkMerge [ | ||
(mkIf (cfg.enableAutoMountUdevRules) { | ||
services.udev.packages = [ | ||
pkgs.jupiter-hw-support | ||
]; | ||
}) | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ let | |
in | ||
{ | ||
imports = [ | ||
./automount.nix | ||
./bluetooth.nix | ||
./boot.nix | ||
./mesa.nix | ||
|
45 changes: 45 additions & 0 deletions
45
pkgs/jupiter-hw-support/0001-Jovian-Ensure-automounting-works-for-any-UID-1000-us.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
From 42798ed60fbc601cefab84fd1f2c8dab95906702 Mon Sep 17 00:00:00 2001 | ||
From: Samuel Dionne-Riel <[email protected]> | ||
Date: Sun, 29 Sep 2024 02:52:26 -0400 | ||
Subject: [PATCH] =?UTF-8?q?[Jovian]=C2=A0Ensure=20automounting=20works=20f?= | ||
=?UTF-8?q?or=20any=20UID=201000=20username?= | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
Signed-off-by: Samuel Dionne-Riel <[email protected]> | ||
--- | ||
usr/lib/hwsupport/steamos-automount.sh | 10 +++++++--- | ||
1 file changed, 7 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/usr/lib/hwsupport/steamos-automount.sh b/usr/lib/hwsupport/steamos-automount.sh | ||
index 386f4d8..8583ca7 100755 | ||
--- a/usr/lib/hwsupport/steamos-automount.sh | ||
+++ b/usr/lib/hwsupport/steamos-automount.sh | ||
@@ -22,8 +22,12 @@ fi | ||
ACTION=$1 | ||
DEVBASE=$2 | ||
DEVICE="/dev/${DEVBASE}" | ||
-DECK_UID=$(id -u deck) | ||
-DECK_GID=$(id -g deck) | ||
+# Jovian Experiments assumptions: | ||
+# - UID for Steam user is 1000 | ||
+# - Username is unknown | ||
+DECK_UID=1000 | ||
+DECK_GID=$(id -g "$DECK_UID") | ||
+DECK_USERNAME=$(id -nu "$DECK_UID") | ||
|
||
send_steam_url() | ||
{ | ||
@@ -90,7 +94,7 @@ do_mount() | ||
"block_devices/${DEVBASE}" \ | ||
Filesystem Mount \ | ||
'a{sv}' 3 \ | ||
- as-user s deck \ | ||
+ as-user s "$DECK_USERNAME" \ | ||
auth.no_user_interaction b true \ | ||
options s "$OPTS") | ||
|
||
-- | ||
2.46.0 | ||
|
30 changes: 30 additions & 0 deletions
30
pkgs/jupiter-hw-support/0001-format-device-Harden-against-mountpoint-being-listed.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From eee1d1e1f8e6d7a2246e3428d71522e02b04c5d7 Mon Sep 17 00:00:00 2001 | ||
From: Samuel Dionne-Riel <[email protected]> | ||
Date: Sun, 29 Sep 2024 21:45:49 -0400 | ||
Subject: [PATCH] format-device: Harden against mountpoint being listed more | ||
than once | ||
|
||
This can happen with some combination of bind mounts magic, where the | ||
mount point may appear at more than one location at a time. | ||
|
||
Signed-off-by: Samuel Dionne-Riel <[email protected]> | ||
--- | ||
usr/lib/hwsupport/format-device.sh | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/usr/lib/hwsupport/format-device.sh b/usr/lib/hwsupport/format-device.sh | ||
index 65d77f8..0400ae8 100755 | ||
--- a/usr/lib/hwsupport/format-device.sh | ||
+++ b/usr/lib/hwsupport/format-device.sh | ||
@@ -77,6 +77,8 @@ fi | ||
# If any partitions on the device are mounted, unmount them before continuing | ||
# to prevent problems later | ||
lsblk -n "$STORAGE_DEVICE" -o MOUNTPOINTS | awk NF | sort -u | while read m; do | ||
+ # Check the mountpoint still exists, in case the mount point is reported more than once. | ||
+ test -e "$m" || continue | ||
if ! umount "$m"; then | ||
echo "Failed to unmount filesystem: $m" | ||
exit 32 # EPIPE | ||
-- | ||
2.46.0 | ||
|
36 changes: 36 additions & 0 deletions
36
pkgs/jupiter-hw-support/0001-steamos-automount-Harden-against-missing-run-media.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From 55674111fe7956adb41c2b8d0c6fbb3c3d6ca8bf Mon Sep 17 00:00:00 2001 | ||
From: Samuel Dionne-Riel <[email protected]> | ||
Date: Sun, 29 Sep 2024 02:36:41 -0400 | ||
Subject: [PATCH] steamos-automount: Harden against missing /run/media | ||
|
||
When running against some systems, it is possible `/run/media` does not | ||
exist when trying to unmount a path. E.g. with `UDISKS_FILESYSTEM_SHARED`. | ||
|
||
Signed-off-by: Samuel Dionne-Riel <[email protected]> | ||
--- | ||
usr/lib/hwsupport/steamos-automount.sh | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/usr/lib/hwsupport/steamos-automount.sh b/usr/lib/hwsupport/steamos-automount.sh | ||
index 8583ca7..0b0457f 100755 | ||
--- a/usr/lib/hwsupport/steamos-automount.sh | ||
+++ b/usr/lib/hwsupport/steamos-automount.sh | ||
@@ -107,6 +107,7 @@ do_mount() | ||
# that use the older mount point (for SD cards only). | ||
case "${DEVBASE}" in | ||
mmcblk0p*) | ||
+ mkdir -p /run/media | ||
if [[ -z "${ID_FS_LABEL}" ]]; then | ||
old_mount_point="/run/media/${DEVBASE}" | ||
else | ||
@@ -124,6 +125,7 @@ do_mount() | ||
|
||
do_unmount() | ||
{ | ||
+ mkdir -p /run/media | ||
local mount_point=$(findmnt -fno TARGET "${DEVICE}" || true) | ||
if [[ -n $mount_point ]]; then | ||
# Remove symlink to the mount point that we're unmounting | ||
-- | ||
2.46.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(note) this one was previously within
./jovian.patch
too.