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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
{ version
, engineVersion
, patches
, dart
, src
, pubspecLockFile
, vendorHash
, depsListFile
, lib
, stdenv
, callPackage
, darwin
, git
, which
}:
let
tools = callPackage ./flutter-tools.nix {
inherit dart version;
flutterSrc = src;
inherit patches;
inherit pubspecLockFile vendorHash depsListFile;
};
unwrapped =
stdenv.mkDerivation {
name = "flutter-${version}-unwrapped";
inherit src patches version;
buildInputs = [ git ];
nativeBuildInputs = [ ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
preConfigure = ''
if [ "$(< bin/internal/engine.version)" != '${engineVersion}' ]; then
echo 1>&2 "The given engine version (${engineVersion}) does not match the version required by the Flutter SDK ($(< bin/internal/engine.version))."
exit 1
fi
'';
postPatch = ''
patchShebangs --build ./bin/
'';
buildPhase = ''
export FLUTTER_ROOT="$(pwd)"
mkdir -p "$FLUTTER_ROOT/bin/cache"
export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot"
export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"
local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)"
echo "$revision" > "$STAMP_PATH"
ln -s '${tools}/share/flutter_tools.snapshot' "$SNAPSHOT_PATH"
echo -n "${version}" > version
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r . $out
ln -sf ${dart} $out/bin/cache/dart-sdk
runHook postInstall
'';
doInstallCheck = true;
nativeInstallCheckInputs = [ which ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
installCheckPhase = ''
runHook preInstallCheck
export HOME="$(mktemp -d)"
$out/bin/flutter config --android-studio-dir $HOME
$out/bin/flutter config --android-sdk $HOME
$out/bin/flutter --version | fgrep -q '${version}'
runHook postInstallCheck
'';
passthru = {
inherit dart engineVersion tools;
# 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.
sdk = unwrapped;
};
meta = with lib; {
description = "Flutter is Google's SDK for building mobile, web and desktop with Dart";
longDescription = ''
Flutter is Google’s UI toolkit for building beautiful,
natively compiled applications for mobile, web, and desktop from a single codebase.
'';
homepage = "https://flutter.dev";
license = licenses.bsd3;
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
maintainers = with maintainers; [ babariviere ericdallo FlafyDev hacker1024 ];
};
};
in
unwrapped
|