flutter: Make fetch-artifects.nix independent from the host's platform
This is useful for an update script
This commit is contained in:
@@ -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 ];
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 "";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user