From 8a0debedb2cc83786fbf0c9d92d68f119eccd9d8 Mon Sep 17 00:00:00 2001 From: Tom Hunze Date: Sun, 7 Dec 2025 16:50:19 +0100 Subject: [PATCH] stremio-linux-shell: init at 1.0.0-beta.13 Co-authored-by: Fazzi --- .../allow-local-network-access.patch | 15 ++ .../better-server-path.patch | 13 ++ .../fix-getshaderinfolog-call.patch | 21 +++ .../st/stremio-linux-shell/package.nix | 142 ++++++++++++++++++ 4 files changed, 191 insertions(+) create mode 100644 pkgs/by-name/st/stremio-linux-shell/allow-local-network-access.patch create mode 100644 pkgs/by-name/st/stremio-linux-shell/better-server-path.patch create mode 100644 pkgs/by-name/st/stremio-linux-shell/fix-getshaderinfolog-call.patch create mode 100644 pkgs/by-name/st/stremio-linux-shell/package.nix diff --git a/pkgs/by-name/st/stremio-linux-shell/allow-local-network-access.patch b/pkgs/by-name/st/stremio-linux-shell/allow-local-network-access.patch new file mode 100644 index 000000000000..524d20502b3b --- /dev/null +++ b/pkgs/by-name/st/stremio-linux-shell/allow-local-network-access.patch @@ -0,0 +1,15 @@ +diff --git a/src/webview/app/mod.rs b/src/webview/app/mod.rs +index 2c6125e..26ab73f 100644 +--- a/src/webview/app/mod.rs ++++ b/src/webview/app/mod.rs +@@ -23,6 +23,10 @@ cef_impl!( + CMD_SWITCHES.iter().for_each(|switch| { + line.append_switch(Some(&CefString::from(switch.to_owned()))); + }); ++ line.append_switch_with_value( ++ Some(&CefString::from("disable-features")), ++ Some(&CefString::from("LocalNetworkAccessChecks")), ++ ); + } + } + diff --git a/pkgs/by-name/st/stremio-linux-shell/better-server-path.patch b/pkgs/by-name/st/stremio-linux-shell/better-server-path.patch new file mode 100644 index 000000000000..8e7cb8d1370b --- /dev/null +++ b/pkgs/by-name/st/stremio-linux-shell/better-server-path.patch @@ -0,0 +1,13 @@ +diff --git a/src/config.rs b/src/config.rs +index 4eda395..679699f 100644 +--- a/src/config.rs ++++ b/src/config.rs +@@ -70,7 +70,7 @@ pub struct ServerConfig { + + impl ServerConfig { + pub fn new(current_dir: &Path) -> Self { +- let file = current_dir.join(SERVER_FILE); ++ let file = Path::new("@serverjs@").to_path_buf(); + + Self { file } + } diff --git a/pkgs/by-name/st/stremio-linux-shell/fix-getshaderinfolog-call.patch b/pkgs/by-name/st/stremio-linux-shell/fix-getshaderinfolog-call.patch new file mode 100644 index 000000000000..6a0af3cb1953 --- /dev/null +++ b/pkgs/by-name/st/stremio-linux-shell/fix-getshaderinfolog-call.patch @@ -0,0 +1,21 @@ +diff --git a/src/shared/renderer/utils.rs b/src/shared/renderer/utils.rs +index be4a65d..1b944ad 100644 +--- a/src/shared/renderer/utils.rs ++++ b/src/shared/renderer/utils.rs +@@ -1,6 +1,6 @@ + use std::{mem, ptr}; + +-use gl::types::{GLenum, GLfloat, GLint, GLsizei, GLsizeiptr, GLuint}; ++use gl::types::{GLchar, GLenum, GLfloat, GLint, GLsizei, GLsizeiptr, GLuint}; + + use super::constants::BYTES_PER_PIXEL; + +@@ -139,7 +139,7 @@ pub fn compile_shader(kind: GLenum, src: &str) -> GLuint { + gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &mut len); + + let mut buffer = vec![0u8; len as usize]; +- gl::GetShaderInfoLog(shader, len, ptr::null_mut(), buffer.as_mut_ptr() as *mut i8); ++ gl::GetShaderInfoLog(shader, len, ptr::null_mut(), buffer.as_mut_ptr() as *mut GLchar); + + panic!( + "Shader compile error: {}", diff --git a/pkgs/by-name/st/stremio-linux-shell/package.nix b/pkgs/by-name/st/stremio-linux-shell/package.nix new file mode 100644 index 000000000000..f22d7e6bfc23 --- /dev/null +++ b/pkgs/by-name/st/stremio-linux-shell/package.nix @@ -0,0 +1,142 @@ +{ + lib, + symlinkJoin, + rustPlatform, + fetchFromGitHub, + versionCheckHook, + gitUpdater, + + # buildInputs + atk, + cef-binary, + gtk3, + libayatana-appindicator, + libxkbcommon, + mpv, + openssl, + + # nativeBuildInputs + makeBinaryWrapper, + pkg-config, + wrapGAppsHook4, + + # Wrapper + addDriverRunpath, + libGL, + nodejs, +}: + +let + # Stremio expects CEF files in a specific layout + cef = symlinkJoin { + name = "stremio-linux-shell-cef"; + paths = [ + "${cef-binary}/Resources" + "${cef-binary}/Release" + ]; + }; +in +rustPlatform.buildRustPackage (finalAttrs: { + pname = "stremio-linux-shell"; + version = "1.0.0-beta.13"; + + src = fetchFromGitHub { + owner = "Stremio"; + repo = "stremio-linux-shell"; + tag = "v${finalAttrs.version}"; + hash = "sha256-1f9IBNo5gxpSqTSIf8QuQOlf+sfRhohOmQTLRbX/OU8="; + }; + + cargoHash = "sha256-wx5oF4uF9UMtKzfGxZKsy6mVjYaRD40dLuvaRtz8yE4="; + + patches = [ + # Chromium 142 stopped allowing local network access by default, which + # breaks the app's ability to communicate with the Stremio server. + ./allow-local-network-access.patch + + # GLchar is u8 on aarch64 + # Upstream PR: https://github.com/Stremio/stremio-linux-shell/pull/40 + ./fix-getshaderinfolog-call.patch + + # Patch server.js path so that we don't have to install it in $out/bin + ./better-server-path.patch + ]; + + postPatch = '' + substituteInPlace src/config.rs \ + --replace-fail "@serverjs@" "${placeholder "out"}/share/stremio/server.js" + + substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \ + --replace-fail "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" + substituteInPlace $cargoDepsCopy/xkbcommon-dl-*/src/lib.rs \ + --replace-fail "libxkbcommon.so.0" "${libxkbcommon}/lib/libxkbcommon.so.0" + substituteInPlace $cargoDepsCopy/xkbcommon-dl-*/src/x11.rs \ + --replace-fail "libxkbcommon-x11.so.0" "${libxkbcommon}/lib/libxkbcommon-x11.so.0" + ''; + + # Don't download CEF during build + buildFeatures = [ "offline-build" ]; + + buildInputs = [ + atk + cef + gtk3 + libayatana-appindicator + libxkbcommon + mpv + openssl + ]; + + nativeBuildInputs = [ + makeBinaryWrapper + pkg-config + wrapGAppsHook4 + ]; + + env.CEF_PATH = "${cef}"; + + postInstall = '' + mkdir -p $out/share/applications + cp data/com.stremio.Stremio.desktop $out/share/applications/com.stremio.Stremio.desktop + + mkdir -p $out/share/icons/hicolor/scalable/apps + cp data/icons/com.stremio.Stremio.svg $out/share/icons/hicolor/scalable/apps/com.stremio.Stremio.svg + + mkdir -p $out/share/stremio + cp data/server.js $out/share/stremio/server.js + + mv $out/bin/stremio-linux-shell $out/bin/stremio + ''; + + # Node.js is required to run `server.js` + # Add to `gappsWrapperArgs` to avoid two layers of wrapping. + preFixup = '' + gappsWrapperArgs+=( + --prefix LD_LIBRARY_PATH : "${addDriverRunpath.driverLink}/lib" \ + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" \ + --prefix PATH : "${lib.makeBinPath [ nodejs ]}" + ) + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "--version"; + doInstallCheck = true; + + passthru = { + inherit cef; + updateScript = gitUpdater { rev-prefix = "v"; }; + }; + + meta = { + description = "Modern media center that gives you the freedom to watch everything you want"; + homepage = "https://www.stremio.com/"; + license = with lib.licenses; [ + gpl3Only + # server.js is unfree + unfree + ]; + maintainers = with lib.maintainers; [ thunze ]; + platforms = lib.platforms.linux; + mainProgram = "stremio"; + }; +})