From 94a34aadf6d3f7a78cad181a555d4d162a7e7914 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 16:14:22 +1000 Subject: [PATCH] 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 Co-authored-by: gilice Co-authored-by: hacker1024 --- pkgs/development/compilers/flutter/flutter.nix | 18 ++++++++++++++++-- pkgs/development/compilers/flutter/wrapper.nix | 3 +-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index de6f29306765..dd76600edb5f 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -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/ diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 7b6fd464e35a..7d7747217ad0 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -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)}' '')