Skip to content

Commit

Permalink
steam-jupiter: add stubs and polkit-helpers (latter currently disabled)
Browse files Browse the repository at this point in the history
  • Loading branch information
K900 committed Sep 23, 2023
1 parent 9e47897 commit 241fd5f
Showing 1 changed file with 14 additions and 45 deletions.
59 changes: 14 additions & 45 deletions pkgs/steam-jupiter/fhsenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,18 @@
{ lib
, runCommand
, writeShellScriptBin
, dmidecode
, jovian-stubs
, steam-fhsenv
, steamos-polkit-helpers
, ...
} @ args:

let
extraArgs = builtins.removeAttrs args [ "lib" "runCommand" "writeShellScriptBin" "steam-fhsenv" ];

# The sudo wrapper doesn't work in FHS environments. For our purposes
# we add a passthrough sudo command that does not actually escalate
# privileges.
#
# <https://github.com/NixOS/nixpkgs/issues/42117>
passthroughSudo = writeShellScriptBin "sudo" ''
declare -a final
positional=""
for value in "$@"; do
if [[ -n "$positional" ]]; then
final+=("$value")
elif [[ "$value" == "-n" ]]; then
:
else
positional="y"
final+=("$value")
fi
done
exec "''${final[@]}"
'';

# Null SteamOS updater that does nothing
#
# This gets us past the OS update step in the OOBE wizard.
nullOsUpdater = writeShellScriptBin "steamos-update" ''
>&2 echo "steamos-update: Not supported on NixOS - Doing nothing"
exit 7;
'';

# Null Steam Deck BIOS updater that does nothing
nullBiosUpdater = writeShellScriptBin "jupiter-biosupdate" ''
>&2 echo "jupiter-biosupdate: Doing nothing"
'';
extraArgs = builtins.removeAttrs args [
"lib" "runCommand" "writeShellScriptBin"
"dmidecode" "jovian-stubs" "steam-fhsenv" "steamos-polkit-helpers"
];

# A very simplistic "session switcher." All it does is kill gamescope.
sessionSwitcher = writeShellScriptBin "steamos-session-select" ''
Expand All @@ -67,21 +37,20 @@ let
mkdir -p ~/.local/state
>~/.local/state/steamos-session-select echo "$session"
if [[ -n "$gamescope_pid" ]]; then
kill "$gamescope_pid"
else
>&2 echo "!! Don't know how to kill gamescope"
exit 1
fi
systemctl stop --user gamescope-session
'';

wrappedSteam = steam-fhsenv.override (extraArgs // {
extraPkgs = pkgs: (if args ? extraPkgs then args.extraPkgs pkgs else []) ++ [
nullOsUpdater nullBiosUpdater
dmidecode
jovian-stubs
sessionSwitcher

# FIXME: figure out how to fix pkexec and readd this
# steamos-polkit-helpers
];
extraProfile = (args.extraProfile or "") + ''
export PATH=${passthroughSudo}/bin:$PATH
export PATH=${jovian-stubs}/bin:$PATH
'';

# We need to add this flag when Steam is started directly (e.g., desktop mode)
Expand Down

0 comments on commit 241fd5f

Please sign in to comment.