From b1efbff8ec70f5a6ad564b32f7d5829139bad3be Mon Sep 17 00:00:00 2001 From: FlafyDev Date: Mon, 15 May 2023 01:16:47 +0300 Subject: [PATCH] flutter: Move artifact installation logic to the wrapper --- .../development/compilers/flutter/default.nix | 18 +++++------ .../development/compilers/flutter/flutter.nix | 8 +---- .../development/compilers/flutter/wrapper.nix | 30 +++++++++++++++---- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index b96452d0c89f..0f57919a9508 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -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 // { - 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" ])); - }; - })); + 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" ])); + }; + }; }; }; }); diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 71f70acf9da5..3dbab3529e77 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -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 diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index cac1bcf41d8b..81e5e6e4fdcd 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -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"