nixos-config/nixos/modules/programs/steam.nix
2023-07-02 20:56:42 +02:00

51 lines
1 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
# steam
# -------
# Don't forget to run 'xhost +' with your user
# to make sure the browser user can write to X
let
bin = pkgs.writeShellScriptBin "steam" ''
/var/run/wrappers/bin/sudo -u steam -i ${pkgs.steam}/bin/steam $@
'';
cfg = config.programs.custom.steam;
in
{
options.programs.custom.steam.enable = mkEnableOption "enable steam";
config = mkIf cfg.enable {
environment.systemPackages = [
bin
pkgs.xorg.xhost
# to use xbox controllers
pkgs.xboxdrv
];
users.users.steam = {
isNormalUser = false;
isSystemUser = true;
home = "/home/steam";
createHome = true;
extraGroups = [ "audio" "input" "video" "pipewire" ];
group = "steam";
};
users.groups.steam = { };
# for steam
# ---------
hardware.opengl.driSupport = true;
hardware.opengl.driSupport32Bit = true;
security.sudo.extraConfig = ''
${config.users.extraUsers.mainUser.name} ALL=(steam) NOPASSWD: ALL
'';
};
}