diff --git a/.cargo/nextest.toml b/.cargo/nextest.toml index 07216b1ff..b7afc9364 100644 --- a/.cargo/nextest.toml +++ b/.cargo/nextest.toml @@ -1,2 +1,3 @@ [profile.default] retries = 3 +default-filter = "not test(test_stream_all_messages_does_not_lose_messages)" diff --git a/.github/workflows/release-xdbg.yml b/.github/workflows/release-xdbg.yml new file mode 100644 index 000000000..80fb6e23a --- /dev/null +++ b/.github/workflows/release-xdbg.yml @@ -0,0 +1,50 @@ +name: Build and Push xmtp-debug to ghcr +on: + push: + branches: + - main + workflow_dispatch: +jobs: + build-and-push: + runs-on: ubuntu-latest + strategy: + matrix: + platform: [aarch64-darwin, x86_64-linux, aarch64-linux, x86_64-darwin] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Nix + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v14 + with: + name: xmtp + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build xdbgDocker + run: | + nix build .#packages.${{ matrix.platform }}.xdbgDocker + - name: Build xdbg Binary + run: | + nix build .#packages.${{ matrix.platform }}.xdbg + nix path-info .#packages.${{ matrix.platform }}.xdbg | xargs -I {} cp {}/bin/xdbg ./xdbg-${{ matrix.platform }} + - name: Log in to GitHub Container Registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Tag Docker image + run: | + IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:xdbg-${{ matrix.platform }} + nix path-info .#packages.${{ matrix.platform }}.xdbgDocker | xargs -I {} docker load < {}/docker-image.tar.gz + docker tag $(docker images --filter "label=org.opencontainers.image.title=xdbg" -q):latest $IMAGE_NAME + - name: Push Docker image to GHCR + run: | + IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:xdbg-${{ matrix.platform }} + docker push $IMAGE_NAME + - name: Upload xdbg binary to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./xdbg-${{ matrix.platform }} + asset_name: xdbg-${{ matrix.platform }} + asset_content_type: application/octet-stream diff --git a/.github/workflows/test-http-api.yml b/.github/workflows/test-http-api.yml index e906f38aa..92e6c60cb 100644 --- a/.github/workflows/test-http-api.yml +++ b/.github/workflows/test-http-api.yml @@ -41,6 +41,6 @@ jobs: - name: Install nextest uses: taiki-e/install-action@nextest - name: build tests - run: cargo nextest run --no-run --tests --workspace --exclude xmtp_api_grpc --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm --features http-api + run: cargo nextest run --config-file ".cargo/nextest.toml" --no-run --tests --workspace --exclude xmtp_api_grpc --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm --features http-api - name: cargo test - run: cargo nextest run --workspace --exclude xmtp_api_grpc --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm --features http-api --test-threads 2 + run: cargo nextest run --config-file ".cargo/nextest.toml" --workspace --exclude xmtp_api_grpc --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm --features http-api --test-threads 2 diff --git a/.gitignore b/.gitignore index 335703a8f..b9fd9a534 100644 --- a/.gitignore +++ b/.gitignore @@ -166,3 +166,5 @@ ecies_bindings_wasm/ **/tracing-flamegraph.svg chain_urls.json +result/** +result diff --git a/dev/release-kotlin b/dev/release-kotlin index 74e507509..3580e9d32 100755 --- a/dev/release-kotlin +++ b/dev/release-kotlin @@ -35,7 +35,7 @@ fi LIBRARY_NAME="libxmtpv3" TARGET_NAME="libuniffi_xmtpv3" -nix develop . --command cargo ndk -o bindings_ffi/jniLibs/ --manifest-path ./bindings_ffi/Cargo.toml \ +nix develop .#android --command cargo ndk -o bindings_ffi/jniLibs/ --manifest-path ./bindings_ffi/Cargo.toml \ -t aarch64-linux-android \ -t x86_64-linux-android \ -t i686-linux-android \ diff --git a/flake.lock b/flake.lock index b46041fed..ac17cfbc2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1733688869, + "narHash": "sha256-KrhxxFj1CjESDrL5+u/zsVH0K+Ik9tvoac/oFPoxSB8=", + "owner": "ipetkov", + "repo": "crane", + "rev": "604637106e420ad99907cae401e13ab6b452e7d9", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "fenix": { "inputs": { "nixpkgs": [ @@ -8,11 +23,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1729492502, - "narHash": "sha256-d6L4bBlUWr4sHC+eRXo+4acFPEFXKmqHpM/BfQ5gQQw=", + "lastModified": 1734071760, + "narHash": "sha256-i5/1cvgahF0lvtRkg9aKlYr0SuE8hNO7xaqvdkc+qXE=", "owner": "nix-community", "repo": "fenix", - "rev": "4002a1ec3486b855f341d2b864ba06b61e73af28", + "rev": "db0bcf236f561ebbac1204074757c26c53a3d63c", "type": "github" }, "original": { @@ -21,55 +36,69 @@ "type": "github" } }, - "flake-utils": { + "flake-parts": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1729307008, - "narHash": "sha256-QUvb6epgKi9pCu9CttRQW4y5NqJ+snKr1FZpG/x3Wtc=", + "lastModified": 1733940404, + "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a9b86fc2290b69375c5542b622088eb6eca2a7c3", + "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.05", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1733096140, + "narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" + } + }, "root": { "inputs": { + "crane": "crane", "fenix": "fenix", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems" } }, "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1729454508, - "narHash": "sha256-1W5B/CnLgdC03iIFG0wtawO1+dGDWDpc84PeOHo2ecU=", + "lastModified": 1734022706, + "narHash": "sha256-rIz8/rsTP5N7uLSyFbHZ+ink6EHBKkWFAQPkzhq7/YM=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "9323b5385863739d1c113f02e4cf3f2777c09977", + "rev": "9b2e72c40454012cbac8a1aa94d65931e3a7b881", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index df8aaf766..a738e9bb6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,98 +1,119 @@ # Flake Shell for building release artifacts for swift and kotlin { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; fenix = { url = "github:nix-community/fenix"; inputs = { nixpkgs.follows = "nixpkgs"; }; }; + systems.url = "github:nix-systems/default"; + # A nix-native packaging system for rust (docs: https://crane.dev/index.html) + crane.url = "github:ipetkov/crane"; - flake-utils = { url = "github:numtide/flake-utils"; }; + flake-parts.url = "github:hercules-ci/flake-parts"; }; - outputs = { nixpkgs, flake-utils, fenix, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - inherit (pkgs.stdenv) isDarwin; - inherit (pkgs) androidenv; - inherit (androidComposition) androidsdk; - frameworks = if isDarwin then pkgs.darwin.apple_sdk.frameworks else null; - pkgs = import nixpkgs { - inherit system; - # Rust Overlay - overlays = [ fenix.overlays.default ]; - config = { - android_sdk.accept_license = true; - allowUnfree = true; - }; - }; - - android = { - platforms = [ "34" ]; - platformTools = "33.0.3"; - buildTools = [ "30.0.3" ]; - }; + nixConfig = { + extra-trusted-public-keys = "xmtp.cachix.org-1:nFPFrqLQ9kjYQKiWL7gKq6llcNEeaV4iI+Ka1F+Tmq0="; + extra-substituters = "https://xmtp.cachix.org"; + }; - sdkArgs = { - platformVersions = android.platforms; - platformToolsVersion = android.platformTools; - buildToolsVersions = android.buildTools; - includeNDK = true; - }; + outputs = inputs@{ flake-parts, fenix, crane, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = import inputs.systems; + perSystem = { pkgs, lib, system, ... }: + let + androidTargets = [ + "aarch64-linux-android" + "armv7-linux-androideabi" + "x86_64-linux-android" + "i686-linux-android" + ]; - androidTargets = [ - "aarch64-linux-android" - "armv7-linux-androideabi" - "x86_64-linux-android" - "i686-linux-android" - ]; + # Pinned Rust Version + rust-toolchain = with fenix.packages.${system}; combine [ + stable.cargo + stable.rustc + (lib.forEach + androidTargets + (target: targets."${target}".stable.rust-std)) + targets.x86_64-unknown-linux-musl.stable.rust-std + ]; - # Pinned Rust Version - rust-toolchain = with fenix.packages.${system}; combine [ - stable.cargo - stable.rustc - (pkgs.lib.forEach - androidTargets - (target: targets."${target}".stable.rust-std)) - ]; + pkgConfig = { + inherit system; + overlays = [ fenix.overlays.default ]; + config = { + android_sdk.accept_license = true; + allowUnfree = true; + }; + }; - # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md - androidHome = "${androidComposition.androidsdk}/libexec/android-sdk"; - androidComposition = androidenv.composeAndroidPackages sdkArgs; + # Library to build rust crates & test them + # Set the rust toolchain package/versioning + craneLib = (crane.mkLib pkgs).overrideToolchain (p: rust-toolchain); - # Packages available to flake while building the environment - nativeBuildInputs = with pkgs; [ pkg-config ]; - # Define the packages available to the build environment - # https://search.nixos.org/packages - buildInputs = with pkgs; [ - rust-toolchain - kotlin - androidsdk - jdk17 - cargo-ndk + inherit (craneLib.fileset) commonCargoSources; - # System Libraries - sqlite - openssl - ] ++ lib.optionals isDarwin [ - # optional packages if on darwin, in order to check if build passes locally - libiconv - frameworks.CoreServices - frameworks.Carbon - frameworks.ApplicationServices - frameworks.AppKit - darwin.cctools - ]; - in - { - devShells.default = pkgs.mkShell { - OPENSSL_DIR = "${pkgs.openssl.dev}"; - ANDROID_HOME = androidHome; - ANDROID_SDK_ROOT = androidHome; # ANDROID_SDK_ROOT is deprecated, but some tools may still use it; - ANDROID_NDK_ROOT = "${androidHome}/ndk-bundle"; + libFileSetForWorkspace = lib.fileset.unions [ + ./Cargo.toml + ./Cargo.lock + (commonCargoSources ./xmtp_api_grpc) + (commonCargoSources ./xmtp_api_http) + (commonCargoSources ./xmtp_cryptography) + (commonCargoSources ./xmtp_id) + (commonCargoSources ./xmtp_mls) + (commonCargoSources ./xmtp_proto) + (commonCargoSources ./xmtp_v2) + (commonCargoSources ./xmtp_user_preferences) + (commonCargoSources ./common) + (commonCargoSources ./xmtp_content_types) + ./xmtp_id/src/scw_verifier/chain_urls_default.json + ./xmtp_id/artifact + ./xmtp_mls/migrations + ]; + binFileSetForWorkspace = lib.fileset.unions [ + (commonCargoSources ./examples/cli) + (commonCargoSources ./mls_validation_service) + (commonCargoSources ./bindings_node) + (commonCargoSources ./bindings_wasm) + (commonCargoSources ./xtask) + (commonCargoSources ./bindings_ffi) + (commonCargoSources ./xmtp_debug) + ]; + fileSetForCrate = crate: lib.fileset.unions [ + libFileSetForWorkspace + crate + ]; + fileSetForWorkspace = lib.fileset.unions [ + binFileSetForWorkspace + libFileSetForWorkspace + ]; + filesets = { + inherit + fileSetForWorkspace + binFileSetForWorkspace + libFileSetForWorkspace + fileSetForCrate; + }; - inherit buildInputs nativeBuildInputs; + xdbg = import ./nix/xdbg { + inherit pkgs craneLib filesets; + }; + validationService = import ./nix/mls_validation_service { + inherit pkgs craneLib filesets; + }; + in + { + _module.args.pkgs = import inputs.nixpkgs pkgConfig; + devShells.android = pkgs.callPackage ./nix/android.nix { inherit rust-toolchain; }; + packages = { + xdbg = xdbg.bin; + xdbgDocker = xdbg.dockerImage; + validationService = validationService.bin; + validationServiceDocker = validationService.dockerImage; + }; }; - }); + }; } diff --git a/nix/android.nix b/nix/android.nix new file mode 100644 index 000000000..fbba2150a --- /dev/null +++ b/nix/android.nix @@ -0,0 +1,64 @@ +{ mkShell +, darwin +, androidenv +, stdenv +, pkg-config +, kotlin +, jdk17 +, cargo-ndk +, sqlite +, openssl +, lib +, rust-toolchain +}: +let + frameworks = if stdenv.isDarwin then darwin.apple_sdk.frameworks else null; + inherit (androidComposition) androidsdk; + + android = { + platforms = [ "34" ]; + platformTools = "33.0.3"; + buildTools = [ "30.0.3" ]; + }; + + sdkArgs = { + platformVersions = android.platforms; + platformToolsVersion = android.platformTools; + buildToolsVersions = android.buildTools; + includeNDK = true; + }; + + # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md + androidHome = "${androidComposition.androidsdk}/libexec/android-sdk"; + androidComposition = androidenv.composeAndroidPackages sdkArgs; + +in +mkShell { + OPENSSL_DIR = "${openssl.dev}"; + ANDROID_HOME = androidHome; + ANDROID_SDK_ROOT = androidHome; # ANDROID_SDK_ROOT is deprecated, but some tools may still use it; + ANDROID_NDK_ROOT = "${androidHome}/ndk-bundle"; + + # Packages available to flake while building the environment + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ + rust-toolchain + kotlin + androidsdk + jdk17 + cargo-ndk + + # System Libraries + sqlite + openssl + ] ++ lib.optionals stdenv.isDarwin [ + # optional packages if on darwin, in order to check if build passes locally + frameworks.CoreServices + frameworks.Carbon + frameworks.ApplicationServices + frameworks.AppKit + darwin.cctools + ]; +} + diff --git a/nix/mls_validation_service/crate.nix b/nix/mls_validation_service/crate.nix new file mode 100644 index 000000000..e3bca831e --- /dev/null +++ b/nix/mls_validation_service/crate.nix @@ -0,0 +1,95 @@ +{ openssl +, sqlite +, sqlcipher +, perl +, lib +, pkg-config +, stdenv +, craneLib +, darwin +, filesets +, mkShell +, rustTarget ? null +}: +let + inherit (stdenv) hostPlatform; + upperTarget = lib.strings.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] rustTarget); + + filesetForCrate = crate: lib.fileset.toSource { + root = ./../..; + fileset = filesets.filesetForCrate crate; + }; + + filesetForWorkspace = lib.fileset.toSource { + root = ./../..; + fileset = filesets.fileSetForWorkspace; + }; + + linkerArgs = if rustTarget == null then { } else { + HOST_CC = "${stdenv.cc.nativePrefix}cc"; + TARGET_CC = "${stdenv.cc.targetPrefix}cc"; + # https://docs.rs/openssl/latest/openssl/#manual + "${upperTarget}_OPENSSL_DIR" = "${openssl.out}"; + "${upperTarget}_OPENSSL_LIB_DIR" = "${openssl.out}/lib"; + "${upperTarget}_OPENSSL_INCLUDE_DIR" = "${openssl.dev}/include"; + # Important because otherwise nix won't be able to link in the correct + # openssl library from the cross pkg set + OPENSSL_NO_VENDOR = 1; + CARGO_BUILD_TARGET = rustTarget; + "CARGO_TARGET_${upperTarget}_LINKER" = "${stdenv.cc.targetPrefix}cc"; + }; + + commonArgs = { + src = filesetForWorkspace; + strictDeps = true; + + # Used to build on the current/build machine + nativeBuildInputs = [ + pkg-config + stdenv.cc + perl + ]; + + # Libraries that will run on the host machine + # that to be linked + buildInputs = [ + # Add additional build inputs here + openssl + sqlite + sqlcipher + ] ++ lib.optionals hostPlatform.isDarwin + (with darwin.apple_sdk; + [ + frameworks.Security + frameworks.SystemConfiguration + ]); + + doCheck = false; + cargoExtraArgs = "--workspace --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm --exclude xmtp_cli --exclude xtask"; + RUSTFLAGS = [ "--cfg" "tracing_unstable" ]; + OPENSSL_DIR = "${openssl.out}"; + OPENSSL_INCLUDE_DIR = "${openssl.dev}/include"; + } // linkerArgs; + + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + + bin = craneLib.buildPackage ({ + inherit cargoArtifacts; + inherit (craneLib.crateNameFromCargoToml { + cargoToml = ./../../mls_validation_service/Cargo.toml; + }) version pname; + cargoExtraArgs = "--package mls_validation_service"; + src = filesetForCrate ./../../mls_validation_service; + doCheck = false; + + RUST_BACKTRACE = 1; + } // commonArgs); + + devShell = mkShell + { + inputsFrom = [ bin ]; + }; +in +{ + inherit bin devShell; +} diff --git a/nix/mls_validation_service/default.nix b/nix/mls_validation_service/default.nix new file mode 100644 index 000000000..6579ba2c3 --- /dev/null +++ b/nix/mls_validation_service/default.nix @@ -0,0 +1,27 @@ +{ + pkgs, + craneLib, + filesets, +}: +let + mls_validation_service = pkgs.callPackage ./crate.nix { inherit craneLib filesets; }; + muslService = pkgs.pkgsCross.musl64.callPackage ./crate.nix { + inherit craneLib filesets; + rustTarget = "x86_64-unknown-linux-musl"; + }; + + dockerImage = pkgs.dockerTools.buildImage { + name = "xmtp/mls-validation-service"; + tag = "latest"; + contents = [ muslService.bin ]; + config = { + Cmd = [ "${muslService.bin}/bin/mls-validation-service" ]; + }; + }; +in +{ + + inherit (mls_validation_service) bin devShell; + inherit muslService; + inherit dockerImage; +} diff --git a/nix/xdbg/crate.nix b/nix/xdbg/crate.nix new file mode 100644 index 000000000..201f81600 --- /dev/null +++ b/nix/xdbg/crate.nix @@ -0,0 +1,95 @@ +{ openssl +, sqlite +, sqlcipher +, perl +, lib +, pkg-config +, stdenv +, craneLib +, darwin +, filesets +, mkShell +, rustTarget ? null +}: +let + inherit (stdenv) hostPlatform; + upperTarget = lib.strings.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] rustTarget); + + filesetForCrate = crate: lib.fileset.toSource { + root = ./../..; + fileset = filesets.filesetForCrate crate; + }; + + filesetForWorkspace = lib.fileset.toSource { + root = ./../..; + fileset = filesets.fileSetForWorkspace; + }; + + linkerArgs = if rustTarget == null then { } else { + HOST_CC = "${stdenv.cc.nativePrefix}cc"; + TARGET_CC = "${stdenv.cc.targetPrefix}cc"; + # https://docs.rs/openssl/latest/openssl/#manual + "${upperTarget}_OPENSSL_DIR" = "${openssl.out}"; + "${upperTarget}_OPENSSL_LIB_DIR" = "${openssl.out}/lib"; + "${upperTarget}_OPENSSL_INCLUDE_DIR" = "${openssl.dev}/include"; + # Important because otherwise nix won't be able to link in the correct + # openssl library from the cross pkg set + OPENSSL_NO_VENDOR = 1; + CARGO_BUILD_TARGET = rustTarget; + "CARGO_TARGET_${upperTarget}_LINKER" = "${stdenv.cc.targetPrefix}cc"; + }; + + commonArgs = { + src = filesetForWorkspace; + strictDeps = true; + + # Used to build on the current/build machine + nativeBuildInputs = [ + pkg-config + stdenv.cc + perl + ]; + + # Libraries that will run on the host machine + # that to be linked + buildInputs = [ + # Add additional build inputs here + openssl + sqlite + sqlcipher + ] ++ lib.optionals hostPlatform.isDarwin + (with darwin.apple_sdk; + [ + frameworks.Security + frameworks.SystemConfiguration + ]); + + doCheck = false; + cargoExtraArgs = "--workspace --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm --exclude xmtp_cli --exclude xtask"; + RUSTFLAGS = [ "--cfg" "tracing_unstable" ]; + OPENSSL_DIR = "${openssl.out}"; + OPENSSL_INCLUDE_DIR = "${openssl.dev}/include"; + } // linkerArgs; + + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + + bin = craneLib.buildPackage ({ + inherit cargoArtifacts; + inherit (craneLib.crateNameFromCargoToml { + cargoToml = ./../../xmtp_debug/Cargo.toml; + }) version pname; + cargoExtraArgs = "--package xdbg"; + src = filesetForCrate ./../../xmtp_debug; + doCheck = false; + + RUST_BACKTRACE = 1; + } // commonArgs); + + devShell = mkShell + { + inputsFrom = [ bin ]; + }; +in +{ + inherit bin devShell; +} diff --git a/nix/xdbg/default.nix b/nix/xdbg/default.nix new file mode 100644 index 000000000..07ed11cd2 --- /dev/null +++ b/nix/xdbg/default.nix @@ -0,0 +1,23 @@ +{ pkgs, craneLib, filesets }: +let + xdbg = pkgs.callPackage ./crate.nix { inherit craneLib filesets; }; + muslXDbg = pkgs.pkgsCross.musl64.callPackage ./crate.nix { + inherit craneLib filesets; rustTarget = "x86_64-unknown-linux-musl"; + }; + + dockerImage = pkgs.dockerTools.buildImage { + name = "xmtp/xdbg"; + tag = "latest"; + copyToRoot = [ muslXDbg.bin ]; + config = { + Cmd = [ "${muslXDbg.bin}/bin/xdbg" ]; + }; + }; +in +{ + + inherit (xdbg) bin devShell; + inherit muslXDbg; + inherit dockerImage; +} + diff --git a/rust-toolchain b/rust-toolchain index d9aa0516c..69af1791b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -3,7 +3,6 @@ channel = "stable" components = [ "rustc", "cargo", "clippy", "rustfmt", "rust-analyzer" ] targets = [ "wasm32-unknown-unknown", - "x86_64-unknown-linux-gnu", "x86_64-apple-ios", "x86_64-apple-darwin", "aarch64-apple-ios"