2023-04-13 13:00:24 +01:00
|
|
|
{ lib
|
2023-04-15 15:17:41 +01:00
|
|
|
, callPackage
|
2021-11-23 11:02:55 +00:00
|
|
|
, stdenvNoCC
|
2023-04-13 13:00:24 +01:00
|
|
|
, llvmPackages_13
|
|
|
|
, cacert
|
|
|
|
, flutter
|
2023-04-13 17:16:04 +01:00
|
|
|
, git
|
2021-11-23 11:02:55 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
# absolutely no mac support for now
|
|
|
|
|
2023-04-15 15:17:41 +01:00
|
|
|
{ pubGetScript ? "flutter pub get"
|
2023-04-16 06:45:09 +01:00
|
|
|
, flutterBuildFlags ? []
|
2023-04-15 15:17:41 +01:00
|
|
|
, vendorHash
|
2023-04-15 16:49:43 +01:00
|
|
|
, pubspecLockFile ? null
|
2023-04-15 15:17:41 +01:00
|
|
|
, nativeBuildInputs ? [ ]
|
|
|
|
, ...
|
|
|
|
}@args:
|
2021-11-23 11:02:55 +00:00
|
|
|
let
|
2023-04-15 15:17:41 +01:00
|
|
|
flutterSetupScript = ''
|
|
|
|
export HOME="$NIX_BUILD_TOP"
|
|
|
|
flutter config --no-analytics &>/dev/null # mute first-run
|
|
|
|
flutter config --enable-linux-desktop >/dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
deps = callPackage ../dart/fetch-dart-deps { dart = flutter; } {
|
|
|
|
sdkSetupScript = flutterSetupScript;
|
2023-04-15 16:49:43 +01:00
|
|
|
inherit pubGetScript vendorHash pubspecLockFile;
|
2023-04-15 15:17:41 +01:00
|
|
|
buildDrvArgs = args;
|
|
|
|
};
|
2021-11-23 11:02:55 +00:00
|
|
|
self =
|
|
|
|
(self: llvmPackages_13.stdenv.mkDerivation (args // {
|
2023-04-16 06:56:14 +01:00
|
|
|
outputs = [ "out" "debug" ];
|
|
|
|
|
2023-04-15 10:52:12 +01:00
|
|
|
nativeBuildInputs = [
|
2023-04-15 15:17:41 +01:00
|
|
|
deps
|
2023-04-15 10:52:12 +01:00
|
|
|
flutter
|
|
|
|
git
|
2023-04-15 15:17:41 +01:00
|
|
|
] ++ nativeBuildInputs;
|
2023-04-13 13:00:24 +01:00
|
|
|
|
2021-11-23 11:02:55 +00:00
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
|
2023-04-15 15:17:41 +01:00
|
|
|
${flutterSetupScript}
|
2021-11-23 11:02:55 +00:00
|
|
|
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
mkdir -p build/flutter_assets/fonts
|
|
|
|
|
|
|
|
flutter packages get --offline -v
|
2023-04-16 06:56:14 +01:00
|
|
|
flutter build linux -v --release --split-debug-info="$debug" ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") flutterBuildFlags)}
|
2021-11-23 11:02:55 +00:00
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
built=build/linux/*/release/bundle
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
mv $built $out/app
|
|
|
|
|
2022-02-20 17:44:18 +00:00
|
|
|
for f in $(find $out/app -iname "*.desktop" -type f); do
|
2021-11-23 11:02:55 +00:00
|
|
|
install -D $f $out/share/applications/$(basename $f)
|
|
|
|
done
|
2022-02-20 17:44:18 +00:00
|
|
|
|
2021-11-23 11:02:55 +00:00
|
|
|
for f in $(find $out/app -maxdepth 1 -type f); do
|
|
|
|
ln -s $f $out/bin/$(basename $f)
|
|
|
|
done
|
|
|
|
|
|
|
|
# make *.so executable
|
|
|
|
find $out/app -iname "*.so" -type f -exec chmod +x {} +
|
|
|
|
|
|
|
|
# remove stuff like /build/source/packages/ubuntu_desktop_installer/linux/flutter/ephemeral
|
|
|
|
for f in $(find $out/app -executable -type f); do
|
|
|
|
if patchelf --print-rpath "$f" | grep /build; then # this ignores static libs (e,g. libapp.so) also
|
|
|
|
echo "strip RPath of $f"
|
|
|
|
newrp=$(patchelf --print-rpath $f | sed -r "s|/build.*ephemeral:||g" | sed -r "s|/build.*profile:||g")
|
|
|
|
patchelf --set-rpath "$newrp" "$f"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
})) self;
|
|
|
|
in
|
|
|
|
self
|