pkgs.mkProtonBinDerivation

pkgs.mkProtonBinDerivation packages a prebuilt release of Proton, or of another Steam compatibility tool, for use with the NixOS option programs.steam.extraCompatPackages.

The tool is installed into the steamcompattool output, which is what programs.steam.extraCompatPackages adds to Steam. The release for the host system is symlinked into it, except for compatibilitytool.vdf, which is copied so the name of the tool can be replaced with steamDisplayName. If the release has a proton script, mkProtonBinDerivation copies and patches it. The patched script makes Wine re-apply wine.inf when Proton upgrades a prefix to a new version, for example to register new services. Without the patch, Wine skips wine.inf on upgrades, because every file in the Nix store has the same modification time.

mkProtonBinDerivation supports fixed-point arguments, and accepts all the attributes of stdenvNoCC.mkDerivation.

Inputs

variants (Attribute set; required)

The release for each supported system, as an attribute set mapping a system to { src; toolName; }:

  • src: the unpacked release, usually from fetchzip.
  • toolName: the name of the tool in the release's compatibilitytool.vdf.

variants is not passed on to the derivation, so changing the release for one system does not rebuild the others. As a consequence it can't be changed with overrideAttrs; override src and toolName instead.

meta.platforms defaults to the systems listed in variants.

steamDisplayName (String; optional)

The name shown in Steam. Can be changed with overrideAttrs, which is useful to install several versions of a tool side by side.

Default value: pname.

userSettings (Attribute set of strings; optional)

Environment variables written to the tool's user_settings.py, which Proton applies to every game run with it. Variables already set in the environment, for example in a game's launch options, take precedence. Only has an effect on tools that ship a proton script. Can be changed with overrideAttrs.

Default value: { }, which writes no user_settings.py.

Update script

pkgs.proton-bin-update-script creates a passthru.updateScript for packages built with mkProtonBinDerivation. It takes an attribute set with a single attribute:

latestVersionCommand (String)

A shell snippet printing the latest upstream version. curl and jq are available to it.

The script updates version and the src of every system in meta.platforms, currently supporting x86_64-linux and aarch64-linux. Each system's release is fetched on the local machine. It exits without changes when the package is already at the latest version.

The script reads the package to update from the environment set by maintainers/scripts/update.nix, so it has to be run through it:

nix-shell maintainers/scripts/update.nix --argstr package proton-ge-bin

Examples

Example

Packaging a Proton release

{
  lib,
  mkProtonBinDerivation,
  proton-bin-update-script,
  fetchzip,
}:

mkProtonBinDerivation (finalAttrs: {
  pname = "proton-example-bin";
  version = "Proton-Example-1";
  steamDisplayName = "Proton-Example";

  variants = {
    "x86_64-linux" = {
      toolName = "${finalAttrs.version}-x86_64";
      src = fetchzip {
        url = "https://example.org/${finalAttrs.version}-x86_64.tar.gz";
        hash = "...";
      };
    };
  };

  passthru.updateScript = proton-bin-update-script {
    latestVersionCommand = ''
      curl -fsSL https://example.org/releases.json | jq -er '.[0].tag_name'
    '';
  };

  meta = {
    description = "Example Proton fork";
    license = lib.licenses.bsd3;
  };
})

Example

Changing the name shown in Steam

{ pkgs, ... }:
{
  programs.steam.extraCompatPackages = [
    (pkgs.proton-ge-bin.overrideAttrs { steamDisplayName = "GE-Proton (Nix)"; })
  ];
}

Example

Setting environment variables for every game

{ pkgs, ... }:
{
  programs.steam.extraCompatPackages = [
    (pkgs.proton-ge-bin.overrideAttrs {
      userSettings = {
        PROTON_LOG = "1";
        DXVK_HUD = "devinfo,fps";
      };
    })
  ];
}