many changes

This commit is contained in:
2025-01-26 10:55:38 +01:00
parent 12ef36af33
commit a2d482e16d
98 changed files with 419 additions and 27402 deletions

1
hosts/gpd-win4/modules/nvim Symbolic link
View File

@@ -0,0 +1 @@
../../nb/modules/nvim

View File

@@ -0,0 +1,129 @@
{ config, lib, pkgs, ... }:
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
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 = ''
#!/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
'';
#### 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";
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"
];
};
#### 2) Create two systemd *user* services:
#### - steam-deck-mode: On stop, automatically start sway
#### - sway: On stop, automatically start steam-deck-mode
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
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
};
};
systemd.user.services."sway" = {
description = "Sway WM Session";
wantedBy = [ ]; # We won't start this on login by default, but from steam or a script
serviceConfig = {
Type = "simple";
ExecStart = "/etc/sway-session.sh";
# On exit, automatically trigger Steam Deck Mode
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).
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
'';
systemd.services."make-switch-to-game-mode-executable" = {
description = "Make switch-to-game-mode.sh executable";
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = [
"${pkgs.coreutils}/bin/chmod +x /etc/switch-to-game-mode.sh"
];
};
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)
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.
#### 5) Additional recommended gaming packages if not set elsewhere:
environment.systemPackages = with pkgs; [
steam
gamemode
mangohud
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"
'';
}

View File

@@ -0,0 +1,80 @@
{ config, lib, pkgs, ... }:
let
# For GPD Win4s AMD APU, we assume AMD Vulkan drivers:
amdPackages = [
pkgs.amdvlk
pkgs.driversi686Linux.amdvlk
];
in
{
options.services.steamDeckMode = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Launch Steam in a Deck-like session upon login (auto-logins and starts Steam in gamepad UI mode).";
};
};
config = {
# Enable Steam and Gamescope
programs.gamescope = {
enable = true;
capSysNice = true;
};
programs.steam = {
enable = true;
# The gamescopeSession creates a special session for Steam on Wayland
gamescopeSession.enable = true;
};
# Add some helpful gaming utilities
environment.systemPackages = with pkgs; [
mangohud
steam-tui
steamcmd
vulkan-tools
vulkan-headers
vulkan-loader
wlroots
libdecor
gamemode
];
# Enable 32-bit support for libraries (often required by Steam)
hardware.opengl.enable = true;
hardware.opengl.driSupport32Bit = true;
# Additional AMD drivers if needed
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
hardware.graphics.extraPackages = amdPackages;
# Example udev rules for Steam Deck controllers, optional
environment.etc."udev/rules.d/99-steamdeck-controller.rules".text = ''
# Valve Controller devices
SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666"
KERNEL=="uinput", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"
'';
# Provide a “Steam Deck Mode” session in the display manager
services.xserver.displayManager.session = {
"steam-deck-mode" = {
name = "Steam Deck Mode";
start = ''
#!/usr/bin/env bash
# On X11, you could also remove or adjust the following env variable if you prefer Wayland
export XDG_SESSION_TYPE=x11
# Fullscreen + close gamescope on exit, then run Steam in gamepad UI
exec gamescope -f -e -- steam -gamepadui
'';
};
};
}
// lib.mkIf config.services.steamDeckMode.enable {
# Auto-login to the user of your choice and start in Steam Deck Mode
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "dominik"; # or your preferred user
services.xserver.autoRestartXServer = true;
services.xserver.displayManager.defaultSession = "steam-deck-mode";
};

1
hosts/gpd-win4/modules/sway Symbolic link
View File

@@ -0,0 +1 @@
../../nb/modules/sway