2024-01-25 14:12:00 +00:00
|
|
|
# Schema:
|
|
|
|
# ${flutterVersion}.${targetPlatform}.${hostPlatform}
|
|
|
|
#
|
|
|
|
# aarch64-darwin as a host is not yet supported.
|
|
|
|
# https://github.com/flutter/flutter/issues/60118
|
2024-01-02 11:29:13 +00:00
|
|
|
{ lib
|
|
|
|
, runCommand
|
|
|
|
, xorg
|
|
|
|
, cacert
|
|
|
|
, unzip
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
, flutterPlatform
|
|
|
|
, systemPlatform
|
2024-01-02 11:29:13 +00:00
|
|
|
, flutter
|
|
|
|
, hash
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-01-25 14:12:00 +00:00
|
|
|
flutterPlatforms = [
|
2024-01-02 11:29:13 +00:00
|
|
|
"android"
|
|
|
|
"ios"
|
|
|
|
"web"
|
|
|
|
"linux"
|
|
|
|
"windows"
|
|
|
|
"macos"
|
|
|
|
"fuchsia"
|
|
|
|
"universal"
|
|
|
|
];
|
|
|
|
|
|
|
|
flutter' = flutter.override {
|
|
|
|
# Use a version of Flutter with just enough capabilities to download
|
|
|
|
# artifacts.
|
2024-01-25 14:12:00 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
in
|
2024-01-25 14:12:00 +00:00
|
|
|
runCommand "flutter-artifacts-${flutterPlatform}-${systemPlatform}"
|
2024-01-02 11:29:13 +00:00
|
|
|
{
|
|
|
|
nativeBuildInputs = [ xorg.lndir flutter' unzip ];
|
|
|
|
|
|
|
|
NIX_FLUTTER_TOOLS_VM_OPTIONS = "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt";
|
2024-01-25 14:12:00 +00:00
|
|
|
NIX_FLUTTER_OPERATING_SYSTEM = {
|
|
|
|
"x86_64-linux" = "linux";
|
|
|
|
"aarch64-linux" = "linux";
|
|
|
|
"x86_64-darwin" = "macos";
|
|
|
|
"aarch64-darwin" = "macos";
|
|
|
|
}.${systemPlatform};
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
outputHash = hash;
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
|
|
|
|
passthru = {
|
2024-01-25 14:12:00 +00:00
|
|
|
inherit flutterPlatform;
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
} ''
|
|
|
|
export FLUTTER_ROOT="$NIX_BUILD_TOP"
|
|
|
|
lndir -silent '${flutter'}' "$FLUTTER_ROOT"
|
|
|
|
rm -rf "$FLUTTER_ROOT/bin/cache"
|
|
|
|
mkdir "$FLUTTER_ROOT/bin/cache"
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
HOME="$(mktemp -d)" flutter precache -v '--${flutterPlatform}' ${builtins.concatStringsSep " " (map (p: "'--no-${p}'") (lib.remove flutterPlatform flutterPlatforms))}
|
2024-01-02 11:29:13 +00:00
|
|
|
rm -rf "$FLUTTER_ROOT/bin/cache/lockfile"
|
|
|
|
find "$FLUTTER_ROOT" -type l -lname '${flutter'}/*' -delete
|
|
|
|
|
|
|
|
cp -r bin/cache "$out"
|
|
|
|
''
|