rustls / rustls-platform-verifier

A certificate verification library for rustls that uses the operating system's verifier
Apache License 2.0
57 stars 18 forks source link

proj: add initial Nix flake support #73

Closed cpu closed 2 months ago

cpu commented 4 months ago

The tooling required to work in this repo can be a little bit challenging to set up (largely as a side effect of supporting multiple platforms/languages, each with their own tooling requirements).

In an effort to make this easier and more reproducible this commit adds the start of a Nix flake.

Some starting points (assuming you've set up nix, which is outside of the scope of this PR):

There's also an android-emu output for creating an Android device emulator that can be used to run unit tests:

# Terminal 1 - Android emulator
nix develop
nix build .#android-emu
./result/bin/run-test-emulator&
adb devices
adb logcat
# Terminal 2 - Unit tests
nix develop
pushd android && ./gradlew connectedAndroidTest

Future work:

djc commented 4 months ago

I think @Ralith has some Nix experience, maybe he can help review?

cpu commented 4 months ago

I don't have a lot of experience with flakes specifically, but this looks generally reasonable.

Thanks for taking a look :-)

I think we should have CI coverage for it.

I pushed a simple CI job :+1:

cpu commented 4 months ago

It should be possible to configure an Android emulator, and to run the unit tests within the emulator, without using Android studio or manually configuring an emulator.

I pushed one last revision to add an emulator image output. The PR description is updated with some quick usage instructions. This is sufficient for being able to build the project and run the Android tests in an emulator without doing any manual setup in Android studio.

Going to call this done for now and pick up on the NDK version pinning the next time I have a chance to fiddle with this.

cpu commented 2 months ago

CI / Clippy (-Zbuild-std) (pull_request) Failing after 14s cargo deny / audit (pull_request) Failing after 23s CI / Test (Android) (pull_request) Failing after 6m

Unrelated to this branch, resolving these in https://github.com/rustls/rustls-platform-verifier/pull/91

@complexspaces Are you thinking that you'd like to do some further reviewing/testing of this branch or could it be merged soon?

cpu commented 2 months ago

I've gotten slightly better (only slightly šŸ˜„) with Nix since I last looked at this, but AFAICT this looks fine. I'm looking forward to trying this out when time permits.

Awesome! I'm not particularly skilled myself so I'm sure there are some improvements we could make down the road. šŸš€

cpu commented 2 months ago

cpu force-pushed the cpu-start-nix-flake_dev branch from 25440f2 to 58a085c

Rebased on main to pick up the CI fixes. Will merge once this is all green.