Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions pkgs/servers/sunshine/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, callPackage
, fetchFromGitHub
, fetchurl
, fetchpatch
, autoPatchelfHook
, makeWrapper
, buildNpmPackage
Expand All @@ -29,6 +30,7 @@
, amf-headers
, svt-av1
, vulkan-loader
, libappindicator
, cudaSupport ? false
, cudaPackages ? {}
}:
Expand All @@ -42,28 +44,35 @@ let
in
stdenv.mkDerivation rec {
pname = "sunshine";
version = "0.18.4";
version = "0.19.1";

src = fetchFromGitHub {
owner = "LizardByte";
repo = "Sunshine";
rev = "v${version}";
sha256 = "sha256-nPUWBka/fl1oTB0vTv6qyL7EHh7ptFnxwfV/jYtloTc=";
sha256 = "sha256-fifwctVrSkAcMK8juAirIbIP64H7GKEwC+sUR/U6Q3Y=";
fetchSubmodules = true;
};

# remove pre-built ffmpeg; use ffmpeg from nixpkgs
patches = [ ./ffmpeg.diff ];
patches = [
./ffmpeg.diff
# fix for X11 not being added to libraries unless prebuilt FFmpeg is used: https://github.com/LizardByte/Sunshine/pull/1166
(fetchpatch {
url = "https://github.com/LizardByte/Sunshine/commit/a067da6cae72cf36f76acc06fcf1e814032af886.patch";
sha256 = "sha256-HMxM7luiFBEmFkvQtkdAMMSjAaYPEFX3LL0T/ActUhM=";
})
];

# fetch node_modules needed for webui
ui = buildNpmPackage {
inherit src version;
pname = "sunshine-ui";
npmDepsHash = "sha256-k8Vfi/57AbGxYFPYSNh8bv4KqHnZjk3BDp8SJQHzuR8=";
npmDepsHash = "sha256-sdwvM/Irejo8DgMHJWWCxwOykOK9foqLFFd/tuzrkxI=";

dontNpmBuild = true;

# use generated package-lock.json upstream does not provide one
# use generated package-lock.json as upstream does not provide one
postPatch = ''
cp ${./package-lock.json} ./package-lock.json
'';
Expand Down Expand Up @@ -94,6 +103,7 @@ stdenv.mkDerivation rec {
xorg.libXfixes
xorg.libXrandr
xorg.libXtst
xorg.libXi
openssl
libopus
boost
Expand All @@ -110,6 +120,7 @@ stdenv.mkDerivation rec {
mesa
amf-headers
svt-av1
libappindicator
] ++ lib.optionals cudaSupport [
cudaPackages.cudatoolkit
];
Expand All @@ -121,21 +132,18 @@ stdenv.mkDerivation rec {
libxcb
];

CXXFLAGS = [
"-Wno-format-security"
];
CFLAGS = [
"-Wno-format-security"
];

cmakeFlags = [
"-Wno-dev"
];

postPatch = ''
# fix hardcoded libevdev path
# fix hardcoded libevdev and icon path
substituteInPlace CMakeLists.txt \
--replace '/usr/include/libevdev-1.0' '${libevdev}/include/libevdev-1.0'
--replace '/usr/include/libevdev-1.0' '${libevdev}/include/libevdev-1.0' \
--replace '/usr/share' "$out/share"

substituteInPlace packaging/linux/sunshine.desktop \
--replace '@PROJECT_NAME@' 'Sunshine'

# add FindFFMPEG to source tree
cp ${findFfmpeg} cmake/FindFFMPEG.cmake
Expand All @@ -153,6 +161,12 @@ stdenv.mkDerivation rec {
--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";
Expand Down
42 changes: 9 additions & 33 deletions pkgs/servers/sunshine/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions pkgs/servers/sunshine/updater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p gnugrep gnused coreutils curl wget jq nix-update prefetch-npm-deps nodejs

set -euo pipefail
pushd "$(dirname "${BASH_SOURCE[0]}")"

version=$(curl -s "https://api.github.com/repos/LizardByte/sunshine/tags" | jq -r .[0].name | grep -oP "^v\K.*")
url="https://raw.githubusercontent.com/LizardByte/sunshine/v$version/"

if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
echo "Already up to date!"
exit 0
fi

rm -f package-lock.json package.json
wget "$url/package.json"
npm i --package-lock-only
npm_hash=$(prefetch-npm-deps package-lock.json)
sed -i 's#npmDepsHash = "[^"]*"#npmDepsHash = "'"$npm_hash"'"#' default.nix
rm -f package.json

popd
nix-update sunshine --version $version