Skip to content

Commit

Permalink
kodi: use mkDerivation with finalAttrs
Browse files Browse the repository at this point in the history
This pattern allows for easier overriding of the derivations attributes like
described and discussed in NixOS#119942.

In this context
- adapt the handling of the version and revision handling so overriding it gets
  reflected in the version string that kodi displays in the UI
- make the bundled dependencies available for overriding
  • Loading branch information
dwagenk authored and nvmd committed Mar 13, 2024
1 parent ba0b243 commit 7fabf06
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions pkgs/applications/video/kodi/unwrapped.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,11 @@ assert usbSupport -> !udevSupport; # libusb-compat-0_1 won't be used if udev is
assert gbmSupport || waylandSupport || x11Support;

let
kodiReleaseDate = "20240302";
kodiVersion = "20.5";
rel = "Nexus";

kodi_src = fetchFromGitHub {
owner = "xbmc";
repo = "xbmc";
rev = "${kodiVersion}-${rel}";
hash = "sha256-R/tzk3ZarJ4BTR312p2lTLezeCEsqdQH54ROsNIoJZA=";
};

# see https://github.com/xbmc/xbmc/blob/${kodiVersion}-${rel}/tools/depends/target/ to get suggested versions for all dependencies

# kodi 20.0 moved to ffmpeg 5, *but* there is a bug making the compilation fail which will
# only been fixed in kodi 21, so stick to ffmpeg 4 for now
ffmpeg = stdenv.mkDerivation rec {
ffmpeg = (kodi_src: rel: stdenv.mkDerivation rec {
pname = "kodi-ffmpeg";
version = "4.4.1";
src = fetchFromGitHub {
Expand Down Expand Up @@ -87,7 +76,7 @@ let
buildInputs = [ libidn2 libtasn1 p11-kit zlib libva ]
++ lib.optional vdpauSupport libvdpau;
nativeBuildInputs = [ cmake nasm pkg-config gnutls ];
};
});

# We can build these externally but FindLibDvd.cmake forces us to build it
# them, so we currently just use them for the src.
Expand Down Expand Up @@ -116,11 +105,23 @@ let
++ lib.optional waylandSupport "wayland"
++ lib.optional x11Support "x11";

in stdenv.mkDerivation {
in stdenv.mkDerivation (finalAttrs: {
pname = "kodi";
version = kodiVersion;
version = "20.5";
kodiReleaseName = "Nexus";

src = fetchFromGitHub {
owner = "xbmc";
repo = "xbmc";
rev = "${finalAttrs.version}-${finalAttrs.kodiReleaseName}";
hash = "sha256-R/tzk3ZarJ4BTR312p2lTLezeCEsqdQH54ROsNIoJZA=";
};

# make derivations declared in the let binding available here, so
# they can be overridden
inherit libdvdcss libdvdnav libdvdread;
ffmpeg = ffmpeg finalAttrs.src finalAttrs.kodiReleaseName;

src = kodi_src;
buildInputs = [
gnutls libidn2 libtasn1 nasm p11-kit
libxml2 python3Packages.python
Expand All @@ -139,7 +140,7 @@ in stdenv.mkDerivation {
libxcrypt libgcrypt libgpg-error libunistring
libcrossguid libplist
bluez giflib glib harfbuzz lcms2 libpthreadstubs
ffmpeg flatbuffers fstrcmp rapidjson
finalAttrs.ffmpeg flatbuffers fstrcmp rapidjson
lirc
mesa # for libEGL
]
Expand Down Expand Up @@ -189,10 +190,12 @@ in stdenv.mkDerivation {

cmakeFlags = [
"-DAPP_RENDER_SYSTEM=${if gbmSupport then "gles" else "gl"}"
"-Dlibdvdcss_URL=${libdvdcss}"
"-Dlibdvdnav_URL=${libdvdnav}"
"-Dlibdvdread_URL=${libdvdread}"
"-DGIT_VERSION=${kodiReleaseDate}"
"-Dlibdvdcss_URL=${finalAttrs.libdvdcss}"
"-Dlibdvdnav_URL=${finalAttrs.libdvdnav}"
"-Dlibdvdread_URL=${finalAttrs.libdvdread}"
# 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"
Expand Down Expand Up @@ -257,7 +260,8 @@ in stdenv.mkDerivation {

passthru = {
pythonPackages = python3Packages;
ffmpeg = ffmpeg;
ffmpeg = finalAttrs.ffmpeg;
kodi = finalAttrs.finalPackage;
};

meta = with lib; {
Expand All @@ -267,4 +271,4 @@ in stdenv.mkDerivation {
platforms = platforms.linux;
maintainers = teams.kodi.members;
};
}
})

0 comments on commit 7fabf06

Please sign in to comment.