2022-10-23 02:14:57 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2023-02-27 01:17:12 +00:00
|
|
|
, callPackage
|
2022-10-23 02:14:57 +00:00
|
|
|
, fetchFromGitHub
|
2023-02-27 01:17:12 +00:00
|
|
|
, fetchurl
|
2022-12-22 00:17:52 +00:00
|
|
|
, autoPatchelfHook
|
2023-02-27 01:17:12 +00:00
|
|
|
, makeWrapper
|
2022-12-22 00:17:52 +00:00
|
|
|
, buildNpmPackage
|
2022-10-23 02:14:57 +00:00
|
|
|
, cmake
|
|
|
|
, avahi
|
|
|
|
, libevdev
|
|
|
|
, libpulseaudio
|
|
|
|
, xorg
|
|
|
|
, libxcb
|
|
|
|
, openssl
|
|
|
|
, libopus
|
2023-02-27 01:17:12 +00:00
|
|
|
, ffmpeg_5-full
|
2022-10-23 02:14:57 +00:00
|
|
|
, boost
|
|
|
|
, pkg-config
|
|
|
|
, libdrm
|
|
|
|
, wayland
|
|
|
|
, libffi
|
|
|
|
, libcap
|
|
|
|
, mesa
|
2022-12-22 00:17:52 +00:00
|
|
|
, curl
|
|
|
|
, libva
|
|
|
|
, libvdpau
|
|
|
|
, numactl
|
2023-02-27 01:17:12 +00:00
|
|
|
, amf-headers
|
|
|
|
, svt-av1
|
|
|
|
, vulkan-loader
|
2023-04-03 00:02:22 +00:00
|
|
|
, libappindicator
|
2023-03-31 13:08:14 +00:00
|
|
|
, config
|
2023-07-20 15:08:19 +00:00
|
|
|
, cudaSupport ? config.cudaSupport
|
2022-10-23 02:14:57 +00:00
|
|
|
, cudaPackages ? {}
|
|
|
|
}:
|
2023-02-27 01:17:12 +00:00
|
|
|
let
|
|
|
|
libcbs = callPackage ./libcbs.nix { };
|
|
|
|
# get cmake file used to find external ffmpeg from previous sunshine version
|
|
|
|
findFfmpeg = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/LizardByte/Sunshine/6702802829869547708dfec98db5b8cbef39be89/cmake/FindFFMPEG.cmake";
|
|
|
|
sha256 = "sha256:1hl3sffv1z8ghdql5y9flk41v74asvh23y6jmaypll84f1s6k1xa";
|
|
|
|
};
|
|
|
|
in
|
2022-10-23 02:14:57 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sunshine";
|
2023-06-17 14:20:17 +00:00
|
|
|
version = "0.20.0";
|
2022-10-23 02:14:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "LizardByte";
|
|
|
|
repo = "Sunshine";
|
|
|
|
rev = "v${version}";
|
2023-06-17 14:20:17 +00:00
|
|
|
sha256 = "sha256-/ceN44PAEtXzrAUi4AEldW1FBhJqIXah1Zd0S6fiV3s=";
|
2022-10-23 02:14:57 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2022-12-22 00:17:52 +00:00
|
|
|
# remove pre-built ffmpeg; use ffmpeg from nixpkgs
|
2023-04-03 00:02:22 +00:00
|
|
|
patches = [
|
|
|
|
./ffmpeg.diff
|
|
|
|
];
|
2022-12-22 00:17:52 +00:00
|
|
|
|
|
|
|
# fetch node_modules needed for webui
|
|
|
|
ui = buildNpmPackage {
|
|
|
|
inherit src version;
|
|
|
|
pname = "sunshine-ui";
|
2023-06-17 14:20:17 +00:00
|
|
|
npmDepsHash = "sha256-pwmkpZjDwluKJjcY0ehetQbAlFnj1tsW100gRjolboc=";
|
2022-12-22 00:17:52 +00:00
|
|
|
|
|
|
|
dontNpmBuild = true;
|
|
|
|
|
2023-04-03 00:02:22 +00:00
|
|
|
# use generated package-lock.json as upstream does not provide one
|
2022-12-22 00:17:52 +00:00
|
|
|
postPatch = ''
|
|
|
|
cp ${./package-lock.json} ./package-lock.json
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r node_modules $out/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-10-23 02:14:57 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
pkg-config
|
2022-12-22 00:17:52 +00:00
|
|
|
autoPatchelfHook
|
2023-02-27 01:17:12 +00:00
|
|
|
makeWrapper
|
2022-10-23 02:14:57 +00:00
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
cudaPackages.autoAddOpenGLRunpathHook
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2023-02-27 01:17:12 +00:00
|
|
|
libcbs
|
2022-10-23 02:14:57 +00:00
|
|
|
avahi
|
2023-02-27 01:17:12 +00:00
|
|
|
ffmpeg_5-full
|
2022-10-23 02:14:57 +00:00
|
|
|
libevdev
|
|
|
|
libpulseaudio
|
|
|
|
xorg.libX11
|
|
|
|
libxcb
|
|
|
|
xorg.libXfixes
|
|
|
|
xorg.libXrandr
|
|
|
|
xorg.libXtst
|
2023-04-03 00:02:22 +00:00
|
|
|
xorg.libXi
|
2022-10-23 02:14:57 +00:00
|
|
|
openssl
|
|
|
|
libopus
|
|
|
|
boost
|
|
|
|
libdrm
|
|
|
|
wayland
|
|
|
|
libffi
|
|
|
|
libevdev
|
|
|
|
libcap
|
|
|
|
libdrm
|
2022-12-22 00:17:52 +00:00
|
|
|
curl
|
|
|
|
libva
|
|
|
|
libvdpau
|
|
|
|
numactl
|
2022-10-23 02:14:57 +00:00
|
|
|
mesa
|
2023-02-27 01:17:12 +00:00
|
|
|
amf-headers
|
|
|
|
svt-av1
|
2023-04-03 00:02:22 +00:00
|
|
|
libappindicator
|
2022-10-23 02:14:57 +00:00
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
cudaPackages.cudatoolkit
|
|
|
|
];
|
|
|
|
|
2022-12-22 00:17:52 +00:00
|
|
|
runtimeDependencies = [
|
|
|
|
avahi
|
|
|
|
mesa
|
|
|
|
xorg.libXrandr
|
|
|
|
libxcb
|
|
|
|
];
|
|
|
|
|
2022-10-23 02:14:57 +00:00
|
|
|
cmakeFlags = [
|
2022-12-22 00:17:52 +00:00
|
|
|
"-Wno-dev"
|
2022-10-23 02:14:57 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2023-04-03 00:02:22 +00:00
|
|
|
# fix hardcoded libevdev and icon path
|
2022-10-23 02:14:57 +00:00
|
|
|
substituteInPlace CMakeLists.txt \
|
2023-04-03 00:02:22 +00:00
|
|
|
--replace '/usr/include/libevdev-1.0' '${libevdev}/include/libevdev-1.0' \
|
|
|
|
--replace '/usr/share' "$out/share"
|
|
|
|
|
|
|
|
substituteInPlace packaging/linux/sunshine.desktop \
|
|
|
|
--replace '@PROJECT_NAME@' 'Sunshine'
|
2023-02-27 01:17:12 +00:00
|
|
|
|
|
|
|
# add FindFFMPEG to source tree
|
|
|
|
cp ${findFfmpeg} cmake/FindFFMPEG.cmake
|
2022-12-22 00:17:52 +00:00
|
|
|
'';
|
2022-10-23 02:14:57 +00:00
|
|
|
|
2022-12-22 00:17:52 +00:00
|
|
|
preBuild = ''
|
|
|
|
# copy node_modules where they can be picked up by build
|
2023-02-27 01:17:12 +00:00
|
|
|
mkdir -p ../node_modules
|
|
|
|
cp -r ${ui}/node_modules/* ../node_modules
|
|
|
|
'';
|
|
|
|
|
|
|
|
# allow Sunshine to find libvulkan
|
|
|
|
postFixup = lib.optionalString cudaSupport ''
|
|
|
|
wrapProgram $out/bin/sunshine \
|
|
|
|
--set LD_LIBRARY_PATH ${lib.makeLibraryPath [ vulkan-loader ]}
|
2022-10-23 02:14:57 +00:00
|
|
|
'';
|
|
|
|
|
2023-04-03 00:02:22 +00:00
|
|
|
postInstall = ''
|
|
|
|
install -Dm644 ../packaging/linux/${pname}.desktop $out/share/applications/${pname}.desktop
|
|
|
|
'';
|
|
|
|
|
2023-04-03 00:01:56 +00:00
|
|
|
passthru.updateScript = ./updater.sh;
|
|
|
|
|
2022-10-23 02:14:57 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Sunshine is a Game stream host for Moonlight.";
|
2022-12-22 00:17:52 +00:00
|
|
|
homepage = "https://github.com/LizardByte/Sunshine";
|
2022-10-23 02:14:57 +00:00
|
|
|
license = licenses.gpl3Only;
|
|
|
|
maintainers = with maintainers; [ devusb ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|