about summary refs log tree commit diff
path: root/pkgs/development/compilers/flutter
diff options
context:
space:
mode:
authorFlafyDev <flafyarazi@gmail.com>2023-12-21 20:23:36 +0200
committerFlafyDev <flafyarazi@gmail.com>2024-01-11 01:37:59 +0200
commitda6757fd9d0deff3fe5ead896834c3e3e70d8d66 (patch)
treeff6d9d881ca90b4b2a9eb5964aeab4731e1fef7b /pkgs/development/compilers/flutter
parent579e01329e83a2bd44762be64b3862e1f8dfd8b7 (diff)
flutter: Make fetch-artifects.nix independent from the host's platform
This is useful for an update script
Diffstat (limited to 'pkgs/development/compilers/flutter')
-rw-r--r--pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix10
-rw-r--r--pkgs/development/compilers/flutter/flutter-tools.nix4
-rw-r--r--pkgs/development/compilers/flutter/flutter.nix17
-rw-r--r--pkgs/development/compilers/flutter/wrapper.nix1
4 files changed, 21 insertions, 11 deletions
diff --git a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix
index 7ce6c34d91150..3d76183e71139 100644
--- a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix
+++ b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix
@@ -5,6 +5,7 @@
 , unzip
 
 , flutterPlatform
+, systemPlatform
 , flutter
 , hash
 }:
@@ -25,9 +26,16 @@ let
     # Use a version of Flutter with just enough capabilities to download
     # artifacts.
     supportedTargetFlutterPlatforms = [ ];
+
+    # Modify flutter-tool's system platform in order to get the desired platform's hashes.
+    flutter = flutter.unwrapped.override {
+      flutterTools = flutter.unwrapped.tools.override {
+        inherit systemPlatform;
+      };
+    };
   };
 in
-runCommand "flutter-artifacts-${flutterPlatform}"
+runCommand "flutter-artifacts-${flutterPlatform}-${systemPlatform}"
 {
   nativeBuildInputs = [ xorg.lndir flutter' unzip ];
 
diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix
index 4435c8fb6c760..55fee5630c16a 100644
--- a/pkgs/development/compilers/flutter/flutter-tools.nix
+++ b/pkgs/development/compilers/flutter/flutter-tools.nix
@@ -1,4 +1,4 @@
-{ hostPlatform
+{ systemPlatform
 , buildDartApplication
 , git
 , which
@@ -35,7 +35,7 @@ buildDartApplication.override { inherit dart; } rec {
   '';
 
   dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart";
-  dartCompileFlags = [ "--define=NIX_FLUTTER_HOST_PLATFORM=${hostPlatform.system}" ];
+  dartCompileFlags = [ "--define=NIX_FLUTTER_HOST_PLATFORM=${systemPlatform}" ];
 
   # The Dart wrapper launchers are useless for the Flutter tool - it is designed
   # to be launched from a snapshot by the SDK.
diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix
index c78589997b434..a1a25e0e99b63 100644
--- a/pkgs/development/compilers/flutter/flutter.nix
+++ b/pkgs/development/compilers/flutter/flutter.nix
@@ -12,16 +12,16 @@
 , git
 , which
 , jq
-}:
-
-let
-  tools = callPackage ./flutter-tools.nix {
+, flutterTools ? callPackage ./flutter-tools.nix {
     inherit dart version;
     flutterSrc = src;
     inherit patches;
     inherit pubspecLock;
-  };
+    systemPlatform = stdenv.hostPlatform.system;
+  }
+}:
 
+let
   unwrapped =
     stdenv.mkDerivation {
       name = "flutter-${version}-unwrapped";
@@ -59,13 +59,13 @@ let
         # Add a flutter_tools artifact stamp, and build a snapshot.
         # This is the Flutter CLI application.
         echo "$(git rev-parse HEAD)" > bin/cache/flutter_tools.stamp
-        ln -s '${tools}/share/flutter_tools.snapshot' bin/cache/flutter_tools.snapshot
+        ln -s '${flutterTools}/share/flutter_tools.snapshot' bin/cache/flutter_tools.snapshot
 
         # Some of flutter_tools's dependencies contain static assets. The
         # application attempts to read its own package_config.json to find these
         # assets at runtime.
         mkdir -p packages/flutter_tools/.dart_tool
-        ln -s '${tools.pubcache}/package_config.json' packages/flutter_tools/.dart_tool/package_config.json
+        ln -s '${flutterTools.pubcache}/package_config.json' packages/flutter_tools/.dart_tool/package_config.json
 
         echo -n "${version}" > version
         cat <<EOF > bin/cache/flutter.version.json
@@ -119,7 +119,8 @@ let
       '';
 
       passthru = {
-        inherit dart engineVersion tools;
+        inherit dart engineVersion;
+        tools = flutterTools;
         # 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.
diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix
index 052c7584e9397..4cf8ac651be49 100644
--- a/pkgs/development/compilers/flutter/wrapper.nix
+++ b/pkgs/development/compilers/flutter/wrapper.nix
@@ -50,6 +50,7 @@ let
     (callPackage ./artifacts/prepare-artifacts.nix {
       src = callPackage ./artifacts/fetch-artifacts.nix {
         inherit flutterPlatform;
+        systemPlatform = stdenv.hostPlatform.system;
         flutter = callPackage ./wrapper.nix { inherit flutter; };
         hash = artifactHashes.${flutterPlatform}.${stdenv.hostPlatform.system} or "";
       };