Unverified Commit 271984be authored by Maciej Krüger's avatar Maciej Krüger Committed by GitHub
Browse files

Merge pull request #231675 from FlafyDev/wrapped-flutter-artifacts

flutter: Move artifact installation logic to the wrapper
parents 50f1969b b1efbff8
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -34,15 +34,15 @@ let
        inherit wrapFlutter mkCustomFlutter mkFlutter;
        buildFlutterApplication = callPackage ../../../build-support/flutter {
          # Package a minimal version of Flutter that only uses Linux desktop release artifacts.
          flutter = wrapFlutter
            (mkCustomFlutter (args // {
          flutter = (wrapFlutter (mkCustomFlutter args)).override {
            supportsAndroid = false;
            includedEngineArtifacts = {
              common = [ "flutter_patched_sdk_product" ];
              platform.linux = lib.optionals stdenv.hostPlatform.isLinux
                (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64"))
                  (architecture: [ "release" ]));
            };
            }));
          };
        };
      };
    });
+1 −7
Original line number Diff line number Diff line
@@ -8,13 +8,7 @@
      "flutter_patched_sdk"
      "flutter_patched_sdk_product"
    ];
    platform = {
      android = lib.optionalAttrs stdenv.hostPlatform.isx86_64
        ((lib.genAttrs [ "arm" "arm64" "x64" ] (architecture: [ "profile" "release" ])) // { x86 = [ "jit-release" ]; });
      linux = lib.optionals stdenv.hostPlatform.isLinux
        (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64"))
          (architecture: [ "debug" "profile" "release" ]));
    };
    platform = { };
  }

, lib
+24 −6
Original line number Diff line number Diff line
@@ -2,7 +2,9 @@
, stdenv
, callPackage
, flutter
, supportsLinuxDesktop ? stdenv.isLinux
, supportsLinuxDesktop ? stdenv.hostPlatform.isLinux
, supportsAndroid ? stdenv.hostPlatform.isx86_64
, includedEngineArtifacts ? null
, extraPkgConfigPackages ? [ ]
, extraLibraries ? [ ]
, extraIncludes ? [ ]
@@ -33,11 +35,27 @@
}:

let
  flutterWithArtifacts = flutter.override {
    includedEngineArtifacts = if includedEngineArtifacts != null then includedEngineArtifacts else {
      common = [
        "flutter_patched_sdk"
        "flutter_patched_sdk_product"
      ];
      platform = {
        android = lib.optionalAttrs supportsAndroid
          ((lib.genAttrs [ "arm" "arm64" "x64" ] (architecture: [ "profile" "release" ])) // { x86 = [ "jit-release" ]; });
        linux = lib.optionalAttrs supportsLinuxDesktop
          (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64"))
            (architecture: [ "debug" "profile" "release" ]));
      };
    };
  };

  # By default, Flutter stores downloaded files (such as the Pub cache) in the SDK directory.
  # Wrap it to ensure that it does not do that, preferring home directories instead.
  immutableFlutter = writeShellScript "flutter_immutable" ''
    export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"}
    ${flutter}/bin/flutter "$@"
    ${flutterWithArtifacts}/bin/flutter "$@"
  '';

  # Tools that the Flutter tool depends on.
@@ -87,12 +105,12 @@ in
{
  nativeBuildInputs = [ makeWrapper ];

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

  inherit (flutter) meta;
  inherit (flutterWithArtifacts) meta;
} ''
  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"