buildDartApplication: Generate LD_LIBRARY_PATH at build time

This allows setup hooks to add runtime dependencies.
This commit is contained in:
hacker1024 2023-10-29 00:46:29 +11:00 committed by FlafyDev
parent 1ae96d0704
commit cf55bc7300
2 changed files with 8 additions and 5 deletions

View file

@ -89,7 +89,7 @@ let
baseDerivation = stdenv.mkDerivation (finalAttrs: (builtins.removeAttrs args [ "gitHashes" "sdkSourceBuilders" "pubspecLock" ]) // {
inherit pubspecLockFile packageConfig sdkSetupScript pubGetScript
dartCompileCommand dartOutputType dartRuntimeCommand dartCompileFlags
dartJitFlags runtimeDependencies;
dartJitFlags;
outputs = args.outputs or [ ] ++ [ "out" "pubcache" ];
@ -98,7 +98,7 @@ let
then writeText "entrypoints.json" (builtins.toJSON dartEntryPoints)
else null;
runtimeDependencyLibraryPath = lib.makeLibraryPath finalAttrs.runtimeDependencies;
runtimeDependencies = map lib.getLib runtimeDependencies;
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
dart

View file

@ -10,9 +10,12 @@ dartFixupHook() {
#
# This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately,
# which is not what application authors expect.
echo "$runtimeDependencyLibraryPath"
if [[ ! -z "$runtimeDependencyLibraryPath" ]]; then
wrapProgramArgs+=(--suffix LD_LIBRARY_PATH : \"$runtimeDependencyLibraryPath\")
APPLICATION_LD_LIBRARY_PATH=""
for runtimeDependency in "${runtimeDependencies[@]}"; do
addToSearchPath APPLICATION_LD_LIBRARY_PATH "${runtimeDependency}/lib"
done
if [[ ! -z "$APPLICATION_LD_LIBRARY_PATH" ]]; then
wrapProgramArgs+=(--suffix LD_LIBRARY_PATH : \"$APPLICATION_LD_LIBRARY_PATH\")
fi
if [[ ! -z "$extraWrapProgramArgs" ]]; then