diff --git a/.github/workflows/nix_tests.yaml b/.github/workflows/nix_tests.yaml index f2209f8a..06768a7b 100644 --- a/.github/workflows/nix_tests.yaml +++ b/.github/workflows/nix_tests.yaml @@ -38,4 +38,4 @@ jobs: env: HF_TOKEN: ${{ secrets.HF_TOKEN }} - name: Rust tests. - run: nix develop .#test --command cargo test + run: nix build .#checks.$(nix eval --impure --raw --expr 'builtins.currentSystem').rust -L diff --git a/flake.nix b/flake.nix index c6adf0a6..3d349ff2 100644 --- a/flake.nix +++ b/flake.nix @@ -69,7 +69,29 @@ server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; }; in { + checks = { + rust = with pkgs; rustPlatform.buildRustPackage { + name = "rust-checks"; + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + buildInputs = [ openssl.dev ]; + nativeBuildInputs = [ clippy pkg-config protobuf python3 rustfmt ]; + buildPhase = '' + cargo check + ''; + checkPhase = '' + cargo fmt -- --check + cargo test -j $NIX_BUILD_CORES + cargo clippy + ''; + installPhase = "touch $out"; + } ; + }; + formatter = pkgs.nixfmt-rfc-style; + devShells = with pkgs; rec { default = pure;