about summary refs log tree commit diff
path: root/pkgs/development/compilers/flutter
diff options
context:
space:
mode:
authorhacker1024 <hacker1024@users.sourceforge.net>2023-10-23 02:51:25 +1100
committerMaciej Krüger <mkg20001@gmail.com>2023-12-21 11:44:11 +0100
commit5f6d29a70aafa0b16a23ae207cc31a4c15b99557 (patch)
tree013857e2b1ab7dc44da6d7ea4f7150a30c6c78e3 /pkgs/development/compilers/flutter
parent2dc524e2a701e86a113f536fdd7f430afac183de (diff)
downloadnixlib-5f6d29a70aafa0b16a23ae207cc31a4c15b99557.tar
nixlib-5f6d29a70aafa0b16a23ae207cc31a4c15b99557.tar.gz
nixlib-5f6d29a70aafa0b16a23ae207cc31a4c15b99557.tar.bz2
nixlib-5f6d29a70aafa0b16a23ae207cc31a4c15b99557.tar.lz
nixlib-5f6d29a70aafa0b16a23ae207cc31a4c15b99557.tar.xz
nixlib-5f6d29a70aafa0b16a23ae207cc31a4c15b99557.tar.zst
nixlib-5f6d29a70aafa0b16a23ae207cc31a4c15b99557.zip
flutter: Use JIT snapshot for flutter_tools
Diffstat (limited to 'pkgs/development/compilers/flutter')
-rw-r--r--pkgs/development/compilers/flutter/flutter-tools.nix20
1 files changed, 19 insertions, 1 deletions
diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix
index 156cbf75588a..23864cd0f245 100644
--- a/pkgs/development/compilers/flutter/flutter-tools.nix
+++ b/pkgs/development/compilers/flutter/flutter-tools.nix
@@ -1,4 +1,6 @@
 { buildDartApplication
+, git
+, which
 , dart
 , version
 , flutterSrc
@@ -11,7 +13,12 @@
 buildDartApplication.override { inherit dart; } rec {
   pname = "flutter-tools";
   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;
   sourceRoot = "source/packages/flutter_tools";
@@ -24,6 +31,17 @@ buildDartApplication.override { inherit dart; } rec {
 
   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
   # to be launched from a snapshot by the SDK.
   postInstall = ''