Commit 55432fae authored by K900's avatar K900
Browse files

steam: refactor and expose fhsenv building

We have things that want a Steam Runtime-friendly fhsenv,
for example umu-launcher and others. Expose that directly
from the Steam package.
parent 3dcd2027
Loading
Loading
Loading
Loading
+174 −144
Original line number Diff line number Diff line
@@ -13,21 +13,28 @@
  privateTmp ? true, # if the steam bubblewrap should isolate /tmp
}:
let
  steamEnv =
  buildRuntimeEnv =
    {
      name,
      runScript,
      passthru ? { },
      meta ? { },
    }:
    buildFHSEnv {
      inherit
        name
        runScript
        passthru
        meta
        privateTmp
        ;
      extraPkgs ? pkgs: [ ],
      extraLibraries ? pkgs: [ ],
      extraProfile ? "",
      extraPreBwrapCmds ? "",
      extraBwrapArgs ? [ ],
      extraEnv ? { },
      ...
    }@args:
    buildFHSEnv (
      (builtins.removeAttrs args [
        "extraPkgs"
        "extraLibraries"
        "extraProfile"
        "extraPreBwrapCmds"
        "extraBwrapArgs"
        "extraArgs"
        "extraEnv"
      ])
      // {
        inherit privateTmp;

        multiArch = true;
        includeClosures = true;
@@ -37,8 +44,6 @@ let
          pkgs:
          with pkgs;
          [
          steam-unwrapped

            bash
            coreutils
            file
@@ -86,10 +91,6 @@ let
          ]
          ++ extraLibraries pkgs;

      extraInstallCommands = lib.optionalString (steam-unwrapped != null) ''
        ln -s ${steam-unwrapped}/share $out/share
      '';

        profile = ''
          # prevents log spam from SteamRT GTK trying to load host GIO modules
          unset GIO_EXTRA_MODULES
@@ -135,18 +136,47 @@ let
          "--bind-try /tmp/dumps /tmp/dumps"
        ]
        ++ extraBwrapArgs;
    };
      }
    );
in
steamEnv {
  name = "steam";
buildRuntimeEnv {
  pname = "steam";
  inherit (steam-unwrapped) version meta;

  extraPkgs = pkgs: [ steam-unwrapped ] ++ extraPkgs pkgs;
  inherit
    extraLibraries
    extraProfile
    extraPreBwrapCmds
    extraBwrapArgs
    extraEnv
    ;

  runScript = writeShellScript "steam-wrapped" ''
    exec steam ${extraArgs} "$@"
  '';

  passthru.run = steamEnv {
  extraInstallCommands = ''
    ln -s ${steam-unwrapped}/share $out/share
  '';

  passthru =
    let
      makeSteamRun =
        package:
        buildRuntimeEnv {
          name = "steam-run";

          extraPkgs = pkgs: package ++ extraPkgs pkgs;

          inherit
            extraLibraries
            extraProfile
            extraPreBwrapCmds
            extraBwrapArgs
            extraEnv
            ;

          runScript = writeShellScript "steam-run" ''
            if [ $# -eq 0 ]; then
              echo "Usage: steam-run command-to-run args..." >&2
@@ -156,18 +186,18 @@ steamEnv {
            exec "$@"
          '';

    meta = (steam-unwrapped.meta or { }) // {
          meta = {
            description = "Run commands in the same FHS environment that is used for Steam";
            mainProgram = "steam-run";
            name = "steam-run";
      # steam-run itself is just a script that lives in nixpkgs (which is licensed under MIT).
      # steam is a dependency and already unfree, so normal steam-run will not install without
      # allowing unfree packages or appropriate `allowUnfreePredicate` rules.
            license = lib.licenses.mit;
          };
        };
    in
    {
      inherit buildRuntimeEnv;

  meta = (steam-unwrapped.meta or { }) // {
    description = "Steam dependencies (dummy package, do not use)";
      run = makeSteamRun [ steam-unwrapped ];
      run-free = makeSteamRun [ ];
    };
}
+1 −5
Original line number Diff line number Diff line
@@ -14922,11 +14922,7 @@ with pkgs;
  springLobby = callPackage ../games/spring/springlobby.nix { };

  steam-run = steam.run;

  # This exists so Hydra tries to build all of Steam's dependencies.
  steam-fhsenv-without-steam = steam.override { steam-unwrapped = null; };

  steam-run-free = steam-fhsenv-without-steam.run;
  steam-run-free = steam.run-free;

  steamback = python3.pkgs.callPackage ../tools/games/steamback { };