buildDartApplication: Generate LD_LIBRARY_PATH at build time

This allows setup hooks to add runtime dependencies.

authored by hacker1024 and committed by FlafyDev cf55bc73 1ae96d07

+8 -5
+2 -2
pkgs/build-support/dart/build-dart-application/default.nix
··· 89 89 baseDerivation = stdenv.mkDerivation (finalAttrs: (builtins.removeAttrs args [ "gitHashes" "sdkSourceBuilders" "pubspecLock" ]) // { 90 90 inherit pubspecLockFile packageConfig sdkSetupScript pubGetScript 91 91 dartCompileCommand dartOutputType dartRuntimeCommand dartCompileFlags 92 - dartJitFlags runtimeDependencies; 92 + dartJitFlags; 93 93 94 94 outputs = args.outputs or [ ] ++ [ "out" "pubcache" ]; 95 95 ··· 98 98 then writeText "entrypoints.json" (builtins.toJSON dartEntryPoints) 99 99 else null; 100 100 101 - runtimeDependencyLibraryPath = lib.makeLibraryPath finalAttrs.runtimeDependencies; 101 + runtimeDependencies = map lib.getLib runtimeDependencies; 102 102 103 103 nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ 104 104 dart
+6 -3
pkgs/build-support/dart/build-dart-application/hooks/dart-fixup-hook.sh
··· 10 10 # 11 11 # This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately, 12 12 # which is not what application authors expect. 13 - echo "$runtimeDependencyLibraryPath" 14 - if [[ ! -z "$runtimeDependencyLibraryPath" ]]; then 15 - wrapProgramArgs+=(--suffix LD_LIBRARY_PATH : \"$runtimeDependencyLibraryPath\") 13 + APPLICATION_LD_LIBRARY_PATH="" 14 + for runtimeDependency in "${runtimeDependencies[@]}"; do 15 + addToSearchPath APPLICATION_LD_LIBRARY_PATH "${runtimeDependency}/lib" 16 + done 17 + if [[ ! -z "$APPLICATION_LD_LIBRARY_PATH" ]]; then 18 + wrapProgramArgs+=(--suffix LD_LIBRARY_PATH : \"$APPLICATION_LD_LIBRARY_PATH\") 16 19 fi 17 20 18 21 if [[ ! -z "$extraWrapProgramArgs" ]]; then