Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

steamvr: init #341095

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
28 changes: 28 additions & 0 deletions doc/build-helpers/fetchers.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,3 +888,31 @@ fetchtorrent {
- `config`: When using `transmission` as the `backend`, a json configuration can
be supplied to transmission. Refer to the [upstream documentation](https://github.com/transmission/transmission/blob/main/docs/Editing-Configuration-Files.md) for information on how to configure.

## `fetchSteam` ${#fetchsteam}

`fetchSteam` expects at least three arguments: `app`, `depot`, and `manifest`. Use [SteamDB](https://steamdb.info/) to find these values. `fetchSteam` only supports anonymous accounts.

```nix
{ fetchSteam }:

fetchSteam {
name = "steamvr-linux-depot";
app = 250820;
depot = 250823;
manifest = 5747149350848671194;
hash = "sha256-q3jasX/prYhs+Vs7Ofru2N3WVxf/0tGlqTd5SvKRm10=";
}
```

### Parameters {#fetchsteam-parameters}

- `name` (string): The name of the resulting derivation. Defaults to `"${app}-${depot}-${manifest}-depot"`.
- `app` (integer): The Steam app ID
- `depot` (integer): The Steam depot ID
- `manifest` (integer): The Steam manifest ID
- `branch` (string): Optional. The branch to download from. Cannot require a password. Defaults to none.
- `language` (string): Optional. The language for which to download the game. Defaults to DepotDownloader's default (english).
- `lowViolence` (boolean): Optional. Whether to download low-violence variations. Defaults to `false`.
- `fileList` (list of string): Optional. A list of files to download. Defaults to all files.
- `fileListRegex` (boolean): Optional. Whether `fileList` should be treated as a list of regular expressions to match the paths of the files. Defaults to `false`.
- `debug` (boolean): Optional. Prints additional debug information. Defaults to `false`.
60 changes: 60 additions & 0 deletions pkgs/build-support/fetchsteam/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
lib,
runCommand,
depotdownloader,
cacert,
writeText,
}:

{
name ? "${toString app}-${toString depot}-${toString manifest}-depot",
app,
depot,
manifest,
branch ? null,
language ? null,
lowViolence ? false,
fileList ? [ ],
fileListRegex ? false,
debug ? false,
hash ? lib.fakeHash,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hash ? lib.fakeHash,
hash ? "",

This is more inline with fetchers like fetchCargoTarball and pnpm.fetchDeps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the added complexity of doing it that way is particularly worth it. Those fetchers probably predate lib.fakeHash, so they chose the way that was simpler back then.

If you want to block on this, I'll change it, but I'd strongly prefer to keep it this way.

}:

runCommand name
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
({

Copy link
Contributor Author

@Pandapip1 Pandapip1 Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this accomplish?

EDIT: Figured it out. See #341095 (comment)

nativeBuildInputs = [ depotdownloader ];

env.SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";

outputHash = hash;
outputHashMode = "recursive";
}
''
# Hack to prevent DepotDownloader from crashing trying to write to ~/.local/share/
export HOME=$(mktemp -d)

DepotDownloader \
-app "${toString app}" \
-depot "${toString depot}" \
-manifest "${toString manifest}" \
${lib.optionalString (branch != null) "-beta ${branch}"} \
${lib.optionalString (language != null) "-language ${language}"} \
${lib.optionalString lowViolence "-lowviolence"} \
${
lib.optionalString (fileList != [ ]) (
(lib.optionalString fileListRegex "regex:")
+ (writeText "steam-file-list-${name}.txt" (lib.concatStringsSep "\n" fileList))
)
} \
${lib.optionalString debug "-debug"} \
-loginid ${
# From DepotDownloader help:
# -loginid <#> - a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently.
# We are running multiple instances of DepotDownloader concurrently, so this is required.
# Setting this to the manifest mod 2^32 will almost always result in a deterministic unique value.
# Nix doesn't have a builtin for mod, so we have to do it manually.
toString (manifest - (manifest / 4294967295) * 4294967295)
} \
-dir $out
rm -rf $out/.DepotDownloader
''
31 changes: 31 additions & 0 deletions pkgs/build-support/fetchsteam/depotdownloader_2_5_0/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{ lib
, buildDotnetModule
, fetchFromGitHub
, dotnetCorePackages
}:

buildDotnetModule rec {
pname = "depotdownloader";
version = "2.5.0";

src = fetchFromGitHub {
owner = "SteamRE";
repo = "DepotDownloader";
rev = "DepotDownloader_${version}";
sha256 = "Kgi0u+H5BIAhrjk9e+8H1h0p5Edm3+2twYBPY3JQGps=";
};

projectFile = "DepotDownloader.sln";
nugetDeps = ./deps.nix;

passthru.updateScript = ./update.sh;

meta = with lib; {
description = "Steam depot downloader utilizing the SteamKit2 library";
changelog = "https://github.com/SteamRE/DepotDownloader/releases/tag/DepotDownloader_${version}";
license = licenses.gpl2Only;
maintainers = [ maintainers.babbaj ];
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
mainProgram = "DepotDownloader";
};
}
15 changes: 15 additions & 0 deletions pkgs/build-support/fetchsteam/depotdownloader_2_5_0/deps.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions pkgs/by-name/st/steamctl/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
lib,
python3Packages,
fetchFromGitHub,
}:

python3Packages.buildPythonApplication rec {
pname = "steamctl";
version = "0.9.5";
pyproject = true;

src = fetchFromGitHub {
owner = "ValvePython";
repo = "steamctl";
rev = "refs/tags/v${version}";
hash = "sha256-reNch5MP31MxyaeKUlANfizOXZXjtIDeSM1kptsWqkc=";
};

build-system = with python3Packages; [ setuptools ];
dependencies = with python3Packages; [
steam
appdirs
argcomplete
tqdm
arrow
pyqrcode
vpk
beautifulsoup4
];

meta = {
description = "A CLI utility to interface with Steam";
homepage = "https://github.com/ValvePython/steamctl"; # GitHub's homepage is set to PyPi listing, PyPi listing's homepage is set to GitHub
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ pandapip1 ];
};
}
64 changes: 64 additions & 0 deletions pkgs/by-name/st/steamvr/PERMISSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
From: John, Gavin N. (Gavin) <[email protected]>
To: [email protected]
Subject: Permission to package SteamVR


Hi Valve VR folks,

I'm Gavin, an incoming freshman at Caltech. In my free time, I like to package programs for [nixpkgs](https://github.com/NixOS/nixpkgs), the package repository for the [nix](https://nixos.org/) package manager and its NixOS linux distribution.

I initially planned to package it by downloading it using depotdownloader, but discovered that SteamVR can't be downloaded in its entirety using anonymous accounts. This led me to discover the [SteamVR licensing page](https://partner.steamgames.com/doc/features/steamvr/enterprise), which had this email address.

Would you be okay with me modifying and distributing my copy of SteamVR for the purpose of making it available to install through nixpkgs? Nixpkgs has a mechanism to keep track of licenses that users have agreed to, so installation of SteamVR can require agreement to the Steam Subscriber Agreement, the Steam PC Café Agreement, and/or the SteamVR Commercial Installation License.

Thank you for your consideration!

Sincerely,

Gavin John

---

From: Ben Jackson <[email protected]>
To: John, Gavin N. (Gavin) <[email protected]>
Subject: Re: Permission to package SteamVR


* I initially planned to package it by downloading it using depotdownloader, but discovered that SteamVR can't be downloaded in its entirety using anonymous accounts.

Thanks for bringing this to our attention. I have fixed that issue.

* Would you be okay with me modifying and distributing my copy of SteamVR for the purpose of making it available to install through nixpkgs?

We would rather avoid that. I assume if depotdownloader works again, this would no longer be preferably anyway.

--Ben

---

From: John, Gavin N. (Gavin) <[email protected]>
To: Ben Jackson <[email protected]>
Subject: [External Mail] Re: Permission to package SteamVR


Hi Ben,

Thank you for your response! Thanks for fixing the issue with depot downloader. That's going to help a lot.

Some modifications to SteamVR will be necessary to make all functionality work with NixOS. Do I have permission to make a configuration file and script that makes the necessary modifications, and to have the config file and script distributed?

Thank you!

Sincerely,

Gavin

---

From: Ben Jackson <[email protected]>
To: "'John, Gavin N. (Gavin)'" <[email protected]>
Subject: RE: Permission to package SteamVR

It's fine to distribute patches that apply after downloading the base content.

If there are specific issues that you think are generic issues regarding portability you can also send them my way.
3 changes: 3 additions & 0 deletions pkgs/by-name/st/steamvr/darwin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{ lib }:

throw "Not yet implemented"
148 changes: 148 additions & 0 deletions pkgs/by-name/st/steamvr/linux.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
lib,
stdenvNoCC,
fetchSteam,
autoPatchelfHook,
audit,
bzip2,
expat,
gtk2,
gdk-pixbuf,
glib,
glibc,
libdrm,
libgcc,
libpng12,
libGL,
libusb1,
nspr,
nss,
openal,
SDL2,
vulkan-loader,
xorg,
zlib,
readline63,
rsync,
config,
acceptLicense ?
config.steam.acceptSubscriberAgreement or config.steam.acceptPCCafeAgreement
or config.steamvr.acceptCommercialLicense or true, # TODO: Change true to false once debugged
}:

