summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/build-support/flutter/default.nix20
1 files changed, 19 insertions, 1 deletions
diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix
index 229d73366d4..f85c7a19ce2 100644
--- a/pkgs/build-support/flutter/default.nix
+++ b/pkgs/build-support/flutter/default.nix
@@ -1,6 +1,7 @@
 { lib
 , callPackage
 , stdenvNoCC
+, makeWrapper
 , llvmPackages_13
 , cacert
 , flutter
@@ -10,10 +11,12 @@
 # absolutely no mac support for now
 
 { pubGetScript ? "flutter pub get"
-, flutterBuildFlags ? []
+, flutterBuildFlags ? [ ]
+, runtimeDependencies ? [ ]
 , vendorHash
 , pubspecLockFile ? null
 , nativeBuildInputs ? [ ]
+, postFixup ? ""
 , ...
 }@args:
 let
@@ -33,6 +36,7 @@ let
   outputs = [ "out" "debug" ];
 
   nativeBuildInputs = [
+    makeWrapper
     deps
     flutter
     git
@@ -87,6 +91,20 @@ let
 
     runHook postInstall
   '';
+
+  postFixup = ''
+    # Add runtime library dependencies to the LD_LIBRARY_PATH.
+    # For some reason, the RUNPATH of the executable is not used to load dynamic libraries in dart:ffi with DynamicLibrary.open().
+    #
+    # 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.
+    for f in "$out"/bin/*; do
+      wrapProgram "$f" \
+        --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath runtimeDependencies}'
+    done
+
+    ${postFixup}
+  '';
 })) self;
 in
   self