nixpkgs/pkgs/servers/sunshine/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

179 lines
3.3 KiB
Nix
Raw Normal View History

2022-10-23 02:14:57 +00:00
{ lib
, stdenv
, fetchFromGitHub
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
, boost
, pkg-config
, libdrm
, wayland
, libffi
, libcap
, mesa
2022-12-22 00:17:52 +00:00
, curl
2023-10-21 16:38:35 +00:00
, pcre
, pcre2
, libuuid
, libselinux
, libsepol
, libthai
, libdatrie
, libxkbcommon
, libepoxy
2022-12-22 00:17:52 +00:00
, libva
, libvdpau
, libglvnd
2022-12-22 00:17:52 +00:00
, numactl
2023-02-27 01:17:12 +00:00
, amf-headers
2023-10-21 16:38:35 +00:00
, intel-media-sdk
2023-02-27 01:17:12 +00:00
, svt-av1
, vulkan-loader
2023-04-03 00:02:22 +00:00
, libappindicator
2023-10-21 16:38:35 +00:00
, libnotify
, config
, cudaSupport ? config.cudaSupport
2022-10-23 02:14:57 +00:00
, cudaPackages ? {}
}:
stdenv.mkDerivation rec {
pname = "sunshine";
2023-10-21 16:38:35 +00:00
version = "0.21.0";
2022-10-23 02:14:57 +00:00
src = fetchFromGitHub {
owner = "LizardByte";
repo = "Sunshine";
rev = "v${version}";
2023-10-21 16:38:35 +00:00
sha256 = "sha256-uvQAJkoKazFLz5iTpYSAGYJQZ2EprQ+p9+tryqorFHM=";
2022-10-23 02:14:57 +00:00
fetchSubmodules = true;
};
2022-12-22 00:17:52 +00:00
# fetch node_modules needed for webui
ui = buildNpmPackage {
inherit src version;
pname = "sunshine-ui";
2023-10-21 16:38:35 +00:00
npmDepsHash = "sha256-+T1XAf4SThoJLOFpnVxDa2qiKFLIKQPGewjA83GQovM=";
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 = [
avahi
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
2023-10-21 16:38:35 +00:00
pcre
pcre2
libuuid
libselinux
libsepol
libthai
libdatrie
xorg.libXdmcp
libxkbcommon
libepoxy
2022-12-22 00:17:52 +00:00
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
2023-10-21 16:38:35 +00:00
libnotify
2022-10-23 02:14:57 +00:00
] ++ lib.optionals cudaSupport [
cudaPackages.cudatoolkit
2023-10-21 16:38:35 +00:00
] ++ lib.optionals stdenv.isx86_64 [
intel-media-sdk
2022-10-23 02:14:57 +00:00
];
2022-12-22 00:17:52 +00:00
runtimeDependencies = [
avahi
mesa
xorg.libXrandr
libxcb
libglvnd
2022-12-22 00:17:52 +00:00
];
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-10-21 16:38:35 +00:00
# fix hardcoded libevdev path
substituteInPlace cmake/compile_definitions/linux.cmake \
--replace '/usr/include/libevdev-1.0' '${libevdev}/include/libevdev-1.0'
2023-04-03 00:02:22 +00:00
substituteInPlace packaging/linux/sunshine.desktop \
2023-10-21 16:38:35 +00:00
--replace '@PROJECT_NAME@' 'Sunshine' \
--replace '@PROJECT_DESCRIPTION@' 'Self-hosted game stream host for Moonlight'
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; {
2023-10-21 16:38:35 +00:00
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;
mainProgram = "sunshine";
2022-10-23 02:14:57 +00:00
maintainers = with maintainers; [ devusb ];
platforms = platforms.linux;
};
}