47 , cudaSupport ? config.cudaSupport
51 stdenv' = if cudaSupport then cudaPackages.backendStdenv else stdenv;
53 stdenv'.mkDerivation rec {
57 src = fetchFromGitHub {
61 sha256 = "sha256-K43LZ7zouTRUI4xhiHuRzu2tN7mUl1nTapuR34JR/Ac=";
62 fetchSubmodules = true;
66 # remove npm install as it needs internet access -- handled separately below
67 ./dont-build-webui.patch
71 ui = buildNpmPackage {
73 pname = "sunshine-ui";
74 npmDepsHash = "sha256-I7IrCR7eQ97a8cPB8F8+T0zX8iJcwh+YtZ9QRtEVZtI=";
76 # use generated package-lock.json as upstream does not provide one
78 cp ${./package-lock.json} ./package-lock.json
92 # Avoid fighting upstream's usage of vendored ffmpeg libraries
94 ] ++ lib.optionals cudaSupport [
137 ] ++ lib.optionals cudaSupport [
138 cudaPackages.cudatoolkit
139 ] ++ lib.optionals stdenv.isx86_64 [
143 runtimeDependencies = [
153 # upstream tries to use systemd and udev packages to find these directories in FHS; set the paths explicitly instead
154 (lib.cmakeFeature "UDEV_RULES_INSTALL_DIR" "lib/udev/rules.d")
155 (lib.cmakeFeature "SYSTEMD_USER_UNIT_INSTALL_DIR" "lib/systemd/user")
159 # remove upstream dependency on systemd and udev
160 substituteInPlace cmake/packaging/linux.cmake \
161 --replace-fail 'find_package(Systemd)' "" \
162 --replace-fail 'find_package(Udev)' ""
164 substituteInPlace packaging/linux/sunshine.desktop \
165 --subst-var-by PROJECT_NAME 'Sunshine' \
166 --subst-var-by PROJECT_DESCRIPTION 'Self-hosted game stream host for Moonlight' \
167 --replace-fail '/usr/bin/env systemctl start --u sunshine' 'sunshine'
169 substituteInPlace packaging/linux/sunshine.service.in \
170 --subst-var-by PROJECT_DESCRIPTION 'Self-hosted game stream host for Moonlight' \
171 --subst-var-by SUNSHINE_EXECUTABLE_PATH $out/bin/sunshine
175 # copy webui where it can be picked up by build
176 cp -r ${ui}/build ../
179 # allow Sunshine to find libvulkan
180 postFixup = lib.optionalString cudaSupport ''
181 wrapProgram $out/bin/sunshine \
182 --set LD_LIBRARY_PATH ${lib.makeLibraryPath [ vulkan-loader ]}
186 install -Dm644 ../packaging/linux/${pname}.desktop $out/share/applications/${pname}.desktop
190 tests.sunshine = nixosTests.sunshine;
191 updateScript = ./updater.sh;
195 description = "Sunshine is a Game stream host for Moonlight";
196 homepage = "https://github.com/LizardByte/Sunshine";
197 license = licenses.gpl3Only;
198 mainProgram = "sunshine";
199 maintainers = with maintainers; [ devusb ];
200 platforms = platforms.linux;