2021-01-15 21:38:59 +01:00
|
|
|
|
{ pname
|
2021-01-06 21:38:03 +01:00
|
|
|
|
, version
|
|
|
|
|
, patches
|
|
|
|
|
, dart
|
2021-01-29 19:03:58 +01:00
|
|
|
|
, src
|
2021-01-06 21:38:03 +01:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
{ bash
|
|
|
|
|
, buildFHSUserEnv
|
|
|
|
|
, cacert
|
|
|
|
|
, coreutils
|
|
|
|
|
, git
|
|
|
|
|
, runCommand
|
2021-01-15 21:21:25 +01:00
|
|
|
|
, stdenv
|
|
|
|
|
, lib
|
2021-01-06 21:38:03 +01:00
|
|
|
|
, fetchurl
|
2021-06-10 04:57:09 +02:00
|
|
|
|
, alsa-lib
|
2021-01-06 21:38:03 +01:00
|
|
|
|
, dbus
|
|
|
|
|
, expat
|
|
|
|
|
, libpulseaudio
|
|
|
|
|
, libuuid
|
|
|
|
|
, libX11
|
|
|
|
|
, libxcb
|
|
|
|
|
, libXcomposite
|
|
|
|
|
, libXcursor
|
|
|
|
|
, libXdamage
|
|
|
|
|
, libXfixes
|
2021-01-31 21:07:29 +01:00
|
|
|
|
, libXrender
|
|
|
|
|
, libXtst
|
|
|
|
|
, libXi
|
|
|
|
|
, libXext
|
2021-01-06 21:38:03 +01:00
|
|
|
|
, libGL
|
|
|
|
|
, nspr
|
|
|
|
|
, nss
|
|
|
|
|
, systemd
|
|
|
|
|
}:
|
2019-12-24 18:01:45 +01:00
|
|
|
|
let
|
2021-01-29 19:03:58 +01:00
|
|
|
|
drvName = "flutter-${version}";
|
2019-12-24 18:01:45 +01:00
|
|
|
|
flutter = stdenv.mkDerivation {
|
|
|
|
|
name = "${drvName}-unwrapped";
|
|
|
|
|
|
2021-01-29 18:50:13 +01:00
|
|
|
|
buildInputs = [ git ];
|
2019-12-24 18:01:45 +01:00
|
|
|
|
|
2021-03-23 20:51:58 +01:00
|
|
|
|
inherit src patches version;
|
2019-12-24 18:01:45 +01:00
|
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
|
patchShebangs --build ./bin/
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
2021-01-29 19:03:58 +01: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}"
|
2019-12-24 18:01:45 +01:00
|
|
|
|
|
2021-01-29 18:50:13 +01:00
|
|
|
|
HOME=../.. # required for pub upgrade --offline, ~/.pub-cache
|
|
|
|
|
# path is relative otherwise it's replaced by /build/flutter
|
2019-12-24 18:01:45 +01:00
|
|
|
|
|
2021-01-29 19:03:58 +01:00
|
|
|
|
pushd "$FLUTTER_TOOLS_DIR"
|
|
|
|
|
${dart}/bin/pub get --offline
|
|
|
|
|
popd
|
2019-12-24 18:01:45 +01:00
|
|
|
|
|
|
|
|
|
local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)"
|
2021-01-06 21:43:33 +01:00
|
|
|
|
${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
|
2019-12-24 18:01:45 +01:00
|
|
|
|
echo "$revision" > "$STAMP_PATH"
|
|
|
|
|
echo -n "${version}" > version
|
2021-01-29 18:50:13 +01:00
|
|
|
|
|
2021-01-29 19:03:58 +01:00
|
|
|
|
rm -r bin/cache/{artifacts,dart-sdk,downloads}
|
|
|
|
|
rm bin/cache/*.stamp
|
2019-12-24 18:01:45 +01:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
mkdir -p $out
|
|
|
|
|
cp -r . $out
|
2021-01-06 21:43:33 +01:00
|
|
|
|
mkdir -p $out/bin/cache/
|
|
|
|
|
ln -sf ${dart} $out/bin/cache/dart-sdk
|
2019-12-24 18:01:45 +01: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-10-07 04:54:12 +02:00
|
|
|
|
dart
|
2019-12-24 18:01:45 +01:00
|
|
|
|
git
|
|
|
|
|
unzip
|
|
|
|
|
which
|
|
|
|
|
xz
|
|
|
|
|
|
|
|
|
|
# flutter test requires this lib
|
|
|
|
|
libGLU
|
|
|
|
|
|
|
|
|
|
# for android emulator
|
2021-06-10 04:57:09 +02:00
|
|
|
|
alsa-lib
|
2019-12-24 18:01:45 +01:00
|
|
|
|
dbus
|
|
|
|
|
expat
|
|
|
|
|
libpulseaudio
|
|
|
|
|
libuuid
|
|
|
|
|
libX11
|
|
|
|
|
libxcb
|
|
|
|
|
libXcomposite
|
|
|
|
|
libXcursor
|
|
|
|
|
libXdamage
|
2021-01-31 21:07:29 +01:00
|
|
|
|
libXext
|
2019-12-24 18:01:45 +01:00
|
|
|
|
libXfixes
|
2021-01-31 21:07:29 +01:00
|
|
|
|
libXi
|
|
|
|
|
libXrender
|
|
|
|
|
libXtst
|
2019-12-24 18:01:45 +01:00
|
|
|
|
libGL
|
|
|
|
|
nspr
|
|
|
|
|
nss
|
|
|
|
|
systemd
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-06 21:38:03 +01:00
|
|
|
|
in
|
|
|
|
|
runCommand drvName
|
|
|
|
|
{
|
2019-12-24 18:01:45 +01: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;
|
|
|
|
|
passthru = { unwrapped = flutter; };
|
2021-01-22 12:25:31 +01:00
|
|
|
|
meta = with lib; {
|
2020-10-25 14:13:18 +01:00
|
|
|
|
description = "Flutter is Google's SDK for building mobile, web and desktop with Dart";
|
2019-12-24 18:01:45 +01: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-01-24 14:08:17 +01:00
|
|
|
|
maintainers = with maintainers; [ babariviere ericdallo thiagokokada ];
|
2019-12-24 18:01:45 +01:00
|
|
|
|
};
|
|
|
|
|
} ''
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
|
|
|
|
|
echo -n "$startScript" > $out/bin/${pname}
|
|
|
|
|
chmod +x $out/bin/${pname}
|
|
|
|
|
''
|