47 , cudaSupport ? config.cudaSupport
51 stdenv' = if cudaSupport then cudaPackages.backendStdenv else stdenv;
53 stdenv'.mkDerivation rec {
57 src = fetchFromGitHub {
61 hash = "sha256-D5ee5m2ZTKVqZDH07nzJuFEbZBQ4xW7m4nYnJQe0EaA=";
62 fetchSubmodules = true;
66 # fix(upnp): support newer miniupnpc library (#2782)
67 # Manually cherry-picked on to 0.23.1.
68 ./0001-fix-upnp-support-newer-miniupnpc-library-2782.patch
72 ui = buildNpmPackage {
74 pname = "sunshine-ui";
75 npmDepsHash = "sha256-9FuMtxTwrU9UIhZXQn/tmGN0IHZBdunV0cY/EElj4bA=";
77 # use generated package-lock.json as upstream does not provide one
79 cp ${./package-lock.json} ./package-lock.json
93 # Avoid fighting upstream's usage of vendored ffmpeg libraries
95 ] ++ lib.optionals cudaSupport [
138 ] ++ lib.optionals cudaSupport [
139 cudaPackages.cudatoolkit
140 ] ++ lib.optionals stdenv.isx86_64 [
144 runtimeDependencies = [
154 # upstream tries to use systemd and udev packages to find these directories in FHS; set the paths explicitly instead
155 (lib.cmakeFeature "UDEV_RULES_INSTALL_DIR" "lib/udev/rules.d")
156 (lib.cmakeFeature "SYSTEMD_USER_UNIT_INSTALL_DIR" "lib/systemd/user")
160 # remove upstream dependency on systemd and udev
161 substituteInPlace cmake/packaging/linux.cmake \
162 --replace-fail 'find_package(Systemd)' "" \
163 --replace-fail 'find_package(Udev)' ""
165 substituteInPlace packaging/linux/sunshine.desktop \
166 --subst-var-by PROJECT_NAME 'Sunshine' \
167 --subst-var-by PROJECT_DESCRIPTION 'Self-hosted game stream host for Moonlight' \
168 --replace-fail '/usr/bin/env systemctl start --u sunshine' 'sunshine'
170 substituteInPlace packaging/linux/sunshine.service.in \
171 --subst-var-by PROJECT_DESCRIPTION 'Self-hosted game stream host for Moonlight' \
172 --subst-var-by SUNSHINE_EXECUTABLE_PATH $out/bin/sunshine
176 # copy webui where it can be picked up by build
177 cp -r ${ui}/build ../
184 # allow Sunshine to find libvulkan
185 postFixup = lib.optionalString cudaSupport ''
186 wrapProgram $out/bin/sunshine \
187 --set LD_LIBRARY_PATH ${lib.makeLibraryPath [ vulkan-loader ]}
190 # redefine installPhase to avoid attempt to build webui
198 install -Dm644 ../packaging/linux/${pname}.desktop $out/share/applications/${pname}.desktop
202 tests.sunshine = nixosTests.sunshine;
203 updateScript = ./updater.sh;
207 description = "Sunshine is a Game stream host for Moonlight";
208 homepage = "https://github.com/LizardByte/Sunshine";
209 license = licenses.gpl3Only;
210 mainProgram = "sunshine";
211 maintainers = with maintainers; [ devusb ];
212 platforms = platforms.linux;