-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules/steam: Split steam itself from autostart infra
The file was getting *wayyy* too unwieldy. There is still more to do to make it more palatable, but this is a start.
- Loading branch information
Showing
3 changed files
with
604 additions
and
563 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkIf | ||
mkMerge | ||
mkOption | ||
types | ||
; | ||
cfg = config.jovian.steam; | ||
in | ||
{ | ||
options = { | ||
jovian = { | ||
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 = types.nullOr types.str; | ||
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 jovian.steam.autoStart is used | ||
Hint: check `services.xserver.displaymanager.*.enable` options in your configuration. | ||
''; | ||
} | ||
]; | ||
|
||
warnings = lib.optional (cfg.desktopSession == null) '' | ||
jovian.steam.desktopSession is unset. | ||
This means that using the Switch to Desktop function in Gaming Mode will | ||
relaunch Gaming Mode. | ||
Set jovian.steam.desktopSession to the name of a desktop session, or "steam-wayland" | ||
to keep this behavior. | ||
''; | ||
|
||
services.xserver = { | ||
enable = true; | ||
displayManager.lightdm.enable = false; | ||
displayManager.startx.enable = true; | ||
}; | ||
|
||
jovian.steam.environment = { | ||
JOVIAN_DESKTOP_SESSION = if cfg.desktopSession != null then cfg.desktopSession else "steam-wayland"; | ||
}; | ||
|
||
services.greetd = { | ||
enable = true; | ||
settings = { | ||
default_session = let | ||
in { | ||
user = "jovian-greeter"; | ||
command = "${pkgs.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 = [ pkgs.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; | ||
} | ||
}); | ||
''; | ||
}) | ||
]); | ||
} |
Oops, something went wrong.