nixpkgs/pkgs/servers/sunshine/default.nix

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

194 lines
3.8 KiB
Nix
Raw Normal View History

2022-10-23 02:14:57 +00:00
{ lib
, stdenv
, fetchFromGitHub
2024-03-07 01:35:58 +00:00
, fetchpatch
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
2024-03-07 01:35:58 +00:00
, miniupnpc
, config
, cudaSupport ? config.cudaSupport
2024-03-07 01:35:58 +00:00
, cudaPackages ? { }
2022-10-23 02:14:57 +00:00
}:
let
stdenv' = if cudaSupport then cudaPackages.backendStdenv else stdenv;
in
stdenv'.mkDerivation rec {
2022-10-23 02:14:57 +00:00
pname = "sunshine";
2024-03-07 01:35:58 +00:00
version = "0.22.0";
2022-10-23 02:14:57 +00:00
src = fetchFromGitHub {
owner = "LizardByte";
repo = "Sunshine";
rev = "v${version}";
2024-03-07 01:35:58 +00:00
sha256 = "sha256-O9U4zP1o6yWtzk+2DW7ueimvsTuajLY8IETlvCT4jTE=";
2022-10-23 02:14:57 +00:00
fetchSubmodules = true;
};
2024-03-07 01:35:58 +00:00
patches = [
# remove npm install as it needs internet access -- handled separately below
./dont-build-webui.patch
# revert https://github.com/LizardByte/Sunshine/pull/2046 - let cmake install handle udev and systemd files
(fetchpatch {
url = "https://github.com/LizardByte/Sunshine/commit/0d4dfcd708c0027b7d8827a03163858800fa79fa.patch";
hash = "sha256-77NtfX0zB7ty92AyFOz9wJoa1jHshlNbPQ7NOpqUuYo=";
revert = true;
})
];
# build webui
2022-12-22 00:17:52 +00:00
ui = buildNpmPackage {
inherit src version;
pname = "sunshine-ui";
2024-03-07 01:35:58 +00:00
npmDepsHash = "sha256-jAZUu2CfcqhC2xMiZYpY7KPCRVFQgT/kgUvSI+5Cpkc=";
2022-12-22 00:17:52 +00:00
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
2024-03-07 01:35:58 +00:00
cp -r * $out/
2022-12-22 00:17:52 +00:00
'';
};
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
2024-03-07 01:35:58 +00:00
miniupnpc
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' \
2024-03-07 01:35:58 +00:00
--replace '@PROJECT_DESCRIPTION@' 'Self-hosted game stream host for Moonlight' \
--replace '/usr/bin/env systemctl start --u sunshine' 'sunshine'
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 = ''
2024-03-07 01:35:58 +00:00
# copy webui where it can be picked up by build
cp -r ${ui}/build ../
2023-02-27 01:17:12 +00:00
'';
# 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;
};
}