mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
flutter.buildFlutterApplication: Allow building for the Web
This commit is contained in:
parent
b43ee05f4e
commit
f51a0b053d
3 changed files with 151 additions and 127 deletions
|
@ -103,6 +103,9 @@ flutter.buildFlutterApplication {
|
|||
pname = "firmware-updater";
|
||||
version = "unstable-2023-04-30";
|
||||
|
||||
# To build for the Web, use the flutterHostPlatform argument.
|
||||
# flutterHostPlatform = "web";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "canonical";
|
||||
repo = "firmware-updater";
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
|
||||
{ pubGetScript ? "flutter pub get"
|
||||
, flutterBuildFlags ? [ ]
|
||||
, flutterHostPlatform ? "linux"
|
||||
, extraWrapProgramArgs ? ""
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
(buildDartApplication.override {
|
||||
dart = flutter;
|
||||
}) (args // {
|
||||
let
|
||||
hostPlatforms = rec {
|
||||
universal = args // {
|
||||
sdkSetupScript = ''
|
||||
# Pub needs SSL certificates. Dart normally looks in a hardcoded path.
|
||||
# https://github.com/dart-lang/sdk/blob/3.1.0/runtime/bin/security_context_linux.cc#L48
|
||||
|
@ -79,8 +80,12 @@
|
|||
}]' "$out" | '${moreutils}/bin/sponge' "$out"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
|
||||
linux = universal // {
|
||||
outputs = universal.outputs or [ ] ++ [ "debug" ];
|
||||
|
||||
nativeBuildInputs = (universal.nativeBuildInputs or [ ]) ++ [
|
||||
wrapGAppsHook
|
||||
|
||||
# Flutter requires pkg-config for Linux desktop support, and many plugins
|
||||
|
@ -92,10 +97,10 @@
|
|||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = (args.buildInputs or [ ]) ++ [ glib ];
|
||||
buildInputs = (universal.buildInputs or [ ]) ++ [ glib ];
|
||||
|
||||
dontDartBuild = true;
|
||||
buildPhase = args.buildPhase or ''
|
||||
buildPhase = universal.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir -p build/flutter_assets/fonts
|
||||
|
@ -106,7 +111,7 @@
|
|||
'';
|
||||
|
||||
dontDartInstall = true;
|
||||
installPhase = args.installPhase or ''
|
||||
installPhase = universal.installPhase or ''
|
||||
runHook preInstall
|
||||
|
||||
built=build/linux/*/release/bundle
|
||||
|
@ -134,11 +139,6 @@
|
|||
fi
|
||||
done
|
||||
|
||||
# Install the package_config.json file.
|
||||
# This is normally done by dartInstallHook, but we disable it.
|
||||
mkdir -p "$pubcache"
|
||||
cp .dart_tool/package_config.json "$pubcache/package_config.json"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
@ -147,4 +147,30 @@
|
|||
''${gappsWrapperArgs[@]} \
|
||||
${extraWrapProgramArgs}
|
||||
'';
|
||||
})
|
||||
};
|
||||
|
||||
web = universal // {
|
||||
dontDartBuild = true;
|
||||
buildPhase = universal.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir -p build/flutter_assets/fonts
|
||||
|
||||
flutter build web -v --release ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") flutterBuildFlags)}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
dontDartInstall = true;
|
||||
installPhase = universal.installPhase or ''
|
||||
runHook preInstall
|
||||
|
||||
cp -r build/web "$out"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
};
|
||||
in
|
||||
(buildDartApplication.override { dart = flutter.override { supportedTargetFlutterPlatforms = [ "universal" flutterHostPlatform ]; }; })
|
||||
hostPlatforms.${flutterHostPlatform} or "Unsupported Flutter host platform: ${flutterHostPlatform}"
|
||||
|
|
|
@ -51,12 +51,7 @@ let
|
|||
(mkCustomFlutter args).overrideAttrs (prev: next: {
|
||||
passthru = next.passthru // rec {
|
||||
inherit wrapFlutter mkCustomFlutter mkFlutter;
|
||||
buildFlutterApplication = callPackage ../../../build-support/flutter {
|
||||
# Package a minimal version of Flutter that only uses Linux desktop release artifacts.
|
||||
flutter = (wrapFlutter (mkCustomFlutter args)).override {
|
||||
supportedTargetFlutterPlatforms = [ "universal" "linux" ];
|
||||
};
|
||||
};
|
||||
buildFlutterApplication = callPackage ../../../build-support/flutter { flutter = wrapFlutter (mkCustomFlutter args); };
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue