From e7f02c057e13b5b11aa388c256c4a7d469ce9a1d Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 23 Apr 2023 23:21:08 +0000 Subject: [PATCH] steam: integrate into sane.programs, and enable for lappy --- hosts/common/programs.nix | 18 ++++++++++++++++-- modules/programs.nix | 13 +++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/hosts/common/programs.nix b/hosts/common/programs.nix index 8e800f6d..c9dfbb23 100644 --- a/hosts/common/programs.nix +++ b/hosts/common/programs.nix @@ -1,8 +1,8 @@ -{ lib, pkgs, ... }: +{ config, lib, pkgs, ... }: let inherit (builtins) attrNames concatLists; - inherit (lib) mapAttrs mapAttrsToList mkDefault mkMerge optional; + inherit (lib) mapAttrs mapAttrsToList mkDefault mkIf mkMerge optional; flattenedPkgs = pkgs // (with pkgs; { # XXX can't `inherit` a nested attr, so we move them to the toplevel @@ -218,6 +218,7 @@ let mumble obsidian slic3r + steam ; }; x86GuiPkgs = { @@ -361,6 +362,11 @@ in # creds, widevine .so download. TODO: could easily manage these statically. spotify.dir = [ ".config/spotify" ]; + steam.dir = [ + ".steam" + ".local/share/Steam" + ]; + # sublime music persists any downloaded albums here. # it doesn't obey a conventional ~/Music/{Artist}/{Album}/{Track} notation, so no symlinking # config (e.g. server connection details) is persisted in ~/.config/sublime-music/config.json @@ -392,5 +398,13 @@ in # XXX: this might not be necessary. try removing this and cacert.unbundled (servo)? environment.etc."ssl/certs".source = "${pkgs.cacert.unbundled}/etc/ssl/certs/*"; + + # steam requires system-level config for e.g. firewall or controller support + programs.steam = mkIf config.sane.programs.steam.enabled { + enable = true; + # not sure if needed: stole this whole snippet from the wiki + remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play + dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server + }; }; } diff --git a/modules/programs.nix b/modules/programs.nix index a1365dcb..28998a8c 100644 --- a/modules/programs.nix +++ b/modules/programs.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, sane-lib, ... }: let - inherit (builtins) any elem map; + inherit (builtins) any attrValues elem map; inherit (lib) filterAttrs hasAttrByPath @@ -18,7 +18,7 @@ let ; inherit (sane-lib) joinAttrsets; cfg = config.sane.programs; - pkgSpec = types.submodule ({ name, ... }: { + pkgSpec = types.submodule ({ config, name, ... }: { options = { package = mkOption { type = types.nullOr types.package; @@ -59,6 +59,12 @@ let place this program on the PATH for some specified user(s). ''; }; + enabled = mkOption { + type = types.bool; + description = '' + generated (i.e. read-only) value indicating if the program is enabled either for any user or for the system. + ''; + }; suggestedPrograms = mkOption { type = types.listOf types.str; default = []; @@ -83,6 +89,9 @@ let }; }; + config = { + enabled = config.enableFor.system || any (en: en) (attrValues config.enableFor.user); + }; }); toPkgSpec = types.coercedTo types.package (p: { package = p; }) pkgSpec;