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

View File

@@ -0,0 +1,44 @@
{ config, lib, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
./sway/sway.nix
./nvim/default.nix
./utils/bento.nix
./utils/modules/sops.nix
./utils/modules/nur.nix
./utils/modules/autoupgrade.nix
./users
# Import our new steam-deck-mode module
./modules/steam-deck-mode.nix
];
networking.hostName = "gpd-win4";
time.timeZone = "Europe/Vienna";
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowBroken = true;
console.keyMap = "de";
services.openssh.enable = true;
security.polkit.enable = true;
networking.networkmanager.enable = true;
users.users.dominik = {
isNormalUser = true;
hashedPassword = ""; # Replace with real hash
extraGroups = [ "wheel" "video" "audio" "input" ];
};
powerManagement.cpuFreqGovernor = "powersave";
# In case you want a persistent /home or other directories:
# environment.persistence."/nix/persist" = {
# hideMounts = true;
# directories = [ "/home" ];
# };
# This system tries to unify the "Steam Deck Mode" and "Sway" approach
# with toggling via systemd user services.
system.stateVersion = "24.05";
}

View File

@@ -0,0 +1,50 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.kernelModules = [ "amdgpu" "kvm-amd" ];
hardware.cpu.amd.updateMicrocode = lib.mkDefault true;
fileSystems."/" =
{
device = "none";
fsType = "tmpfs";
options = [ "size=16G" "mode=755" ];
};
fileSystems."/nix" =
{
device = "/dev/disk/by-uuid/856e1ebe-832f-422d-8d91-d43a5d852abb";
fsType = "f2fs";
};
boot.initrd = {
luks.devices."enc" = {
crypttabExtraOpts = [ "fido2-device=auto" ];
device = "/dev/disk/by-uuid/08897ecb-23ce-4352-a1fc-fa442b9e0f72";
};
systemd.enable = true;
};
fileSystems."/boot" =
{
device = "/dev/disk/by-uuid/1521-B173";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
hardware.graphics = {
enable = true;
extraPackages = with pkgs; [
vaapiVdpau
libvdpau-va-gl
libva
libva-utils
];
};
}

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

1
hosts/gpd-win4/users Symbolic link
View File

@@ -0,0 +1 @@
../nb/users

1
hosts/gpd-win4/utils Symbolic link
View File

@@ -0,0 +1 @@
../../utils