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 Oct 7, 2023
1 parent 8a4c174 commit d7f6169
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions pkgs/applications/video/kodi/unwrapped.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,9 @@ assert usbSupport -> !udevSupport; # libusb-compat-0_1 won't be used if udev is
assert gbmSupport || waylandSupport || x11Support;

let
kodiReleaseDate = "20230312";
kodiVersion = "20.1";
rel = "Nexus";

kodi_src = fetchFromGitHub {
owner = "xbmc";
repo = "xbmc";
rev = "${kodiVersion}-${rel}";
hash = "sha256-2nwjW0MYrMVk+dllrAv9yn+YNA6/loZzoK8mbFIZ8Xs=";
};

# 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 All @@ -76,7 +63,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 @@ -105,11 +92,22 @@ let
++ lib.optional waylandSupport "wayland"
++ lib.optional x11Support "x11";

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

src = fetchFromGitHub {
owner = "xbmc";
repo = "xbmc";
rev = "${finalAttrs.version}-${finalAttrs.kodiReleaseName}";
hash = "sha256-2nwjW0MYrMVk+dllrAv9yn+YNA6/loZzoK8mbFIZ8Xs=";
};

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

buildInputs = [
gnutls libidn2 libtasn1 nasm p11-kit
Expand All @@ -129,7 +127,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 @@ -178,10 +176,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 @@ -246,7 +246,8 @@ in stdenv.mkDerivation {

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

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

0 comments on commit d7f6169

Please sign in to comment.