I’m not quite sure what you mean by that. Are you taking the entire source code of kodi and attempting to build the subprojects from that? How?
How are you injecting it into the main drv? It needs to be built with the buildPackages stdenv and inputs.
That only works in a spliced package set. If you e.g. manually callPackage it, you’ll simply get the pkgsHostTarget version (“buildInputs”). You need to manually select the appropriate one.
What you want to do is have one separate derviation for each dependency. Then figure out how that dependency is actually used and use the correct callPackage on it (either from pkgsBuildBuild or the regular one that you get injected via function arguments (from pkgsHostTarget).
You’re right, it was a good idea to just have a separate derivation for each one and especially to bypass Kodi’s weird thing where it has one overarching configure for all of their vendored dependencies… I had to apply a few hacks but I’ve got it mostly working.
Right now both of the subderivations are let-clauses over the kodi derivation:
let
jsonSchemaBuilder = buildPackages.stdenv.mkDerivation (...
texturePacker = buildPackages.stdenv.mkDerivation (...
in
stdenv.mkDerivation(... kodi stuff
And with some careful application of buildPackages in the correct places (i.e. texturePacker buildInputs to make sure they’re the correct architecture) this seems to work!
Both TexturePacker and JsonSchemaBuilder build now, and seem to be detected correctly by the Kodi build process:
-- Found JsonSchemaBuilder: /nix/store/k258csan82assjxyr0q11xidsl3wachi-kodi-jsonSchemaBuilder-21.0/bin/JsonSchemaBuilder
-- Found external TexturePacker: /nix/store/mcdja9qhq6sjanqdjfvwzln6mwbjw4ps-kodi-texturePacker-21.0/bin/TexturePacker
… However, that build process still fails at the end with this extremely unhelpful error:
The logs before it don’t really say anything, and there’s no Makefile I can go take a look at as it’s generated by CMake. Presumably something is missing, but I don’t know what it is or could be. So, it’s sadly still not working
Hopefully I can figure it out, but right now I don’t even know how I can even debug this…
Please paste the full log somewhere. Actual errors can be quite far away from the notorious makefile error.
Also scour the source and build directories for log files where the make invocation(?)'s log might have been sent to. I think cmake puts its logs somewhere (perhaps more verbose too?).
Please also make doubly sure that you have built the sub-projects for all architectures required and that you have put them into the right places. Things built for the buildPlatform go in nativeBuildInputs and things built for the hostPlatform go in buildInputs; never the other way around.
This includes looking into whether they’re used during the build, at runtime or both. This is the most critical to get right because otherwise it might do something stupid like attempting to link an x86 binary against an armv7 one which will obviously fail. Double check that all generated artifacts in the build dir are indeed armv7 ELFs.
Yes, I forgot to actually search the log for “error” (it is very late here). It seems that the direct issue is that java is not of the correct architecture. This is doubly confusing because jre_headless only occurs in nativeBuildInputs, so I’m not sure why I’m getting an ARM Java as a dependency.
I believe they’re only necessary at build-time, so in this case the hostPlatform of the vendored dependencies x86_64, whereas the hostPlatform of Kodi itself is armv7l. This is why I had to do the hacky thing with making the buildInputs for TexturePacker look like this:
If I don’t use this hack, it tries to link armv7 libraries (hostPlatform of Kodi) against x86 executables (hostPlatform of TexturePacker) and it goes wrong. But if my assumption is wrong and I do need these dependencies at runtime, then I am pretty sure this won’t work. So you’re right that it would be better to factor them out into separate packages and call them with callPackage to prevent the dependency mixing that’s happening here.
Also, I just looked at a random cmake file in Kodi and saw this:
# TexturePacker::TexturePacker::Executable - The TexturePacker executable participating in build
# TexturePacker::TexturePacker::Installable - The TexturePacker executable shipped in the Kodi package
Taking jre_headless from buildPackages was the final thing needed to make it work! The TexturePacker::Installable thing ended up not being an issue after all, as Kodi somehow ships an ‘internal’ TexturePacker.
So now I (finally) have it all working and have made a PR to nixpkgs: Fix kodi crosscompile by gcoremans · Pull Request #362865 · NixOS/nixpkgs · GitHub . I’ve tried to clean up my code as much as possible. (including factoring out the two dependencies into separate packages so I can avoid the buildPackages in buildInputs hack)
Still need to actually test it on my rpi 2b, so hopefully it’ll work.