flutter: Use autoPatchelfHook for SDK artifacts

This allows SDK artifacts (including build tools and libraries) to use the right interpreter and library locations, abolishing the need for a FHS or post-build patches.

`autoPatchelf` has been used through `autoPatchelfHook`, instead of the `autoPatchelf` command on just the artifact directory, due to the latter method not patching interpreter paths (https://discourse.nixos.org/t/trying-to-use-autopatchelf/24003).

Co-authored-by: FlafyDev <flafyarazi@gmail.com>
Co-authored-by: gilice <gilice@proton.me>
Co-authored-by: hacker1024 <hacker1024@users.sourceforge.net>
This commit is contained in:
hacker1024 2023-04-13 16:14:22 +10:00
parent 65708c3360
commit 94a34aadf6
2 changed files with 17 additions and 4 deletions

View File

@ -4,12 +4,25 @@
, src
, lib
, git
, stdenv
, autoPatchelfHook
, git
, which
, atk
, glib
, gtk3
, libepoxy
}:
let
# Libraries that Flutter artifacts depend on at runtime.
artifactRuntimeDeps = [
atk
glib
gtk3
libepoxy
];
self =
stdenv.mkDerivation {
name = "$flutter-${version}-unwrapped";
@ -17,7 +30,8 @@ let
outputs = [ "out" "cache" ];
buildInputs = [ git ];
nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [ git ] ++ artifactRuntimeDeps;
postPatch = ''
patchShebangs --build ./bin/

View File

@ -95,6 +95,5 @@ in
--prefix PATH : '${lib.makeBinPath buildTools}' \
--prefix PKG_CONFIG_PATH : '${builtins.concatStringsSep ":" pkgConfigDirectories}' \
--prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \
--prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \
--suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath appPrebuiltDeps}'
--prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}'
'')