1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
{ 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
, miniupnpc
, config
, cudaSupport ? config.cudaSupport
, cudaPackages ? { }
}:
let
stdenv' = if cudaSupport then cudaPackages.backendStdenv else stdenv;
in
stdenv'.mkDerivation rec {
pname = "sunshine";
version = "0.22.2";
src = fetchFromGitHub {
owner = "LizardByte";
repo = "Sunshine";
rev = "v${version}";
sha256 = "sha256-So8fX0XQoW2cdTWWENoE07EU6e8vvjeTpizLoaDTjeg=";
fetchSubmodules = true;
};
patches = [
# remove npm install as it needs internet access -- handled separately below
./dont-build-webui.patch
];
# build webui
ui = buildNpmPackage {
inherit src version;
pname = "sunshine-ui";
npmDepsHash = "sha256-0487ntbJZ20MZHezQ+Z3EJkidF3Dgoh/mynYwR7k/+I=";
# 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 * $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
miniupnpc
] ++ lib.optionals cudaSupport [
cudaPackages.cudatoolkit
] ++ lib.optionals stdenv.isx86_64 [
intel-media-sdk
];
runtimeDependencies = [
avahi
mesa
xorg.libXrandr
libxcb
libglvnd
];
cmakeFlags = [
"-Wno-dev"
# upstream tries to use systemd and udev packages to find these directories in FHS; set the paths explicitly instead
(lib.cmakeFeature "UDEV_RULES_INSTALL_DIR" "lib/udev/rules.d")
(lib.cmakeFeature "SYSTEMD_USER_UNIT_INSTALL_DIR" "lib/systemd/user")
];
postPatch = ''
# remove upstream dependency on systemd and udev
substituteInPlace cmake/packaging/linux.cmake \
--replace-fail 'find_package(Systemd)' "" \
--replace-fail 'find_package(Udev)' ""
substituteInPlace packaging/linux/sunshine.desktop \
--subst-var-by PROJECT_NAME 'Sunshine' \
--subst-var-by PROJECT_DESCRIPTION 'Self-hosted game stream host for Moonlight' \
--replace-fail '/usr/bin/env systemctl start --u sunshine' 'sunshine'
substituteInPlace packaging/linux/sunshine.service.in \
--subst-var-by PROJECT_DESCRIPTION 'Self-hosted game stream host for Moonlight' \
--subst-var-by SUNSHINE_EXECUTABLE_PATH $out/bin/sunshine
'';
preBuild = ''
# copy webui where it can be picked up by build
cp -r ${ui}/build ../
'';
# 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;
};
}
|