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
|
{ 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.autoAddOpenGLRunpathHook
];
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;
maintainers = with maintainers; [ devusb ];
platforms = platforms.linux;
};
}
|