As Flutter is a go-to way for building GUIs also for desktop, canonical even promotes it in their blog, I want to make exactly that reproducable/hermetic using nix!
But I only find ways on how two build a dev shell with flutter etc included s.t. i can run flutter build
etc manually.
What I actually want is that my flake produces a binary output on its own. For example nix run github:owner/repo
should also work for repos containing flutter projects, or nix build .#apk
should produce an apk, if the flake has the corresponding package.
The problem I face when trying to build such a flake is that i cannot get the pub get
dependencies.
Even something in the likes of
packages = rec {
fetchDeps = pkgs.stdenv.mkDerivation {
name = "fetchDeps";
buildInputs = with pkgs; deps ++ [ wget cacert ];
src = frontend-dir;
buildPhase = ''
export HOME=$(mktemp -d)
export DART_VM_OPTIONS="--root-certs-file=/etc/ssl/certs/ca-certificates.crt"
flutter pub get -vv
'';
installPhase = ''
mkdir -p $out
cp -r $HOME/.pub-cache $out/.pub-cache
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = pkgs.lib.fakeHash;
};
apk = pkgs.stdenv.mkDerivation {
name = "apk";
buildInputs = with pkgs; deps ++ [ jdk17 android.androidsdk ];
src = frontend-dir;
ANDROID_SDK_ROOT = "${android.androidsdk}/libexec/android-sdk";
configurePhase = ''
export HOME=$(mktemp -d)
cp ${fetchDeps}/.pub-cache $HOME/.pub-cache
flutter pub get --offline
yes | flutter doctor --android-licenses
'';
buildPhase = ''
flutter doctor
flutter build apk
'';
installPhase = ''
mkdir -p $out
cp -r build/app/outputs/flutter-apk/app-release.apk $out/app-release.apk
'';
};
#....
wont work, as dart throws CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:393)
…
Is it actually the case that we cannot have reproducable flutter applications or is there something like pub2nix out there i dont know of?