mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 01:13:05 +00:00
63746cac08
This PR refactor CUDA setup hooks, and in particular autoAddOpenGLRunpath and autoAddCudaCompatRunpathHook, that were using a lot of code in common (in fact, I introduced the latter by copy pasting most of the bash script of the former). This is not satisfying for maintenance, as a recent patch showed, because we need to duplicate changes to both hooks. This commit abstract the common part in a single shell script that applies a generic patch action to every elf file in the output. For autoAddOpenGLRunpath the action is just addOpenGLRunpath (now addDriverRunpath), and is few line function for autoAddCudaCompatRunpathHook. Doing so, we also takes the occasion to use the newer addDriverRunpath instead of the previous addOpenGLRunpath, and rename the CUDA hook to reflect that as well. Co-Authored-By: Connor Baker <connor.baker@tweag.io>
179 lines
3.3 KiB
Nix
179 lines
3.3 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchFromGitHub
|
|
, autoPatchelfHook
|
|
, makeWrapper
|
|
, buildNpmPackage
|
|
, cmake
|
|
, avahi
|
|
, libevdev
|
|
, libpulseaudio
|
|
, xorg
|
|
, libxcb
|
|
, openssl
|
|
, libopus
|
|
, boost
|
|
, pkg-config
|
|
, libdrm
|
|
, wayland
|
|
, libffi
|
|
, libcap
|
|
, mesa
|
|
, curl
|
|
, pcre
|
|
, pcre2
|
|
, libuuid
|
|
, libselinux
|
|
, libsepol
|
|
, libthai
|
|
, libdatrie
|
|
, libxkbcommon
|
|
, libepoxy
|
|
, libva
|
|
, libvdpau
|
|
, libglvnd
|
|
, numactl
|
|
, amf-headers
|
|
, intel-media-sdk
|
|
, svt-av1
|
|
, vulkan-loader
|
|
, libappindicator
|
|
, libnotify
|
|
, config
|
|
, cudaSupport ? config.cudaSupport
|
|
, cudaPackages ? {}
|
|
}:
|
|
stdenv.mkDerivation rec {
|
|
pname = "sunshine";
|
|
version = "0.21.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "LizardByte";
|
|
repo = "Sunshine";
|
|
rev = "v${version}";
|
|
sha256 = "sha256-uvQAJkoKazFLz5iTpYSAGYJQZ2EprQ+p9+tryqorFHM=";
|
|
fetchSubmodules = true;
|
|
};
|
|
|
|
# fetch node_modules needed for webui
|
|
ui = buildNpmPackage {
|
|
inherit src version;
|
|
pname = "sunshine-ui";
|
|
npmDepsHash = "sha256-+T1XAf4SThoJLOFpnVxDa2qiKFLIKQPGewjA83GQovM=";
|
|
|
|
dontNpmBuild = true;
|
|
|
|
# use generated package-lock.json as upstream does not provide one
|
|
postPatch = ''
|
|
cp ${./package-lock.json} ./package-lock.json
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp -r node_modules $out/
|
|
'';
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
cmake
|
|
pkg-config
|
|
autoPatchelfHook
|
|
makeWrapper
|
|
] ++ lib.optionals cudaSupport [
|
|
cudaPackages.autoAddDriverRunpath
|
|
];
|
|
|
|
buildInputs = [
|
|
avahi
|
|
libevdev
|
|
libpulseaudio
|
|
xorg.libX11
|
|
libxcb
|
|
xorg.libXfixes
|
|
xorg.libXrandr
|
|
xorg.libXtst
|
|
xorg.libXi
|
|
openssl
|
|
libopus
|
|
boost
|
|
libdrm
|
|
wayland
|
|
libffi
|
|
libevdev
|
|
libcap
|
|
libdrm
|
|
curl
|
|
pcre
|
|
pcre2
|
|
libuuid
|
|
libselinux
|
|
libsepol
|
|
libthai
|
|
libdatrie
|
|
xorg.libXdmcp
|
|
libxkbcommon
|
|
libepoxy
|
|
libva
|
|
libvdpau
|
|
numactl
|
|
mesa
|
|
amf-headers
|
|
svt-av1
|
|
libappindicator
|
|
libnotify
|
|
] ++ lib.optionals cudaSupport [
|
|
cudaPackages.cudatoolkit
|
|
] ++ lib.optionals stdenv.isx86_64 [
|
|
intel-media-sdk
|
|
];
|
|
|
|
runtimeDependencies = [
|
|
avahi
|
|
mesa
|
|
xorg.libXrandr
|
|
libxcb
|
|
libglvnd
|
|
];
|
|
|
|
cmakeFlags = [
|
|
"-Wno-dev"
|
|
];
|
|
|
|
postPatch = ''
|
|
# fix hardcoded libevdev path
|
|
substituteInPlace cmake/compile_definitions/linux.cmake \
|
|
--replace '/usr/include/libevdev-1.0' '${libevdev}/include/libevdev-1.0'
|
|
|
|
substituteInPlace packaging/linux/sunshine.desktop \
|
|
--replace '@PROJECT_NAME@' 'Sunshine' \
|
|
--replace '@PROJECT_DESCRIPTION@' 'Self-hosted game stream host for Moonlight'
|
|
'';
|
|
|
|
preBuild = ''
|
|
# copy node_modules where they can be picked up by build
|
|
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 ]}
|
|
'';
|
|
|
|
postInstall = ''
|
|
install -Dm644 ../packaging/linux/${pname}.desktop $out/share/applications/${pname}.desktop
|
|
'';
|
|
|
|
passthru.updateScript = ./updater.sh;
|
|
|
|
meta = with lib; {
|
|
description = "Sunshine is a Game stream host for Moonlight";
|
|
homepage = "https://github.com/LizardByte/Sunshine";
|
|
license = licenses.gpl3Only;
|
|
mainProgram = "sunshine";
|
|
maintainers = with maintainers; [ devusb ];
|
|
platforms = platforms.linux;
|
|
};
|
|
}
|