diff --git a/.envrc b/.envrc index af2fd92..72baf23 100644 --- a/.envrc +++ b/.envrc @@ -8,5 +8,9 @@ # Ensures that flake.nix gets evaluated. use flake +# Flutter via FVM — .fvmrc pins the version; fvm use creates .fvm/flutter_sdk. +# This must come after `use flake` so FVM Flutter takes precedence. +PATH_add .fvm/flutter_sdk/bin + # Load variables from .env dotenv_if_exists diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..19e8577 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.41.6" +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcaf171..38c16a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,7 @@ jobs: integration: name: Integration tests (Stalwart) runs-on: ubuntu-latest - # Run integration tests only on push to main, not on every PR, - # since they require downloading the Stalwart binary via Nix. + # Run integration tests only on push to main, not on every PR. if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: @@ -54,7 +53,7 @@ jobs: channel: stable cache: true - - name: Enter Nix shell and run integration tests + - name: Run integration tests run: | nix develop --command bash -c " flutter pub get && diff --git a/.gitignore b/.gitignore index 0e15fd7..89e9e5c 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,6 @@ linux/flutter/generated_plugins.cmake # direnv cache .direnv/ + +# FVM — .fvmrc is committed; .fvm/ contains the downloaded SDK (not committed) +.fvm/ diff --git a/LATER.md b/LATER.md index ccba6de..c52ada2 100644 --- a/LATER.md +++ b/LATER.md @@ -1,6 +1,14 @@ # Later -is there a e2e test tool in Flutter like Playwright? Application should launch, create screenshots... +Flutter best practices? + +--- + +Flutter/Dart Linters? + +--- + +integration_test (similar to Playwright) --- diff --git a/README.md b/README.md index 38342cb..ffa6f32 100644 --- a/README.md +++ b/README.md @@ -51,14 +51,17 @@ Run the app, tap **+**, and enter your IMAP/SMTP server details. The app syncs y ### Prerequisites -[Nix](https://nixos.org/download) with flakes enabled, and [direnv](https://direnv.net/). +[Nix](https://nixos.org/download) with flakes enabled and [direnv](https://direnv.net/). ```bash -# One-time: allow direnv in this directory +# One-time: allow direnv to load the Nix dev shell direnv allow + +# One-time: install the pinned Flutter version (fvm is provided by Nix) +fvm install ``` -`direnv` loads the Nix flake automatically — no manual `nix develop` needed after that. The flake pins **Flutter 3.41.6**, Android SDK, Stalwart mail server (for integration tests), and all Linux desktop build tools (GTK3, clang, cmake). +`direnv` loads the Nix flake automatically — it provides go-task, fvm, Android SDK, Stalwart, and Linux build tools. Flutter itself is managed by FVM (pinned in `.fvmrc`) rather than Nix, which avoids glibc compatibility issues on non-NixOS hosts. `task check` also runs `fvm install` automatically if Flutter is missing. ### First-time setup diff --git a/Taskfile.yml b/Taskfile.yml index 15131a9..38f5155 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -13,10 +13,17 @@ tasks: - sh: test "${DIRENV_DIR#-}" = "{{.TASKFILE_DIR}}" msg: "Not in nix dev shell. Run: nix develop" - _pub-get: + _flutter-check: internal: true run: once deps: [_nix-check] + cmds: + - cmd: command -v flutter >/dev/null 2>&1 || fvm install + + _pub-get: + internal: true + run: once + deps: [_flutter-check] cmds: - flutter pub get --suppress-analytics 2>/dev/null @@ -63,7 +70,7 @@ tasks: integration: desc: Integration tests against a local Stalwart mail server - deps: [_nix-check] + deps: [_flutter-check] cmds: - stalwart-dev/test.sh @@ -77,18 +84,26 @@ tasks: echo "Error: libsecret-1-dev is installed but pkg-config cannot find it." echo "Your nix shell was opened before the package was installed." echo "Fix: exit the nix shell and re-enter with: nix develop" - exit 1 else echo "Error: libsecret-1-dev is not installed." echo "Fix: sudo apt install libsecret-1-dev" - exit 1 fi + exit 1 build-linux: desc: Build the Linux desktop app (debug) deps: [_nix-check, _pub-get, _check-libsecret] cmds: - flutter build linux --debug --no-pub + - | + binary=build/linux/x64/debug/bundle/sharedinbox + missing=$(LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu ldd "$binary" 2>/dev/null | grep 'not found' || true) + if [ -n "$missing" ]; then + echo "Error: built binary has unresolvable runtime dependencies:" + echo "$missing" + echo "Fix: sudo apt install libsecret-1-0" + exit 1 + fi build-android: desc: Build a release APK (output in build/app/outputs/flutter-apk/) diff --git a/flake.nix b/flake.nix index a361e86..f65356f 100644 --- a/flake.nix +++ b/flake.nix @@ -31,9 +31,6 @@ in { devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ - # Flutter / Dart toolchain - flutter - # Android androidSdk @@ -60,6 +57,9 @@ # Task runner go-task + # Flutter version manager (fvm install downloads the pinned Flutter SDK) + fvm + # Utilities git curl