Commit 84347c21 authored by hacker1024's avatar hacker1024
Browse files

flutter: Use wrapGAppsHook

Flutter's Linux desktop embedding uses GTK. wrapGAppsHook should be used.
parent 48516a89
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,8 +2,10 @@
, callPackage
, stdenvNoCC
, makeWrapper
, wrapGAppsHook
, llvmPackages_13
, cacert
, glib
, flutter
, jq
}:
@@ -47,8 +49,12 @@ let
      deps
      flutter
      jq
      glib
      wrapGAppsHook
    ] ++ nativeBuildInputs;

    dontWrapGApps = true;

    preUnpack = ''
      ${lib.optionalString (!autoDepsList) ''
        if ! { [ '${lib.boolToString (depsListFile != null)}' = 'true' ] ${lib.optionalString (depsListFile != null) "&& cmp -s <(jq -Sc . '${depsListFile}') <(jq -Sc . '${finalAttrs.passthru.depsListFile}')"}; }; then
@@ -123,6 +129,7 @@ let
      for f in "$out"/bin/*; do
        wrapProgram "$f" \
          --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath finalAttrs.runtimeDependencies}' \
          ''${gappsWrapperArgs[@]} \
          ${extraWrapProgramArgs}
      done

+33 −20
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
, makeWrapper
, runCommandLocal
, writeShellScript
, wrapGAppsHook
, git
, which
, pkg-config
@@ -166,19 +167,25 @@ let
  includeFlags = map (pkg: "-isystem ${lib.getOutput "dev" pkg}/include") (appStaticBuildDeps ++ extraIncludes);
  linkerFlags = (map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") appRuntimeDeps) ++ extraLinkerFlags;
in
(callPackage ./sdk-symlink.nix { }) (runCommandLocal "flutter-wrapped"
(callPackage ./sdk-symlink.nix { }) (stdenv.mkDerivation
{
  nativeBuildInputs = [
    makeWrapper
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
  pname = "flutter-wrapped";
  inherit (flutter) version;

  nativeBuildInputs = [ makeWrapper ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ]
    ++ lib.optionals supportsLinuxDesktop [ glib wrapGAppsHook ];

  passthru = flutter.passthru // {
    inherit (flutter) version;
    unwrapped = flutter;
  };

  inherit (flutter) meta;
} ''
  dontUnpack = true;
  dontWrapGApps = true;

  installPhase = ''
    runHook preInstall

    for path in ${builtins.concatStringsSep " " (builtins.foldl' (paths: pkg: paths ++ (map (directory: "'${pkg}/${directory}/pkgconfig'") ["lib" "share"])) [ ] pkgConfigPackages)}; do
      addToSearchPath FLUTTER_PKG_CONFIG_PATH "$path"
    done
@@ -191,5 +198,11 @@ in
      --suffix LIBRARY_PATH : '${lib.makeLibraryPath appStaticBuildDeps}' \
      --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " (includeFlags ++ extraCxxFlags)}' \
      --prefix CFLAGS "''\t" '${builtins.concatStringsSep " " (includeFlags ++ extraCFlags)}' \
    --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}'
'')
      --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \
      ''${gappsWrapperArgs[@]}

    runHook postInstall
  '';

  inherit (flutter) meta;
})