I’m trying to package a flutter package (https://commet.chat/) but I struggle with something: it asks to run a script to generate source code automatically (translations notably) that basically runs flutter pub get and a bunch of flutter pub run XX:YY --ZZ. So I tried to add in the preBuild phase:
flutter pub run intl_utils:generate
but after maybe 30s it timeout saying that iso_duration can’t be fetched. But iso_duration (and intl_utils) ARE present in pubspec.lock.json. Then I tried to do:
flutter pub get --offline
and this time it directly says:
Resolving dependencies... Because _ depends on iso_duration any which doesn't exist (could not find package iso_duration in cache), version solving failed. Try again without --offline! Failed to update packages.
So I tried to check the cache:
flutter pub cache list
but it prints {"packages":{}} so it seems like nix has not properly created the cache despite me using flutter335.buildFlutterApplication. Any idea what I’m missing?
{ lib
, stdenv
, fetchFromGitHub
, flutter335
}:
flutter335.buildFlutterApplication rec {
pname = "commet";
version = "0.4.0";
src = fetchFromGitHub {
owner = "commetchat";
repo = pname;
rev = "v${version}";
sha256 = "sha256-rXUUyHhBO7onKyZ04h7nG+FV1M/0Q+zLAMjo8RhD4g8=";
};
# Generate with cat pubspec.lock | yq > pubspec.lock.json in the source code folder
pubspecLock = lib.importJSON ./pubspec.lock.json;
# TODO: automatically fetch it using same code as in pkgs/by-name/mu/musicpod/package.nix
gitHashes = {
calendar_view = "sha256-tGAMK89VsgqfKQy+t8x5zl6dbQEf5h4HxSUR8crB1oM=";
desktop_webview_window = "sha256-EOh5QoOuAxiYn0IcdxY7taN2Twu8GshY9zAoGCztPnA=";
dynamic_color = "sha256-4zSTiXplkBjtPtzssj3VaHTVo9YlYKNTMLgBIM5MMe4=";
flutter_highlighter = "sha256-Y84Besir3gu1RnQt9YoE0GyIJLLZ6H0Kki/Wf6z6QMg=";
flutter_html = "sha256-576KYoYB4sZeavcAS8V5rjDG9hezYlN2Q4zlyvBOouw=";
flutter_local_notifications = "sha256-AgvvFoJgos/gsTwcLGX/CxbHauWiH3OHksqtF0Dauuw=";
flutter_local_notifications_linux = "sha256-AgvvFoJgos/gsTwcLGX/CxbHauWiH3OHksqtF0Dauuw=";
markdown = "sha256-2rEMNJM9Vy7LrFLt30/Z3pyqERTYJei9D3mgOAAvVPg=";
matrix = "sha256-YrArfC9AMWzFYcFkeWJMeFgIo1bJbmkTbeZfcYYA1zA=";
matrix_dart_sdk_drift_db = "sha256-t4a61O0nk9We0s4+cQB30H05giKi8IE3srPza57Ii94=";
receive_intent = "sha256-mXSxOXtDU1bwcuYz+pniJiGnYD4bxJUtMw1mq+OFRrY=";
signal_sticker_api = "sha256-VdEE3Bt8gpfUpxxYSz5319YEL49Eh+loO+ZipI1DoyA=";
starfield = "sha256-ebVRyVkyLfHCC6EBmx5evXL1U71S3tgCMo1yLWlIcw4=";
};
nativeBuildInputs = [ ];
buildInputs = [
];
preBuild = ''
ls -al
echo "Cache"
flutter pub cache list
echo "Test"
export PUB_OFFLINE=true
flutter pub get --offline
flutter pub run --offline intl_utils:generate
echo "Generating commet code..."
cd commet
dart run scripts/codegen.dart
echo "Generating tiamat code..."
cd ../tiamat
dart run scripts/codegen.dart
cd ..
echo "Done"
'';
meta = {
homepage = "https://github.com/commetchat/commet";
description = "A comfortable chat client which respects your privacy. Powered by [Matrix].";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ ];
platforms = lib.platforms.linux;
};
}