From cf55bc7300560f63f4e76521dbd163a00b060769 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 29 Oct 2023 00:46:29 +1100 Subject: [PATCH] buildDartApplication: Generate LD_LIBRARY_PATH at build time This allows setup hooks to add runtime dependencies. --- .../dart/build-dart-application/default.nix | 4 ++-- .../dart/build-dart-application/hooks/dart-fixup-hook.sh | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/dart/build-dart-application/default.nix b/pkgs/build-support/dart/build-dart-application/default.nix index 6ddd4a07d992..2e99479c9bb0 100644 --- a/pkgs/build-support/dart/build-dart-application/default.nix +++ b/pkgs/build-support/dart/build-dart-application/default.nix @@ -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 diff --git a/pkgs/build-support/dart/build-dart-application/hooks/dart-fixup-hook.sh b/pkgs/build-support/dart/build-dart-application/hooks/dart-fixup-hook.sh index c5a9bedd0665..60bd74871c92 100644 --- a/pkgs/build-support/dart/build-dart-application/hooks/dart-fixup-hook.sh +++ b/pkgs/build-support/dart/build-dart-application/hooks/dart-fixup-hook.sh @@ -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