flutter: Use JIT snapshot for flutter_tools

This commit is contained in:
hacker1024 2023-10-23 02:51:25 +11:00 committed by Maciej Krüger
parent 2dc524e2a7
commit 5f6d29a70a
No known key found for this signature in database
GPG key ID: 0D948CE19CF49C5F

View file

@ -1,4 +1,6 @@
{ buildDartApplication { buildDartApplication
, git
, which
, dart , dart
, version , version
, flutterSrc , flutterSrc
@ -11,7 +13,12 @@
buildDartApplication.override { inherit dart; } rec { buildDartApplication.override { inherit dart; } rec {
pname = "flutter-tools"; pname = "flutter-tools";
inherit version; inherit version;
dartOutputType = "kernel";
# The SDK normally uses a JIT snapshot, so we do as well.
# Previously, we used a kernel snapshot - but this was found to cause
# extremely strange behaviour at runtime (observed in `flutter precache`),
# where certain functions would not execute properly.
dartOutputType = "jit-snapshot";
src = flutterSrc; src = flutterSrc;
sourceRoot = "source/packages/flutter_tools"; sourceRoot = "source/packages/flutter_tools";
@ -24,6 +31,17 @@ buildDartApplication.override { inherit dart; } rec {
dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart"; dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart";
# When the JIT snapshot is being built, the application needs to run.
# It attempts to generate configuration files, and relies on a few external
# tools.
nativeBuildInputs = [ git which ];
preConfigure = ''
export HOME=.
export FLUTTER_ROOT="$NIX_BUILD_TOP/source"
mkdir -p "$FLUTTER_ROOT/bin/cache"
ln -s '${dart}' "$FLUTTER_ROOT/bin/cache/dart-sdk"
'';
# The Dart wrapper launchers are useless for the Flutter tool - it is designed # The Dart wrapper launchers are useless for the Flutter tool - it is designed
# to be launched from a snapshot by the SDK. # to be launched from a snapshot by the SDK.
postInstall = '' postInstall = ''