kodi: package build-time tools separately (#404040)

This commit is contained in:
Colin 2025-06-02 00:47:58 +00:00 committed by GitHub
commit 184cf80254
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -186,294 +186,343 @@ let
lib.optional gbmSupport "gbm" lib.optional gbmSupport "gbm"
++ lib.optional waylandSupport "wayland" ++ lib.optional waylandSupport "wayland"
++ lib.optional x11Support "x11"; ++ lib.optional x11Support "x11";
in in
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (
pname = "kodi"; finalAttrs:
version = "21.2"; let
kodiReleaseName = "Omega"; texturePacker = buildPackages.callPackage (
{
cmake,
giflib,
libjpeg,
libpng,
lzo,
stdenv,
zlib,
pkg-config,
}:
stdenv.mkDerivation {
pname = finalAttrs.pname + "-build-tool-texture-packer";
inherit (finalAttrs) version src;
src = fetchFromGitHub { sourceRoot = "${finalAttrs.src.name}/tools/depends/native/TexturePacker/src";
owner = "xbmc";
repo = "xbmc";
rev = "${finalAttrs.version}-${finalAttrs.kodiReleaseName}";
hash = "sha256-RdTJcq6FPerQx05dU3r8iyaorT4L7162hg5RdywsA88=";
};
patches = [ nativeBuildInputs = [
# Backport to fix build with Pipewire 1.4 pkg-config
# FIXME: remove in the next update cmake
(fetchpatch { ];
url = "https://github.com/xbmc/xbmc/commit/269053ebbfd3cc4a3156a511f54ab7f08a09a730.patch";
hash = "sha256-JzzrMJvAufrxTxtWnzknUS9JLJEed+qdtVnIYYe9LCw=";
})
];
# make derivations declared in the let binding available here, so buildInputs = [
# they can be overridden giflib
inherit libjpeg
libdvdcss libpng
libdvdnav lzo
libdvdread zlib
groovy ];
apache_commons_lang
apache_commons_text
;
buildInputs = env.NIX_CFLAGS_COMPILE = lib.optionalString (!stdenv.hostPlatform.isWindows) "-DTARGET_POSIX";
[
gnutls preConfigure = ''
libidn2 cmakeFlagsArray+=(-DKODI_SOURCE_DIR=$src -DCMAKE_MODULE_PATH=$src/cmake/modules)
libtasn1 '';
nasm
p11-kit meta.mainProgram = "TexturePacker";
libxml2 }
python3Packages.python ) { };
boost
libmicrohttpd jsonSchemaBuilder = buildPackages.callPackage (
gettext { stdenv, cmake }:
pcre-cpp stdenv.mkDerivation {
yajl pname = finalAttrs.pname + "-build-tool-json-schema-builder";
fribidi inherit (finalAttrs) version src;
libva
libdrm sourceRoot = "${finalAttrs.src.name}/tools/depends/native/JsonSchemaBuilder/src";
openssl
gperf nativeBuildInputs = [ cmake ];
tinyxml2
tinyxml-2 meta.mainProgram = "JsonSchemaBuilder";
taglib }
libssh ) { };
gtest in
ncurses {
spdlog pname = "kodi";
alsa-lib version = "21.2";
libGL kodiReleaseName = "Omega";
libGLU
fontconfig src = fetchFromGitHub {
freetype owner = "xbmc";
ftgl repo = "xbmc";
libjpeg rev = "${finalAttrs.version}-${finalAttrs.kodiReleaseName}";
libpng hash = "sha256-RdTJcq6FPerQx05dU3r8iyaorT4L7162hg5RdywsA88=";
libtiff };
libmpeg2
libsamplerate patches = [
libmad # Backport to fix build with Pipewire 1.4
libogg # FIXME: remove in the next update
libvorbis (fetchpatch {
flac url = "https://github.com/xbmc/xbmc/commit/269053ebbfd3cc4a3156a511f54ab7f08a09a730.patch";
libxslt hash = "sha256-JzzrMJvAufrxTxtWnzknUS9JLJEed+qdtVnIYYe9LCw=";
systemd })
lzo
libcdio
libmodplug
libass
libbluray
libudfread
sqlite
libmysqlclient
avahi
lame
curl
bzip2
zip
unzip
mesa-demos
libcec
libcec_platform
dcadec
libuuid
libxcrypt
libgcrypt
libgpg-error
libunistring
libcrossguid
libplist
bluez
giflib
glib
harfbuzz
lcms2
libpthreadstubs
ffmpeg
flatbuffers
fstrcmp
rapidjson
lirc
mesa-gl-headers
]
++ lib.optionals x11Support [
libX11
xorgproto
libXt
libXmu
libXext.dev
libXdmcp
libXinerama
libXrandr.dev
libXtst
libXfixes
]
++ lib.optional dbusSupport dbus
++ lib.optional joystickSupport cwiid
++ lib.optional nfsSupport libnfs
++ lib.optional pulseSupport libpulseaudio
++ lib.optional pipewireSupport pipewire
++ lib.optional rtmpSupport rtmpdump
++ lib.optional sambaSupport samba
++ lib.optional udevSupport udev
++ lib.optional usbSupport libusb-compat-0_1
++ lib.optional vdpauSupport libvdpau
++ lib.optionals waylandSupport [
wayland
waylandpp.dev
wayland-protocols
# Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
libxkbcommon.dev
]
++ lib.optionals gbmSupport [
libxkbcommon.dev
libgbm
libinput.dev
libdisplay-info
]; ];
nativeBuildInputs = # make derivations declared in the let binding available here, so
[ # they can be overridden
cmake inherit
doxygen libdvdcss
makeWrapper libdvdnav
which libdvdread
pkg-config groovy
autoconf apache_commons_lang
automake apache_commons_text
libtool # still needed for some components. Check if that is the case with 19.0 ;
jre_headless
yasm
gettext
python3Packages.python
flatbuffers
# for TexturePacker buildInputs =
giflib [
zlib gnutls
libpng libidn2
libjpeg libtasn1
lzo nasm
] p11-kit
++ lib.optionals waylandSupport [ libxml2
wayland-protocols python3Packages.python
waylandpp.bin boost
libmicrohttpd
gettext
pcre-cpp
yajl
fribidi
libva
libdrm
openssl
gperf
tinyxml2
tinyxml-2
taglib
libssh
gtest
ncurses
spdlog
alsa-lib
libGL
libGLU
fontconfig
freetype
ftgl
libjpeg
libpng
libtiff
libmpeg2
libsamplerate
libmad
libogg
libvorbis
flac
libxslt
systemd
lzo
libcdio
libmodplug
libass
libbluray
libudfread
sqlite
libmysqlclient
avahi
lame
curl
bzip2
zip
unzip
mesa-demos
libcec
libcec_platform
dcadec
libuuid
libxcrypt
libgcrypt
libgpg-error
libunistring
libcrossguid
libplist
bluez
glib
harfbuzz
lcms2
libpthreadstubs
ffmpeg
flatbuffers
fstrcmp
rapidjson
lirc
mesa-gl-headers
# Deps needed by TexturePacker, which is built and installed in normal
# kodi build, however the one used during the build is not this one
# in order to support cross-compilation.
giflib
zlib
]
++ lib.optionals x11Support [
libX11
xorgproto
libXt
libXmu
libXext.dev
libXdmcp
libXinerama
libXrandr.dev
libXtst
libXfixes
]
++ lib.optional dbusSupport dbus
++ lib.optional joystickSupport cwiid
++ lib.optional nfsSupport libnfs
++ lib.optional pulseSupport libpulseaudio
++ lib.optional pipewireSupport pipewire
++ lib.optional rtmpSupport rtmpdump
++ lib.optional sambaSupport samba
++ lib.optional udevSupport udev
++ lib.optional usbSupport libusb-compat-0_1
++ lib.optional vdpauSupport libvdpau
++ lib.optionals waylandSupport [
wayland
waylandpp.dev
wayland-protocols
# Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
libxkbcommon.dev
]
++ lib.optionals gbmSupport [
libxkbcommon.dev
libgbm
libinput.dev
libdisplay-info
];
nativeBuildInputs =
[
cmake
doxygen
makeWrapper
which
pkg-config
autoconf
automake
libtool # still needed for some components. Check if that is the case with 19.0
jre_headless
yasm
gettext
python3Packages.python
flatbuffers
]
++ lib.optionals waylandSupport [
wayland-protocols
waylandpp.bin
];
depsBuildBuild = [
buildPackages.stdenv.cc
]; ];
depsBuildBuild = [ cmakeFlags =
buildPackages.stdenv.cc [
]; "-DAPP_RENDER_SYSTEM=${if gbmSupport then "gles" else "gl"}"
"-Dlibdvdcss_URL=${finalAttrs.libdvdcss}"
"-Dlibdvdnav_URL=${finalAttrs.libdvdnav}"
"-Dlibdvdread_URL=${finalAttrs.libdvdread}"
"-Dgroovy_SOURCE_DIR=${finalAttrs.groovy}"
"-Dapache-commons-lang_SOURCE_DIR=${finalAttrs.apache_commons_lang}"
"-Dapache-commons-text_SOURCE_DIR=${finalAttrs.apache_commons_text}"
# Upstream derives this from the git HEADs hash and date.
# LibreElec (minimal distro for kodi) uses the equivalent to this.
"-DGIT_VERSION=${finalAttrs.version}-${finalAttrs.kodiReleaseName}"
"-DENABLE_EVENTCLIENTS=ON"
"-DENABLE_INTERNAL_CROSSGUID=OFF"
"-DENABLE_INTERNAL_RapidJSON=OFF"
"-DENABLE_OPTICAL=${if opticalSupport then "ON" else "OFF"}"
"-DENABLE_VDPAU=${if vdpauSupport then "ON" else "OFF"}"
"-DLIRC_DEVICE=/run/lirc/lircd"
"-DSWIG_EXECUTABLE=${buildPackages.swig}/bin/swig"
"-DFLATBUFFERS_FLATC_EXECUTABLE=${buildPackages.flatbuffers}/bin/flatc"
"-DPYTHON_EXECUTABLE=${buildPackages.python3Packages.python}/bin/python"
"-DPYTHON_LIB_PATH=${python3Packages.python.sitePackages}"
"-DWITH_JSONSCHEMABUILDER=${lib.getExe jsonSchemaBuilder}"
# When wrapped KODI_HOME will likely contain symlinks to static assets
# that Kodi's built in webserver will cautiously refuse to serve up
# (because their realpaths are outside of KODI_HOME and the other
# whitelisted directories). This adds the entire nix store to the Kodi
# webserver whitelist to avoid this problem.
"-DKODI_WEBSERVER_EXTRA_WHITELIST=${builtins.storeDir}"
]
++ lib.optionals waylandSupport [
"-DWAYLANDPP_SCANNER=${buildPackages.waylandpp}/bin/wayland-scanner++"
]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DWITH_TEXTUREPACKER=${lib.getExe texturePacker}"
];
cmakeFlags = # 14 tests fail but the biggest issue is that every test takes 30 seconds -
[ # I'm guessing there is a thing waiting to time out
"-DAPP_RENDER_SYSTEM=${if gbmSupport then "gles" else "gl"}" doCheck = false;
"-Dlibdvdcss_URL=${finalAttrs.libdvdcss}"
"-Dlibdvdnav_URL=${finalAttrs.libdvdnav}"
"-Dlibdvdread_URL=${finalAttrs.libdvdread}"
"-Dgroovy_SOURCE_DIR=${finalAttrs.groovy}"
"-Dapache-commons-lang_SOURCE_DIR=${finalAttrs.apache_commons_lang}"
"-Dapache-commons-text_SOURCE_DIR=${finalAttrs.apache_commons_text}"
# Upstream derives this from the git HEADs hash and date.
# LibreElec (minimal distro for kodi) uses the equivalent to this.
"-DGIT_VERSION=${finalAttrs.version}-${finalAttrs.kodiReleaseName}"
"-DENABLE_EVENTCLIENTS=ON"
"-DENABLE_INTERNAL_CROSSGUID=OFF"
"-DENABLE_INTERNAL_RapidJSON=OFF"
"-DENABLE_OPTICAL=${if opticalSupport then "ON" else "OFF"}"
"-DENABLE_VDPAU=${if vdpauSupport then "ON" else "OFF"}"
"-DLIRC_DEVICE=/run/lirc/lircd"
"-DSWIG_EXECUTABLE=${buildPackages.swig}/bin/swig"
"-DFLATBUFFERS_FLATC_EXECUTABLE=${buildPackages.flatbuffers}/bin/flatc"
"-DPYTHON_EXECUTABLE=${buildPackages.python3Packages.python}/bin/python"
"-DPYTHON_LIB_PATH=${python3Packages.python.sitePackages}"
# When wrapped KODI_HOME will likely contain symlinks to static assets
# that Kodi's built in webserver will cautiously refuse to serve up
# (because their realpaths are outside of KODI_HOME and the other
# whitelisted directories). This adds the entire nix store to the Kodi
# webserver whitelist to avoid this problem.
"-DKODI_WEBSERVER_EXTRA_WHITELIST=${builtins.storeDir}"
]
++ lib.optionals waylandSupport [
"-DWAYLANDPP_SCANNER=${buildPackages.waylandpp}/bin/wayland-scanner++"
];
# 14 tests fail but the biggest issue is that every test takes 30 seconds - preConfigure = ''
# I'm guessing there is a thing waiting to time out
doCheck = false;
preConfigure =
''
cmakeFlagsArray+=("-DCORE_PLATFORM_NAME=${lib.concatStringsSep " " kodi_platforms}") cmakeFlagsArray+=("-DCORE_PLATFORM_NAME=${lib.concatStringsSep " " kodi_platforms}")
''
+ lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
# Need these tools on the build system when cross compiling,
# hacky, but have found no other way.
CXX=$CXX_FOR_BUILD LD=ld make -C tools/depends/native/JsonSchemaBuilder
appendToVar cmakeFlags "-DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"
CXX=$CXX_FOR_BUILD LD=ld make EXTRA_CONFIGURE= -C tools/depends/native/TexturePacker
appendToVar cmakeFlags "-DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
''; '';
postInstall = '' postInstall = ''
# TODO: figure out which binaries should be wrapped this way and which shouldn't # TODO: figure out which binaries should be wrapped this way and which shouldn't
for p in $(ls --ignore=kodi-send $out/bin/) ; do for p in $(ls --ignore=kodi-send $out/bin/) ; do
wrapProgram $out/bin/$p \ wrapProgram $out/bin/$p \
--prefix PATH ":" "${ --prefix PATH ":" "${
lib.makeBinPath ( lib.makeBinPath (
[ [
python3Packages.python python3Packages.python
mesa-demos mesa-demos
] ]
++ lib.optional x11Support xdpyinfo ++ lib.optional x11Support xdpyinfo
++ lib.optional sambaSupport samba ++ lib.optional sambaSupport samba
) )
}" \ }" \
--prefix LD_LIBRARY_PATH ":" "${ --prefix LD_LIBRARY_PATH ":" "${
lib.makeLibraryPath ( lib.makeLibraryPath (
[ [
curl curl
systemd systemd
libmad libmad
libcec libcec
libcec_platform libcec_platform
libass libass
] ]
++ lib.optional vdpauSupport libvdpau ++ lib.optional vdpauSupport libvdpau
++ lib.optional nfsSupport libnfs ++ lib.optional nfsSupport libnfs
++ lib.optional rtmpSupport rtmpdump ++ lib.optional rtmpSupport rtmpdump
) )
}" }"
done done
wrapProgram $out/bin/kodi-send \ wrapProgram $out/bin/kodi-send \
--prefix PYTHONPATH : $out/${python3Packages.python.sitePackages} --prefix PYTHONPATH : $out/${python3Packages.python.sitePackages}
substituteInPlace $out/share/xsessions/kodi.desktop \ substituteInPlace $out/share/xsessions/kodi.desktop \
--replace kodi-standalone $out/bin/kodi-standalone --replace kodi-standalone $out/bin/kodi-standalone
''; '';
doInstallCheck = true; doInstallCheck = true;
installCheckPhase = "$out/bin/kodi --version"; installCheckPhase = "$out/bin/kodi --version";
passthru = { passthru = {
pythonPackages = python3Packages; pythonPackages = python3Packages;
ffmpeg = ffmpeg; ffmpeg = ffmpeg;
kodi = finalAttrs.finalPackage; kodi = finalAttrs.finalPackage;
}; };
meta = with lib; { meta = with lib; {
description = "Media center"; description = "Media center";
homepage = "https://kodi.tv/"; homepage = "https://kodi.tv/";
license = licenses.gpl2Plus; license = licenses.gpl2Plus;
platforms = platforms.linux; platforms = platforms.linux;
teams = [ teams.kodi ]; teams = [ teams.kodi ];
mainProgram = "kodi"; mainProgram = "kodi";
}; };
}) }
)