1 { config, lib, pkgs, ... }:
6 cfg = config.programs.steam;
8 steam = pkgs.steam.override {
9 extraLibraries = pkgs: with config.hardware.opengl;
10 if pkgs.hostPlatform.is64bit
11 then [ package ] ++ extraPackages
12 else [ package32 ] ++ extraPackages32;
15 options.programs.steam = {
16 enable = mkEnableOption (lib.mdDoc "steam");
18 remotePlay.openFirewall = mkOption {
21 description = lib.mdDoc ''
22 Open ports in the firewall for Steam Remote Play.
26 dedicatedServer.openFirewall = mkOption {
29 description = lib.mdDoc ''
30 Open ports in the firewall for Source Dedicated Server.
35 config = mkIf cfg.enable {
36 hardware.opengl = { # this fixes the "glXChooseVisual failed" bug, context: https://github.com/NixOS/nixpkgs/issues/47932
39 driSupport32Bit = true;
42 # optionally enable 32bit pulseaudio support if pulseaudio is enabled
43 hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable;
45 hardware.steam-hardware.enable = true;
47 environment.systemPackages = [ steam steam.run ];
49 networking.firewall = lib.mkMerge [
50 (mkIf cfg.remotePlay.openFirewall {
51 allowedTCPPorts = [ 27036 ];
52 allowedUDPPortRanges = [ { from = 27031; to = 27036; } ];
55 (mkIf cfg.dedicatedServer.openFirewall {
56 allowedTCPPorts = [ 27015 ]; # SRCDS Rcon port
57 allowedUDPPorts = [ 27015 ]; # Gameplay traffic
62 meta.maintainers = with maintainers; [ mkg20001 ];