Skip to content

Instantly share code, notes, and snippets.

@yuchangyuan
Created June 10, 2022 02:17
Show Gist options
  • Save yuchangyuan/eadf7ffbe8ae6958ce3a17a0f30a8c0d to your computer and use it in GitHub Desktop.
Save yuchangyuan/eadf7ffbe8ae6958ce3a17a0f30a8c0d to your computer and use it in GitHub Desktop.
nix package for sunshine
{ stdenv, fetchgit, cmake, pkgconfig
, openssl, boost, libpulseaudio, libopus, ffmpeg, libevdev, libffi
, xorg
, libdrm, libcap, mesa
, wayland
, avahi }:
stdenv.mkDerivation rec {
name = "sunshine-" + version;
version = "v0.13.0";
src = fetchgit {
url = "https://github.com/SunshineStream/Sunshine.git";
fetchSubmodules = true;
rev = "refs/tags/${version}";
sha256 = "1nwm2v62gpxs5wyyyxgj24xkf3hsbvfmj7pycdzp526kkv9l1yxm";
};
nativeBuildInputs = [ pkgconfig cmake ];
postPatch = ''
sed -i -e 's|/usr/include/libevdev-1.0|${libevdev}/include/libevdev-1.0|' ./CMakeLists.txt
sed -i -e 's/-Wno-format/-Wno-format -Wno-format-security/' ./third-party/cbs/CMakeLists.txt
# fix ASSETS_DIR
sed -i -e '4iset(SUNSHINE_ASSETS_DIR "'$out'/share/assets")' ./CMakeLists.txt
'';
buildInputs = [
# common
openssl libpulseaudio libopus ffmpeg libevdev libffi
(boost.override { enableShared = false; }) # boost need static
# x11
xorg.libXtst xorg.libX11 xorg.libXrandr xorg.libXfixes xorg.libxcb
# kms
libdrm libcap
# wayland
wayland
];
runtimeDependencies = [
mesa # libgbm
];
installPhase = ''
mkdir -p $out/bin
cp -a sunshine sunshine-* $out/bin
mkdir -p $out/share
cp -a ../assets $out/share
'';
postFixup = ''
patchelf \
--set-rpath $(patchelf --print-rpath $out/bin/sunshine-*):${mesa}/lib:${avahi}/lib:/run/opengl-driver/lib \
$out/bin/sunshine-*
'';
meta = {
homepage = https://sunshinestream.github.io;
description = "Sunshine is a Gamestream host for Moonlight! Stream your PC to any supported Moonlight client app.";
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment