many changes

This commit is contained in:
2025-02-23 16:00:33 +01:00
parent e2add63337
commit 386b70314d
29 changed files with 1840 additions and 423 deletions

View File

@@ -2,77 +2,59 @@
let
cfgUser = "dominik"; # Adjust to your username
in {
#### 1) Provide two scripts:
#### - `steam-deck-mode.sh`: Runs Steam Big Picture with Gamescope (Wayland).
#### - `sway-session.sh`: Starts Sway.
environment.etc."steam-deck-mode.sh".text = ''
#!/usr/bin/env bash
# This script launches Steam in Big Picture mode under Gamescope (Wayland).
# Once Steam (or Gamescope) exits, the systemd user service stops.
# The ExecStopPost hook in the user service will then start Sway automatically.
# For safety, kill any existing Steam instance
# Launches Steam in Big Picture with Gamescope.
# On exit, user service stops, triggering ExecStopPost to start GNOME.
pgrep steam && steam -shutdown || true
sleep 1
# Use Gamescope in fullscreen mode, exit on Steam exit, run Steam in Gamepad UI
exec gamescope -W 1280 -H 800 -f -e -- steam -gamepadui
'';
environment.etc."sway-session.sh".text = ''
environment.etc."gnome-session.sh".text = ''
#!/usr/bin/env bash
# This script starts a Sway session. When Sway exits, the user service stops,
# which triggers ExecStopPost to start Steam Big Picture again.
exec sway
# Start a GNOME session
exec gnome-session
'';
#### Make these scripts executable via a simple systemd service:
systemd.services."make-scripts-executable" = {
description = "Make steam-deck-mode.sh and sway-session.sh executable";
description = "Make steam-deck-mode and gnome-session scripts executable";
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = [
"${pkgs.coreutils}/bin/chmod +x /etc/steam-deck-mode.sh"
"${pkgs.coreutils}/bin/chmod +x /etc/sway-session.sh"
"${pkgs.coreutils}/bin/chmod +x /etc/gnome-session.sh"
];
};
#### 2) Create two systemd *user* services:
#### - steam-deck-mode: On stop, automatically start sway
#### - sway: On stop, automatically start steam-deck-mode
# Steam Deck Mode service
systemd.user.services."steam-deck-mode" = {
description = "Steam Deck Mode (Wayland Gamescope + Steam Big Picture)";
wantedBy = [ "default.target" ]; # So we can enable it for the user
description = "Steam Deck Mode (Gamescope + Steam Big Picture)";
wantedBy = [ "default.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "/etc/steam-deck-mode.sh";
# On exit, automatically trigger Sway
ExecStopPost = "${pkgs.systemd}/bin/systemctl --user start sway";
Restart = "no"; # If Steam crashes, you can change to 'on-failure' if desired
ExecStopPost = "${pkgs.systemd}/bin/systemctl --user start gnome-session";
Restart = "no";
};
};
systemd.user.services."sway" = {
description = "Sway WM Session";
wantedBy = [ ]; # We won't start this on login by default, but from steam or a script
# GNOME Session (Wayland) service
systemd.user.services."gnome-session" = {
description = "GNOME Session (Wayland)";
wantedBy = [ ];
serviceConfig = {
Type = "simple";
ExecStart = "/etc/sway-session.sh";
# On exit, automatically trigger Steam Deck Mode
ExecStart = "/etc/gnome-session.sh";
ExecStopPost = "${pkgs.systemd}/bin/systemctl --user start steam-deck-mode";
Restart = "no";
};
};
#### 3) Provide a script & desktop entry to let you switch from Sway to Game Mode easily
#### (i.e., stop the 'sway' service, which triggers Steam).
# Quick script to switch from GNOME to Steam Big Picture
environment.etc."switch-to-game-mode.sh".text = ''
#!/usr/bin/env bash
# This script stops Sway, causing the user service to exit
# The ExecStopPost of that service will start steam-deck-mode automatically.
${pkgs.systemd}/bin/systemctl --user stop sway
# Stop GNOME => triggers Steam in ExecStopPost
${pkgs.systemd}/bin/systemctl --user stop gnome-session
'';
systemd.services."make-switch-to-game-mode-executable" = {
@@ -86,21 +68,24 @@ in {
environment.etc."xdg/applications/switch-to-game-mode.desktop".text = ''
[Desktop Entry]
Name=Switch to Game Mode
Comment=Stop Sway and start Steam Big Picture (Gamescope)
Comment=Stop GNOME and start Steam (Gamescope)
Exec=/etc/switch-to-game-mode.sh
Terminal=false
Type=Application
Categories=Game;
'';
#### 4) If you want to start directly in Steam Deck Mode on boot (no display manager),
#### enable auto-login on TTY and run the user service for "dominik".
#### For example (uncomment if you want an immediate console login):
# services.getty.autologinUser = cfgUser;
# systemd.user.services."steam-deck-mode".wantedBy = [ "default.target" ]; # already set
# You'd do 'systemctl --user enable steam-deck-mode' as that user to start it on login.
# Update to new hardware.graphics.* options
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
#### 5) Additional recommended gaming packages if not set elsewhere:
# Include AMD Vulkan for 64bit & 32bit
hardware.graphics.extraPackages = [
pkgs.amdvlk
pkgs.driversi686Linux.amdvlk
];
# A recommended set of gaming packages
environment.systemPackages = with pkgs; [
steam
gamemode
@@ -108,22 +93,11 @@ in {
vulkan-tools
vulkan-loader
vulkan-headers
# ...
];
#### 6) Enable 32-bit support for Steam
hardware.opengl.enable = true;
hardware.opengl.driSupport32Bit = true;
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
hardware.graphics.extraPackages = [
pkgs.amdvlk
pkgs.driversi686Linux.amdvlk
];
#### 7) Optionally handle udev rules for Steam/Controllers if needed
environment.etc."udev/rules.d/99-steamdeck-controller.rules".text = ''
SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666"
KERNEL=="uinput", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"
'';
# Move the Steam Deck controller rules to services.udev.extraRules
# services.udev.extraRules = ''
# SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666"
# KERNEL=="uinput", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"
# '';
}