From 4ebf259d11930774b3a13b370b955a8765bfcae6 Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Thu, 9 Jul 2020 00:05:24 -0600 Subject: [PATCH] modules#steam: create xsession for Steam --- modules/list.nix | 1 + .../services/x11/window-managers/steam.nix | 45 +++++++++++++++++++ .../window-managers/steamcompmgr/default.nix | 34 ++++++++++++++ pkgs/default.nix | 2 + profiles/games/default.nix | 7 ++- 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 modules/services/x11/window-managers/steam.nix create mode 100644 pkgs/applications/window-managers/steamcompmgr/default.nix diff --git a/modules/list.nix b/modules/list.nix index f517734..6ee0e37 100644 --- a/modules/list.nix +++ b/modules/list.nix @@ -3,4 +3,5 @@ ./security/mitigations.nix ./services/hardware/wii-u-gc-adapter.nix ./services/games/gamemode.nix + ./services/x11/window-managers/steam.nix ] diff --git a/modules/services/x11/window-managers/steam.nix b/modules/services/x11/window-managers/steam.nix new file mode 100644 index 0000000..948a680 --- /dev/null +++ b/modules/services/x11/window-managers/steam.nix @@ -0,0 +1,45 @@ +{ pkgs, lib, config, ... }: + +with lib; + +let cfg = config.services.xserver.windowManager.steam; +in { + options = { + services.xserver.windowManager.steam = { + enable = mkEnableOption "steam"; + package = mkOption { + type = lib.types.package; + default = pkgs.steam; + description = '' + The Steam package to use. + ''; + }; + extraSessionCommands = mkOption { + type = lib.types.str; + default = ""; + description = '' + Shell commands executed just before Steam is started. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ cfg.package ]; + + services.xserver.windowManager.session = [{ + name = "steam"; + start = '' + ${cfg.extraSessionCommands} + + # needed to ensure conflicting compositors are not running + ${pkgs.systemd}/bin/systemctl --user stop graphical-session.target + + ${pkgs.xorg.xset}/bin/xset -dpms + ${pkgs.xorg.xset}/bin/xset s off + ${pkgs.steamcompmgr}/bin/steamcompmgr & + steam -tenfoot -fulldesktopres + ''; + }]; + }; +} diff --git a/pkgs/applications/window-managers/steamcompmgr/default.nix b/pkgs/applications/window-managers/steamcompmgr/default.nix new file mode 100644 index 0000000..67b1462 --- /dev/null +++ b/pkgs/applications/window-managers/steamcompmgr/default.nix @@ -0,0 +1,34 @@ +{ stdenv, fetchFromGitHub, libudev, SDL, SDL_image, libXdamage, libXcomposite +, libXrender, libXext, libXxf86vm, pkgconfig, autoreconfHook, gnumake }: + +stdenv.mkDerivation { + name = "steamcompmgr"; + src = fetchFromGitHub { + owner = "gamer-os"; + repo = "steamos-compositor-plus"; + rev = "c3855fcb5015ecdca299ee4b46b9f90c7a6788de"; + hash = "sha256-sRthjN+pnabl67PuJS+zbUznW4ws0fub0R9bTzelg18="; + }; + + buildInputs = [ + libudev + SDL + SDL_image + libXdamage + libXcomposite + libXrender + libXext + libXxf86vm + pkgconfig + autoreconfHook + gnumake + ]; + + meta = with stdenv.lib; { + description = "SteamOS Compositor"; + homepage = "https://github.com/steamos-compositor-plus"; + maintainers = [ maintainers.nrdxp ]; + license = licenses.bsd2; + inherit version; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 4bc8911..f2fdbdd 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -7,4 +7,6 @@ final: prev: { wii-u-gc-adapter = prev.callPackage ./misc/drivers/wii-u-gc-adapter { }; libinih = prev.callPackage ./development/libraries/libinih { }; gamemode = prev.callPackage ./os-specific/linux/gamemode { }; + steamcompmgr = + prev.callPackage ./applications/window-managers/steamcompmgr { }; } diff --git a/profiles/games/default.nix b/profiles/games/default.nix index faaa272..a364e04 100644 --- a/profiles/games/default.nix +++ b/profiles/games/default.nix @@ -2,7 +2,6 @@ imports = [ ../graphical ./udev.nix ]; environment.systemPackages = with unstablePkgs; [ retroarchBare - steam steam-run pcsx2 qjoypad @@ -15,6 +14,12 @@ # fps games on laptop need this services.xserver.libinput.disableWhileTyping = false; + # Launch steam from display managers + services.xserver.windowManager.steam = { + enable = true; + package = unstablePkgs.steam; + }; + # 32-bit support needed for steam hardware.opengl.driSupport32Bit = true; hardware.pulseaudio.support32Bit = true;