-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anthony Rabbito <[email protected]>
- Loading branch information
Showing
9 changed files
with
340 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
{ config, lib, pkgs, inputs, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkDefault | ||
mkIf | ||
mkMerge | ||
mkOption | ||
types | ||
; | ||
cfg = config.snowflake.steam; | ||
in | ||
{ | ||
options = { | ||
snowflake = { | ||
steam = { | ||
autoStart = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = lib.mdDoc '' | ||
Whether to automatically launch the Steam Deck UI on boot. | ||
Traditional Display Managers cannot be enabled in conjunction with this option. | ||
''; | ||
}; | ||
|
||
user = mkOption { | ||
type = types.str; | ||
description = lib.mdDoc '' | ||
The user to run Steam with. | ||
''; | ||
}; | ||
|
||
desktopSession = mkOption { | ||
type = with types ; nullOr str // { | ||
check = userProvidedDesktopSession: | ||
lib.assertMsg (userProvidedDesktopSession != null -> (str.check userProvidedDesktopSession && lib.elem userProvidedDesktopSession config.services.xserver.displayManager.sessionData.sessionNames)) '' | ||
Desktop session '${userProvidedDesktopSession}' not found. | ||
Valid values for 'snowflake.steam.desktopSession' are: | ||
${lib.concatStringsSep "\n " config.services.xserver.displayManager.sessionData.sessionNames} | ||
If you don't want a desktop session to switch to, set 'snowflake.steam.desktopSession' to 'gamescope-wayland'. | ||
''; | ||
}; | ||
default = null; | ||
example = "plasma"; | ||
description = lib.mdDoc '' | ||
The session to launch for Desktop Mode. | ||
By default, attempting to switch to the desktop will launch Gaming Mode again. | ||
''; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable (mkMerge [ | ||
(mkIf cfg.autoStart { | ||
assertions = [ | ||
{ | ||
assertion = !config.systemd.services.display-manager.enable; | ||
message = '' | ||
Traditional Display Managers cannot be enabled when snowflake.steam.autoStart is used | ||
Hint: check `services.xserver.displaymanager.*.enable` options in your configuration. | ||
''; | ||
} | ||
]; | ||
|
||
warnings = lib.optional (cfg.desktopSession == null) '' | ||
snowflake.steam.desktopSession is unset. | ||
This means that using the Switch to Desktop function in Gaming Mode will | ||
relaunch Gaming Mode. | ||
Set snowflake.steam.desktopSession to the name of a desktop session, or "gamescope-wayland" | ||
to keep this behavior. | ||
''; | ||
|
||
services.xserver = { | ||
enable = true; | ||
displayManager.lightdm.enable = false; | ||
displayManager.startx.enable = true; | ||
}; | ||
|
||
systemd.user.services.gamescope-session = { | ||
overrideStrategy = "asDropin"; | ||
|
||
environment = mkMerge ( | ||
[ | ||
{ | ||
JOVIAN_DESKTOP_SESSION = cfg.desktopSession; | ||
PATH = lib.mkForce null; | ||
} | ||
] | ||
# Add any globally defined well-known XKB_DEFAULT environment variables to the session | ||
# This is the closest wayland sessions have to generic keyboard configurations. | ||
++ (map (var: | ||
(mkIf (config.environment.variables ? "${var}") { | ||
"${var}" = mkDefault config.environment.variables."${var}"; | ||
}) | ||
) [ | ||
"XKB_DEFAULT_LAYOUT" | ||
"XKB_DEFAULT_OPTIONS" | ||
"XKB_DEFAULT_MODEL" | ||
"XKB_DEFAULT_RULES" | ||
"XKB_DEFAULT_VARIANT" | ||
] | ||
) | ||
); | ||
|
||
# upstream unit redirects to a file, but this seems unnecessary now? | ||
# see https://github.com/Jovian-Experiments/PKGBUILDs-mirror/blob/76aa4a564094dc656aa1b1daa0f116a7b93b0d7b/gamescope-session.service#L10 | ||
serviceConfig = { | ||
StandardOutput = "journal"; | ||
StandardError = "journal"; | ||
}; | ||
}; | ||
|
||
services.greetd = { | ||
enable = true; | ||
settings = { | ||
default_session = { | ||
user = "jovian-greeter"; | ||
command = "${inputs.jovian-nixos.legacyPackages.${pkgs.system}.jovian-greeter}/bin/jovian-greeter ${cfg.user}"; | ||
}; | ||
}; | ||
}; | ||
|
||
users.users.jovian-greeter = { | ||
isSystemUser = true; | ||
group = "jovian-greeter"; | ||
}; | ||
users.groups.jovian-greeter = {}; | ||
|
||
security.pam.services = { | ||
greetd.text = '' | ||
auth requisite pam_nologin.so | ||
auth sufficient pam_succeed_if.so user = ${cfg.user} quiet_success | ||
auth required pam_unix.so | ||
account sufficient pam_unix.so | ||
password required pam_deny.so | ||
session optional pam_keyinit.so revoke | ||
session include login | ||
''; | ||
}; | ||
|
||
environment = { | ||
systemPackages = [ inputs.jovian-nixos.legacyPackages.${pkgs.system}.jovian-greeter.helper ]; | ||
pathsToLink = [ "lib/jovian-greeter" ]; | ||
}; | ||
security.polkit.extraConfig = '' | ||
polkit.addRule(function(action, subject) { | ||
if ( | ||
action.id == "org.freedesktop.policykit.exec" && | ||
action.lookup("program") == "/run/current-system/sw/lib/jovian-greeter/consume-session" && | ||
subject.user == "jovian-greeter" | ||
) { | ||
return polkit.Result.YES; | ||
} | ||
}); | ||
''; | ||
|
||
xdg.portal.configPackages = mkDefault [ inputs.jovian-nixos.legacyPackages.${pkgs.system}.gamescope-session ]; | ||
}) | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ lib, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkOption | ||
types | ||
; | ||
in | ||
{ | ||
imports = [ | ||
./steam.nix | ||
./autostart.nix | ||
./environment.nix | ||
]; | ||
options = { | ||
snowflake = { | ||
steam = { | ||
enable = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = lib.mdDoc '' | ||
Whether to enable the Steam Deck UI. | ||
When enabled, you can either use the `autoStart` option (preferred), | ||
launch the Steam Deck UI from your Display Manager or | ||
by running `start-gamescope-session`. | ||
''; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
inherit (lib) | ||
concatStringsSep | ||
escapeShellArg | ||
mapAttrsToList | ||
mkIf | ||
mkMerge | ||
mkOption | ||
types | ||
; | ||
|
||
cfg = config.snowflake.steam; | ||
in | ||
{ | ||
options = { | ||
snowflake.steam = { | ||
environment = mkOption { | ||
type = with types; attrsOf str; | ||
default = {}; | ||
description = '' | ||
Additional environment variables or overrides to environment variables | ||
that will be applied to the gamescope session. | ||
''; | ||
}; | ||
}; | ||
}; | ||
config = mkIf cfg.enable (mkMerge [ | ||
{ | ||
environment.etc."xdg/gamescope-session/environment" = { | ||
text = concatStringsSep "\n" ( | ||
mapAttrsToList ( | ||
key: value: | ||
"export ${escapeShellArg key}=${escapeShellArg value}" | ||
) cfg.environment | ||
); | ||
}; | ||
} | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ config, inputs, lib, pkgs, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkDefault | ||
mkIf | ||
mkMerge | ||
; | ||
|
||
cfg = config.snowflake.steam; | ||
in | ||
{ | ||
config = mkIf cfg.enable (mkMerge [ | ||
{ | ||
warnings = [] | ||
++ lib.optional (!config.networking.networkmanager.enable) | ||
"The Steam Deck UI integrates with NetworkManager (networking.networkmanager.enable) which is not enabled. NetworkManager is required to complete the first-time setup process."; | ||
} | ||
{ | ||
security.wrappers.gamescope = { | ||
owner = "root"; | ||
group = "root"; | ||
source = "${pkgs.gamescope_git}/bin/gamescope"; | ||
capabilities = "cap_sys_nice+pie"; | ||
}; | ||
|
||
security.wrappers.galileo-mura-extractor = { | ||
owner = "root"; | ||
group = "root"; | ||
source = "${inputs.jovian-nixos.legacyPackages.${pkgs.system}.galileo-mura}/bin/galileo-mura-extractor"; | ||
setuid = true; | ||
}; | ||
} | ||
{ | ||
# Enable MTU probing, as vendor does | ||
# See: https://github.com/ValveSoftware/SteamOS/issues/1006 | ||
# See also: https://www.reddit.com/r/SteamDeck/comments/ymqvbz/ubisoft_connect_connection_lost_stuck/j36kk4w/?context=3 | ||
boot.kernel.sysctl."net.ipv4.tcp_mtu_probing" = true; | ||
|
||
hardware.opengl = { | ||
driSupport32Bit = true; | ||
extraPackages = [ pkgs.gamescope-wsi_git ]; | ||
extraPackages32 = [ pkgs.pkgsi686Linux.gamescope-wsi_git ]; | ||
}; | ||
|
||
hardware.pulseaudio.support32Bit = true; | ||
hardware.steam-hardware.enable = mkDefault true; | ||
|
||
environment.systemPackages = [ inputs.jovian-nixos.legacyPackages.${pkgs.system}.gamescope-session inputs.jovian-nixos.legacyPackages.${pkgs.system}.steamos-polkit-helpers ]; | ||
|
||
systemd.packages = [ inputs.jovian-nixos.legacyPackages.${pkgs.system}.gamescope-session ]; | ||
|
||
services.xserver.displayManager.sessionPackages = [ inputs.jovian-nixos.legacyPackages.${pkgs.system}.gamescope-session ]; | ||
|
||
# Conflicts with powerbuttond | ||
services.logind.extraConfig = '' | ||
HandlePowerKey=ignore | ||
''; | ||
|
||
services.udev.packages = [ | ||
inputs.jovian-nixos.legacyPackages.${pkgs.system}.powerbuttond | ||
]; | ||
|
||
# This rule allows the user to configure Wi-Fi in Deck UI. | ||
# | ||
# Steam modifies the system network configs via | ||
# `org.freedesktop.NetworkManager.settings.modify.system`, | ||
# which normally requires being in the `networkmanager` group. | ||
security.polkit.extraConfig = '' | ||
// snowflake-NixOS/steam: Allow users to configure Wi-Fi in Deck UI | ||
polkit.addRule(function(action, subject) { | ||
if ( | ||
action.id.indexOf("org.freedesktop.NetworkManager") == 0 && | ||
subject.isInGroup("users") && | ||
subject.local && | ||
subject.active | ||
) { | ||
return polkit.Result.YES; | ||
} | ||
}); | ||
''; | ||
|
||
snowflake.steam.environment = { | ||
# We don't support adopting a drive, yet. | ||
STEAM_ALLOW_DRIVE_ADOPT = mkDefault "0"; | ||
# Ejecting doesn't work, either. | ||
STEAM_ALLOW_DRIVE_UNMOUNT = mkDefault "0"; | ||
}; | ||
} | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.