flutter: Make it possible to override operatingSystem internally

Makes it possible to get artifact hashes for other system platforms.

Useful for an update script.
This commit is contained in:
FlafyDev
2024-01-15 01:35:45 +02:00
parent da6757fd9d
commit b73ceb1ca7
2 changed files with 19 additions and 0 deletions
@@ -40,6 +40,12 @@ runCommand "flutter-artifacts-${flutterPlatform}-${systemPlatform}"
nativeBuildInputs = [ xorg.lndir flutter' unzip ];
NIX_FLUTTER_TOOLS_VM_OPTIONS = "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt";
NIX_FLUTTER_OPERATING_SYSTEM = {
"x86_64-linux" = "linux";
"aarch64-linux" = "linux";
"x86_64-darwin" = "macos";
"aarch64-darwin" = "macos";
}.${systemPlatform};
outputHash = hash;
outputHashMode = "recursive";
@@ -0,0 +1,13 @@
diff --git a/packages/flutter_tools/lib/src/base/platform.dart b/packages/flutter_tools/lib/src/base/platform.dart
index 45da89ad4c..2d79dbaece 100644
--- a/packages/flutter_tools/lib/src/base/platform.dart
+++ b/packages/flutter_tools/lib/src/base/platform.dart
@@ -132,7 +132,7 @@ class LocalPlatform extends Platform {
String get pathSeparator => io.Platform.pathSeparator;
@override
- String get operatingSystem => io.Platform.operatingSystem;
+ String get operatingSystem => io.Platform.environment['NIX_FLUTTER_OPERATING_SYSTEM'] ?? io.Platform.operatingSystem;
@override
String get operatingSystemVersion => io.Platform.operatingSystemVersion;