diff --git a/.fvmrc b/.fvmrc index 457360f..8ab3a25 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,3 +1,3 @@ { "flutter": "3.44.0" -} \ No newline at end of file +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 35a3589..fe20dbc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,13 +26,13 @@ repos: - id: forbidden-files-hook name: check for forbidden home-directory files language: system - entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && nix develop --command task check-hygiene' + entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && task check-hygiene' pass_filenames: false always_run: true - id: dart-check name: dart format (autofix) + check-fast (parallel) language: system - entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && nix develop --command dagger call --progress=plain -q -m ci --source=. check-fast' + entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && dagger call --progress=plain -q -m ci --source=. check-fast' pass_filenames: false always_run: true - id: ci-no-direct-dagger @@ -50,12 +50,12 @@ repos: - id: ci-image-exists name: verify container images in ci/main.go are reachable language: system - entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && nix develop --command task check-ci-images' + entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && task check-ci-images' pass_filenames: false files: ^(ci/main\.go|\.fvmrc)$ - id: dagger-versions-aligned - name: verify Dagger version is consistent across dagger.json, flake.nix, Dockerfile and DAGGER.md + name: verify Dagger version is consistent across dagger.json, Dockerfile and DAGGER.md language: system entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && scripts/check_dagger_versions.sh' pass_filenames: false - files: ^(ci/dagger\.json|flake\.nix|\.forgejo/Dockerfile|DAGGER\.md)$ + files: ^(ci/dagger\.json|\.forgejo/Dockerfile|DAGGER\.md)$ diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..c95f6b7 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,59 @@ +# Development and Testing Container for SharedInbox +# Replaces the Nix shell environment. +FROM ghcr.io/cirruslabs/flutter:3.44.0 + +# Install Linux desktop build and test dependencies, Go, NodeJS, python3, and utilities +RUN apt-get update && apt-get install -y --no-install-recommends \ + clang \ + cmake \ + ninja-build \ + pkg-config \ + libgtk-3-dev \ + liblzma-dev \ + libsecret-1-dev \ + libgcrypt20-dev \ + libjsoncpp-dev \ + sqlite3 \ + iproute2 \ + netcat-openbsd \ + xvfb \ + libosmesa6 \ + libegl1 \ + lld \ + git \ + curl \ + jq \ + python3-pip \ + nodejs \ + npm \ + hugo \ + lcov \ + rsync \ + openssh-client \ + && rm -rf /var/lib/apt/lists/* + +# Install Task runner +RUN curl -fsSL https://taskfile.dev/install.sh \ + | sh -s -- -b /usr/local/bin v3.48.0 + +# Install Dagger CLI +RUN curl -fsSL https://dl.dagger.io/dagger/install.sh \ + | DAGGER_VERSION=0.20.8 BIN_DIR=/usr/local/bin sh + +# Install python packages (Play Store API clients + pre-commit) +RUN pip install --break-system-packages --no-cache-dir \ + google-api-python-client \ + google-auth-httplib2 \ + httplib2 \ + pre-commit==4.5.1 + +# Install acpx CLI globally +RUN npm install -g acpx@0.10.0 + +# Setup user "ci" +RUN useradd -m -s /bin/bash ci +USER ci +ENV HOME=/home/ci +ENV PATH=/home/ci/.pub-cache/bin:$PATH + +WORKDIR /src diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 8cdc600..0000000 --- a/flake.lock +++ /dev/null @@ -1,82 +0,0 @@ -{ - "nodes": { - "dagger": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1778107833, - "narHash": "sha256-q5XQep2mpgTPiWwuYB1+L2dsFeACT6sHx8J939iM+HE=", - "owner": "dagger", - "repo": "nix", - "rev": "873cc22ba46b73d4a6c1aa6c102ef3aabc736496", - "type": "github" - }, - "original": { - "owner": "dagger", - "repo": "nix", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1778737229, - "narHash": "sha256-6xWoytx8jFW4PF1GjRm/i/53trbpKGfz6zjzQGBr4cI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d7a713c0b7e47c908258e71cba7a2d77cc8d71d5", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-25.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "dagger": "dagger", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index b512860..0000000 --- a/flake.nix +++ /dev/null @@ -1,166 +0,0 @@ -{ - description = "SharedInbox — IMAP/SMTP Flutter client"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; - flake-utils.url = "github:numtide/flake-utils"; - dagger.url = "github:dagger/nix"; - dagger.inputs.nixpkgs.follows = "nixpkgs"; - }; - - outputs = { self, nixpkgs, flake-utils, dagger }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - - # All Linux desktop runtime libraries needed by flutter build linux and - # the UI integration tests (xvfb-run). Kept as a list so we can reuse - # it for both buildInputs and LD_LIBRARY_PATH / PKG_CONFIG_PATH. - linuxDesktopLibs = with pkgs; [ - gtk3 - libsecret - fontconfig - libepoxy - mesa - libGL # libglvnd — vendor-neutral GL/EGL/GLX dispatch layer - at-spi2-core - glib - pango - cairo - gdk-pixbuf - harfbuzz - # Dagger remote setup dependencies - stunnel - netcat - ]; - - fgj = pkgs.stdenv.mkDerivation { - pname = "fgj"; - version = "0.4.0"; - src = pkgs.fetchurl { - url = "https://codeberg.org/romaintb/fgj/releases/download/v0.4.0/fgj_linux_amd64"; - sha256 = "07pia03facvvxq9i1dgl7p47ccv1iqj4drpkp45gvw26d4afkbj7"; - }; - dontUnpack = true; - installPhase = '' - mkdir -p $out/bin - cp $src $out/bin/fgj - chmod +x $out/bin/fgj - ''; - }; - - # The dagger/nix flake's Nix wrapper is a broken self-exec loop, so we - # fetch the CLI binary directly. Keep this version in lockstep with - # ci/dagger.json (engineVersion) and .forgejo/Dockerfile (DAGGER_VERSION) — - # scripts/check_dagger_versions.sh enforces this. - daggerCli = pkgs.stdenv.mkDerivation { - pname = "dagger"; - version = "0.20.8"; - src = pkgs.fetchurl { - url = "https://dl.dagger.io/dagger/releases/0.20.8/dagger_v0.20.8_linux_amd64.tar.gz"; - sha256 = "1ns6wq2z1skd2fq9lbrcali0s8kn24p3haamnjjgchg6zlv6b960"; - }; - sourceRoot = "."; - installPhase = '' - mkdir -p $out/bin - cp dagger $out/bin/dagger - chmod +x $out/bin/dagger - ''; - }; - in { - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ - # Dagger CLI - daggerCli - - # Go compiler — for Dagger development - go - - # Java JDK — required by Gradle for Android builds - - # Task runner - go-task - - # Flutter version manager — needed for host builds (task build-linux, task run) - fvm - - # Git hooks - pre-commit - - # Linux desktop build + runtime dependencies (flutter build linux / task run) - ] ++ linuxDesktopLibs ++ (with pkgs; [ - pkg-config - clang - cmake - ninja - - # Local IMAP/SMTP dev server for integration tests - stalwart-mail - - # Headless display for UI integration tests - xvfb-run # wraps Xvfb; xvfb-run --auto-servernum ... - - # Coverage merging (flutter test --merge-coverage requires lcov) - lcov - - # Website - hugo - - # Utilities - git - curl - jq - sqlite - # python3 base + Google Play API client (for scripts/deploy_playstore.py) - (python3.withPackages (ps: with ps; [ - google-api-python-client - google-auth-httplib2 - httplib2 - ])) # used by stalwart-dev/start and deploy_playstore.py - fgj # Codeberg/Forgejo CLI (like gh for GitHub) - skopeo # inspect OCI image manifests without pulling layers (used by check-ci-images) - librsvg # rsvg-convert — SVG→PNG for generate-icons task - ]); - - shellHook = '' - # nix develop --command does not set IN_NIX_SHELL; set it so _preflight passes in CI - export IN_NIX_SHELL=1 - - # Point Dagger client at the running engine socket - export DAGGER_HOST=unix:///run/dagger/engine.sock - - # Disable Flutter telemetry inside dev shell - export FLUTTER_SUPPRESS_ANALYTICS=true - - # Expose dev headers to cmake's FindPkgConfig. - # The nix pkg-config wrapper works in bash but cmake invokes pkg-config - # as a subprocess and needs PKG_CONFIG_PATH set explicitly. - export PKG_CONFIG_PATH="${pkgs.gtk3.dev}/lib/pkgconfig:${pkgs.glib.dev}/lib/pkgconfig:${pkgs.pango.dev}/lib/pkgconfig:${pkgs.cairo.dev}/lib/pkgconfig:${pkgs.gdk-pixbuf.dev}/lib/pkgconfig:${pkgs.at-spi2-core.dev}/lib/pkgconfig:${pkgs.harfbuzz.dev}/lib/pkgconfig:${pkgs.libsecret}/lib/pkgconfig:${pkgs.fontconfig.dev}/lib/pkgconfig:${pkgs.libepoxy}/lib/pkgconfig:$PKG_CONFIG_PATH" - - # Nix ld uses --no-copy-dt-needed-entries (strict mode): transitive shared-lib - # deps are not followed automatically, so link them explicitly. - export LDFLAGS="-L${pkgs.fontconfig.lib}/lib -lfontconfig $LDFLAGS" - - # Make nix-built runtime libs visible to the dynamic linker so the - # Flutter Linux bundle and integration-ui tests can run. - export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath linuxDesktopLibs}:$LD_LIBRARY_PATH" - - # Wire the libglvnd dispatch to the nix mesa vendor ICDs so GTK/Flutter - # can create an OpenGL (EGL + GLX) context under Xvfb without a real GPU. - export __EGL_VENDOR_LIBRARY_DIRS="${pkgs.mesa}/share/glvnd/egl_vendor.d" - export __GLX_VENDOR_LIBRARY_DIRS="${pkgs.mesa}/lib" - export LIBGL_ALWAYS_SOFTWARE=1 - export MESA_LOADER_DRIVER_OVERRIDE=softpipe - - echo "SharedInbox Flutter dev environment ready." - echo " Analyze : task analyze" - echo " Unit tests : task test" - echo " Integration : task integration" - echo " All checks : task check" - echo " Run (Linux) : task run" - echo " Start Stalwart : stalwart-dev/start" - ''; - }; - } - ); -} diff --git a/scripts/check_dagger_versions.sh b/scripts/check_dagger_versions.sh index e479b77..76d8d47 100755 --- a/scripts/check_dagger_versions.sh +++ b/scripts/check_dagger_versions.sh @@ -13,11 +13,6 @@ ROOT=$(git rev-parse --show-toplevel) dagger_json=$(grep -oE '"engineVersion"[[:space:]]*:[[:space:]]*"[^"]+"' "$ROOT/ci/dagger.json" \ | sed -E 's/.*"v?([^"]+)"$/\1/') -# flake.nix — the dagger021 derivation's CLI download URL. -flake_nix=$(grep -oE 'dagger_v[0-9]+\.[0-9]+\.[0-9]+_linux' "$ROOT/flake.nix" \ - | head -n1 \ - | sed -E 's/dagger_v([0-9.]+)_linux/\1/') - # .forgejo/Dockerfile — DAGGER_VERSION env on the install line. dockerfile=$(grep -oE 'DAGGER_VERSION=[0-9]+\.[0-9]+\.[0-9]+' "$ROOT/.forgejo/Dockerfile" \ | head -n1 \ @@ -29,11 +24,10 @@ dagger_md=$(grep -oE 'dagger/nix/v[0-9]+\.[0-9]+\.[0-9]+' "$ROOT/DAGGER.md" \ | sed -E 's@.*/v@@') printf 'ci/dagger.json engineVersion = v%s\n' "$dagger_json" -printf 'flake.nix dagger021 = %s\n' "$flake_nix" printf '.forgejo/Dockerf. DAGGER_VERSION= %s\n' "$dockerfile" printf 'DAGGER.md engine tag = v%s\n' "$dagger_md" -for v in "$flake_nix" "$dockerfile" "$dagger_md"; do +for v in "$dockerfile" "$dagger_md"; do if [ -z "$v" ]; then echo "ERROR: failed to parse a Dagger version reference." >&2 exit 1 @@ -41,7 +35,7 @@ for v in "$flake_nix" "$dockerfile" "$dagger_md"; do if [ "$v" != "$dagger_json" ]; then echo "" >&2 echo "ERROR: Dagger versions are out of sync." >&2 - echo " Align ci/dagger.json, flake.nix, .forgejo/Dockerfile and DAGGER.md to the same version." >&2 + echo " Align ci/dagger.json, .forgejo/Dockerfile and DAGGER.md to the same version." >&2 exit 1 fi done