2021-02-05 17:12:51 +00:00
|
|
|
|
{ pname
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, version
|
|
|
|
|
, patches
|
|
|
|
|
, dart
|
2021-02-05 17:12:51 +00:00
|
|
|
|
, src
|
2021-01-09 10:05:03 +00:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
{ bash
|
|
|
|
|
, buildFHSUserEnv
|
|
|
|
|
, cacert
|
|
|
|
|
, git
|
|
|
|
|
, runCommand
|
|
|
|
|
, stdenv
|
2021-02-05 17:12:51 +00:00
|
|
|
|
, lib
|
2021-06-28 23:13:55 +00:00
|
|
|
|
, alsa-lib
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, dbus
|
|
|
|
|
, expat
|
|
|
|
|
, libpulseaudio
|
|
|
|
|
, libuuid
|
|
|
|
|
, libX11
|
|
|
|
|
, libxcb
|
|
|
|
|
, libXcomposite
|
|
|
|
|
, libXcursor
|
|
|
|
|
, libXdamage
|
|
|
|
|
, libXfixes
|
2021-02-05 17:12:51 +00:00
|
|
|
|
, libXrender
|
|
|
|
|
, libXtst
|
|
|
|
|
, libXi
|
|
|
|
|
, libXext
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, libGL
|
|
|
|
|
, nspr
|
|
|
|
|
, nss
|
|
|
|
|
, systemd
|
2021-09-28 08:13:01 +00:00
|
|
|
|
, which
|
2022-02-20 05:27:41 +00:00
|
|
|
|
, callPackage
|
2021-01-09 10:05:03 +00:00
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
let
|
2021-02-05 17:12:51 +00:00
|
|
|
|
drvName = "flutter-${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
flutter = stdenv.mkDerivation {
|
|
|
|
|
name = "${drvName}-unwrapped";
|
|
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
|
buildInputs = [ git ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
|
inherit src patches version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
|
patchShebangs --build ./bin/
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
2021-02-05 17:12:51 +00:00
|
|
|
|
export FLUTTER_ROOT="$(pwd)"
|
|
|
|
|
export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
|
|
|
|
|
export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart"
|
|
|
|
|
|
|
|
|
|
export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot"
|
|
|
|
|
export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"
|
|
|
|
|
|
|
|
|
|
export DART_SDK_PATH="${dart}"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
HOME=../.. # required for pub upgrade --offline, ~/.pub-cache
|
|
|
|
|
# path is relative otherwise it's replaced by /build/flutter
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
pushd "$FLUTTER_TOOLS_DIR"
|
2022-08-21 13:32:41 +00:00
|
|
|
|
${dart}/bin/dart pub get --offline
|
2021-02-05 17:12:51 +00:00
|
|
|
|
popd
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)"
|
2021-01-09 10:05:03 +00:00
|
|
|
|
${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
echo "$revision" > "$STAMP_PATH"
|
|
|
|
|
echo -n "${version}" > version
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
rm -r bin/cache/{artifacts,dart-sdk,downloads}
|
|
|
|
|
rm bin/cache/*.stamp
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-09-28 08:13:01 +00:00
|
|
|
|
runHook preInstall
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
mkdir -p $out
|
|
|
|
|
cp -r . $out
|
2021-01-09 10:05:03 +00:00
|
|
|
|
mkdir -p $out/bin/cache/
|
|
|
|
|
ln -sf ${dart} $out/bin/cache/dart-sdk
|
2021-09-28 08:13:01 +00:00
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
|
installCheckInputs = [ which ];
|
|
|
|
|
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
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Wrap flutter inside an fhs user env to allow execution of binary,
|
|
|
|
|
# like adb from $ANDROID_HOME or java from android-studio.
|
|
|
|
|
fhsEnv = buildFHSUserEnv {
|
|
|
|
|
name = "${drvName}-fhs-env";
|
|
|
|
|
multiPkgs = pkgs: [
|
|
|
|
|
# Flutter only use these certificates
|
|
|
|
|
(runCommand "fedoracert" { } ''
|
|
|
|
|
mkdir -p $out/etc/pki/tls/
|
|
|
|
|
ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs
|
|
|
|
|
'')
|
|
|
|
|
pkgs.zlib
|
|
|
|
|
];
|
|
|
|
|
targetPkgs = pkgs:
|
|
|
|
|
with pkgs; [
|
|
|
|
|
bash
|
|
|
|
|
curl
|
2020-11-03 02:18:15 +00:00
|
|
|
|
dart
|
2020-04-24 23:36:52 +00:00
|
|
|
|
git
|
|
|
|
|
unzip
|
|
|
|
|
which
|
|
|
|
|
xz
|
|
|
|
|
|
|
|
|
|
# flutter test requires this lib
|
|
|
|
|
libGLU
|
|
|
|
|
|
|
|
|
|
# for android emulator
|
2021-06-28 23:13:55 +00:00
|
|
|
|
alsa-lib
|
2020-04-24 23:36:52 +00:00
|
|
|
|
dbus
|
|
|
|
|
expat
|
|
|
|
|
libpulseaudio
|
|
|
|
|
libuuid
|
|
|
|
|
libX11
|
|
|
|
|
libxcb
|
|
|
|
|
libXcomposite
|
|
|
|
|
libXcursor
|
|
|
|
|
libXdamage
|
2021-02-05 17:12:51 +00:00
|
|
|
|
libXext
|
2020-04-24 23:36:52 +00:00
|
|
|
|
libXfixes
|
2021-02-05 17:12:51 +00:00
|
|
|
|
libXi
|
|
|
|
|
libXrender
|
|
|
|
|
libXtst
|
2020-04-24 23:36:52 +00:00
|
|
|
|
libGL
|
|
|
|
|
nspr
|
|
|
|
|
nss
|
|
|
|
|
systemd
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
|
in
|
2022-02-20 05:27:41 +00:00
|
|
|
|
let
|
|
|
|
|
self = (self:
|
2021-01-09 10:05:03 +00:00
|
|
|
|
runCommand drvName
|
|
|
|
|
{
|
2020-04-24 23:36:52 +00:00
|
|
|
|
startScript = ''
|
|
|
|
|
#!${bash}/bin/bash
|
|
|
|
|
export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"}
|
|
|
|
|
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
|
|
|
|
|
${fhsEnv}/bin/${drvName}-fhs-env ${flutter}/bin/flutter --no-version-check "$@"
|
|
|
|
|
'';
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
allowSubstitutes = false;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
passthru = {
|
|
|
|
|
unwrapped = flutter;
|
|
|
|
|
inherit dart;
|
2022-02-20 05:27:41 +00:00
|
|
|
|
mkFlutterApp = callPackage ../../../build-support/flutter {
|
|
|
|
|
flutter = self;
|
|
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
|
meta = with lib; {
|
2020-10-27 00:29:36 +00:00
|
|
|
|
description = "Flutter is Google's SDK for building mobile, web and desktop with Dart";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
maintainers = with maintainers; [ babariviere ericdallo ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
} ''
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
|
mkdir -p $out/bin/cache/
|
|
|
|
|
ln -sf ${dart} $out/bin/cache/dart-sdk
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
echo -n "$startScript" > $out/bin/${pname}
|
|
|
|
|
chmod +x $out/bin/${pname}
|
2022-02-20 05:27:41 +00:00
|
|
|
|
'') self;
|
|
|
|
|
in
|
|
|
|
|
self
|