summary refs log tree commit diff
diff options
context:
space:
mode:
authorAtemu <atemu.main@gmail.com>2023-03-07 20:24:28 +0100
committerAtemu <atemu.main@gmail.com>2023-03-26 17:19:33 +0200
commit473159871236e584af08386ed408aef30102395c (patch)
tree86f023e7bd870d8a40aa5576db24f02d72459141
parent192c3ecd4bcc317c3d8868d3c944a75de0dee32e (diff)
downloadnixpkgs-473159871236e584af08386ed408aef30102395c.tar
nixpkgs-473159871236e584af08386ed408aef30102395c.tar.gz
nixpkgs-473159871236e584af08386ed408aef30102395c.tar.bz2
nixpkgs-473159871236e584af08386ed408aef30102395c.tar.lz
nixpkgs-473159871236e584af08386ed408aef30102395c.tar.xz
nixpkgs-473159871236e584af08386ed408aef30102395c.tar.zst
nixpkgs-473159871236e584af08386ed408aef30102395c.zip
nixos/steam: always apply extraLibraries and make them additive
Before, setting {option}`programs.steam.package` would result in a steam without
the {option}`hardware.opengl.package`, {option}`hardware.opengl.extraPackages`
etc. You had to manually add them yourself.

Additionally, overlaying `steam = prev.steam.override { extraLibraries = [ ... ]; }`
resulted in those extra libraries not actually being put into the fhsenv because
they'd be fully overridden by the option's default.

Now, the user can supply a custom steam to {option}`programs.steam.package` with
its own list of extraLibraries which will not be overridden and overlays work as
expected too.
-rw-r--r--nixos/modules/programs/steam.nix34
1 files changed, 21 insertions, 13 deletions
diff --git a/nixos/modules/programs/steam.nix b/nixos/modules/programs/steam.nix
index 98269f6250d..6935ac93bf7 100644
--- a/nixos/modules/programs/steam.nix
+++ b/nixos/modules/programs/steam.nix
@@ -9,23 +9,31 @@ in {
     enable = mkEnableOption (lib.mdDoc "steam");
 
     package = mkOption {
-      type        = types.package;
-      default     = pkgs.steam.override {
-        extraLibraries = pkgs: with config.hardware.opengl;
-          if pkgs.stdenv.hostPlatform.is64bit
-          then [ package ] ++ extraPackages
-          else [ package32 ] ++ extraPackages32;
-      };
-      defaultText = literalExpression ''
-        pkgs.steam.override {
-          extraLibraries = pkgs: with config.hardware.opengl;
+      type = types.package;
+      default = pkgs.steam;
+      defaultText = literalExpression "pkgs.steam";
+      example = literalExpression ''
+        pkgs.steam-small.override {
+          extraLibraries = with pkgs; [
+            atk
+          ];
+        }
+      '';
+      apply = steam: steam.override (prev: {
+        extraLibraries = pkgs: let
+          prevLibs = if prev ? extraLibraries then prev.extraLibraries pkgs else [ ];
+          additionalLibs = with config.hardware.opengl;
             if pkgs.stdenv.hostPlatform.is64bit
             then [ package ] ++ extraPackages
             else [ package32 ] ++ extraPackages32;
-        }
-      '';
+        in prevLibs ++ additionalLibs;
+      });
       description = lib.mdDoc ''
-        steam package to use.
+        The Steam package to use. Additional libraries are added from the system
+        configuration to ensure graphics work properly.
+
+        Use this option to customise the Steam package rather than adding your
+        custom Steam to {option}`environment.systemPackages` yourself.
       '';
     };