From ee289896a7cd0ea4d8a34f3cc5ca282a98ec3e54 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 22 Oct 2023 17:21:36 +1100 Subject: flutter: Build flutter_tools with buildDartApplication --- pkgs/development/compilers/flutter/flutter.nix | 48 +++++++------------------- 1 file changed, 13 insertions(+), 35 deletions(-) (limited to 'pkgs/development/compilers/flutter/flutter.nix') diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index da45fee420d00..3cc230b7b205c 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -3,21 +3,29 @@ , patches , dart , src +, pubspecLockFile +, vendorHash +, depsListFile , lib , stdenv +, callPackage , darwin , git , which }: let + tools = callPackage ./flutter-tools.nix { + inherit dart version; + flutterSrc = src; + inherit pubspecLockFile vendorHash depsListFile; + }; + unwrapped = stdenv.mkDerivation { name = "flutter-${version}-unwrapped"; inherit src patches version; - outputs = [ "out" "cache" ]; - buildInputs = [ git ]; nativeBuildInputs = [ ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ]; @@ -35,45 +43,15 @@ let buildPhase = '' export FLUTTER_ROOT="$(pwd)" - export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" - export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart" + mkdir -p "$FLUTTER_ROOT/bin/cache" export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" - export DART_SDK_PATH="${dart}" - - # The Flutter tool compilation requires dependencies to be cached, as there is no Internet access. - # Dart expects package caches to be mutable, and does not support composing cache directories. - # The packages cached during the build therefore cannot be easily used. They are provided through - # the derivation's "cache" output, though, in case they are needed. - # - # Note that non-cached packages will normally be fetched from the Internet when they are needed, so Flutter - # will function without an existing package cache as long as it has an Internet connection. - export PUB_CACHE="$cache" - - if [ -d .pub-preload-cache ]; then - ${dart}/bin/dart pub cache preload .pub-preload-cache/* - elif [ -d .pub-cache ]; then - mv .pub-cache "$PUB_CACHE" - else - echo 'ERROR: Failed to locate the Dart package cache required to build the Flutter tool.' - exit 1 - fi - - pushd "$FLUTTER_TOOLS_DIR" - ${dart}/bin/dart pub get --offline - popd - local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" - ${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH" echo "$revision" > "$STAMP_PATH" + ln -s '${tools}/share/flutter_tools.snapshot' "$SNAPSHOT_PATH" echo -n "${version}" > version - - # Certain prebuilts should be replaced with Nix-built (or at least Nix-patched) equivalents. - rm -r \ - $FLUTTER_ROOT/bin/cache/dart-sdk \ - $FLUTTER_ROOT/bin/cache/artifacts/engine ''; installPhase = '' @@ -101,7 +79,7 @@ let ''; passthru = { - inherit dart engineVersion; + inherit dart engineVersion tools; # The derivation containing the original Flutter SDK files. # When other derivations wrap this one, any unmodified files # found here should be included as-is, for tooling compatibility. -- cgit 1.4.1