blob: 0e1ce6e678cbaab251172ad0b8a08d68dbc0c5b8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# Schema:
# ${flutterVersion}.${targetPlatform}.${hostPlatform}
#
# aarch64-darwin as a host is not yet supported.
# https://github.com/flutter/flutter/issues/60118
{ lib
, runCommand
, xorg
, cacert
, unzip
, flutterPlatform
, systemPlatform
, flutter
, hash
}:
let
flutterPlatforms = [
"android"
"ios"
"web"
"linux"
"windows"
"macos"
"fuchsia"
"universal"
];
flutter' = flutter.override {
# 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}-${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";
outputHashAlgo = "sha256";
passthru = {
inherit flutterPlatform;
};
} ''
export FLUTTER_ROOT="$NIX_BUILD_TOP"
lndir -silent '${flutter'}' "$FLUTTER_ROOT"
rm -rf "$FLUTTER_ROOT/bin/cache"
mkdir "$FLUTTER_ROOT/bin/cache"
HOME="$(mktemp -d)" flutter precache -v '--${flutterPlatform}' ${builtins.concatStringsSep " " (map (p: "'--no-${p}'") (lib.remove flutterPlatform flutterPlatforms))}
rm -rf "$FLUTTER_ROOT/bin/cache/lockfile"
find "$FLUTTER_ROOT" -type l -lname '${flutter'}/*' -delete
cp -r bin/cache "$out"
''
|