stdenvNoCC.mkDerivation {
name = "steamvr-linux";

srcs =
assert
!acceptLicense
-> throw ''
Use of SteamVR requires the acceptance of at least one of the following license agreements:

- Steam Subscriber Agreement [1]
- Steam PC Café Agreement [2]
- SteamVR Commercial License Agreement [3]

You can express acceptance by setting one of the following options:

configuration.nix:
nixpkgs.config.steam.acceptSubscriberAgreement = true; # for the Steam Subscriber Agreement
nixpkgs.config.steam.acceptPCCafeAgreement = true; # for the Steam PC Café Agreement
nixpkgs.config.steamvr.acceptCommercialLicense = true; # for the SteamVR Commercial License Agreement

[1]: https://store.steampowered.com/subscriber_agreement/
[2]: https://partner.steamgames.com/doc/sitelicense/licensees/signup
[3]: https://partner.steamgames.com/doc/features/steamvr/enterprise
'';
[
(fetchSteam {
name = "steamvr-linux-depot";
app = 250820;
depot = 250823;
manifest = 5747149350848671194;
hash = "sha256-q3jasX/prYhs+Vs7Ofru2N3WVxf/0tGlqTd5SvKRm10=";
})
(fetchSteam {
name = "openvr-content-1-depot";
app = 250820;
depot = 250824;
manifest = 5862217504045387455;
hash = "sha256-X4vQdfrbkqkDk+zWeZ9uq0aqa3EDzrUAsMAzQGLhmo8=";
})
(fetchSteam {
name = "openvr-content-2-depot";
app = 250820;
depot = 250827;
manifest = 2950592113021695594;
hash = "sha256-5P8FRXAe2ZUsEQxtdVQLjvq8YHWqG1xY6paRDF8fHtc=";
})
(fetchSteam {
name = "openvr-content-3-depot";
app = 250820;
depot = 250828;
manifest = 7972087267127211047;
hash = "sha256-nsrYx+/pba38ucDaEXOhrQeTHERegHUSv3MjiOhUdjg=";
})
(fetchSteam {
name = "openvr-content-4-depot";
app = 250820;
depot = 250829;
manifest = 1180860512328011191;
hash = "sha256-yf6aSyQ0r1RoFEp5aK9yNPbMN5lZEkLG1Gmr1ffLEsA=";
})
(fetchSteam {
name = "steamvr-environments-linux-depot";
app = 250820;
depot = 250829;
manifest = 1180860512328011191;
hash = "sha256-yf6aSyQ0r1RoFEp5aK9yNPbMN5lZEkLG1Gmr1ffLEsA=";
})
];
sourceRoot = ".";

nativeBuildInputs = [
autoPatchelfHook
rsync
];
buildInputs =
[
audit
bzip2
expat
gtk2
gdk-pixbuf
glib
glibc
libdrm
libgcc.lib
libpng12
libGL
libusb1
nspr
nss
openal
readline63
SDL2
vulkan-loader
zlib
]
++ (with xorg; [
libX11
libXext
libXrender
libXi
libXtst
libXdamage
libSM
]);

dontConfigure = true;
dontBuild = true;

installPhase = ''
mkdir -p $out
for src in $srcs; do
rsync -a $src/ $out/
done
'';
}
Loading
Loading