Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nix): improve flake.nix, adding checks and formatter #542

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

johnyob
Copy link
Collaborator

@johnyob johnyob commented Aug 15, 2024

Context

Dependencies: #543
Related Tasks: jstz-45, jstz-48

This PR is the first one in the line of work of transitioning our CI to an entirely Nix-based environment.

Description

This PR contains a number of changes (separated into commits):

  • Use crane to build our Rust crates -- crane is a Nix library for building Rust projects with excellent integration into tooling and caching of dependencies
  • Fix the broken derivations for the @jstz-dev/jstz and @jstz-dev/types packages
  • Add cargo unit tests to nix flake checks
  • Configure nix fmt to format the codebase

Manually testing the PR

@johnyob johnyob requested a review from zcabter August 15, 2024 11:05
@johnyob johnyob force-pushed the ajob410@ci/jstz-45-nixing-support branch 2 times, most recently from 3fd514b to a3c4f8c Compare August 15, 2024 11:15
@johnyob johnyob force-pushed the ajob410@ci/jstz-45-nixing-support branch from a3c4f8c to 949544c Compare August 15, 2024 14:17
@johnyob johnyob changed the base branch from main to ajob410@chore/standardise-cargo-toml August 15, 2024 14:17
@johnyob johnyob force-pushed the ajob410@ci/jstz-45-nixing-support branch 2 times, most recently from 6985d84 to 57120bb Compare August 15, 2024 14:51
Base automatically changed from ajob410@chore/standardise-cargo-toml to main August 16, 2024 10:05
@johnyob johnyob force-pushed the ajob410@ci/jstz-45-nixing-support branch from 57120bb to ee3a3a5 Compare August 21, 2024 14:06
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 27.59%. Comparing base (5a0dbe9) to head (f3b2beb).
Report is 7 commits behind head on main.

see 20 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a0dbe9...f3b2beb. Read the comment docs.

nix/crates.nix Outdated Show resolved Hide resolved
@zcabter
Copy link
Collaborator

zcabter commented Aug 22, 2024

Maybe its a good idea to include nix fmt in the pre-commit hook?

flake.nix Show resolved Hide resolved
@zcabter zcabter assigned johnyob and unassigned zcabter Aug 22, 2024
@zcabter
Copy link
Collaborator

zcabter commented Aug 22, 2024

Build and tests runs locally, CI looks good ✅

@johnyob
Copy link
Collaborator Author

johnyob commented Aug 22, 2024

Maybe its a good idea to include nix fmt in the pre-commit hook?

I agree. We should be able to do this fairly easily with https://github.com/cachix/git-hooks.nix. Perhaps a different PR?

johnyob and others added 4 commits August 22, 2024 16:31
This commit switches our nix build to use crane. Crane not only has better support for building in Cargo workspaces,
but also permits one to only build all workspace dependencies.
This is extremely useful for caching all our Rust dependencies.

Co-authored-by: zcabter <[email protected]>
This commit fixes the existing (broken) Nix support for building our TypeScript packages.
We have to (unfortunately) rely on an overlay for buildNpmPackage since the current support
in Nixpkgs is broken
This commit uses cargo-nextest to run the cargo tests in `nix flake check`.
This commit configures rustfmt, alejandra, prettier, and shfmt.
@johnyob johnyob force-pushed the ajob410@ci/jstz-45-nixing-support branch from 6fa393f to f3b2beb Compare August 22, 2024 15:31
@johnyob johnyob assigned zcabter and unassigned johnyob Aug 22, 2024
@zcabter
Copy link
Collaborator

zcabter commented Aug 22, 2024

Maybe its a good idea to include nix fmt in the pre-commit hook?

I agree. We should be able to do this fairly easily with https://github.com/cachix/git-hooks.nix. Perhaps a different PR?

Ok let's do it in a follow up. Tracked here: https://linear.app/tezos/issue/JSTZ-73/run-nix-fmt-in-pre-commit-hook

@zcabter zcabter removed their assignment Aug 22, 2024
@johnyob johnyob merged commit 0e4da48 into main Aug 22, 2024
8 checks passed
@johnyob johnyob deleted the ajob410@ci/jstz-45-nixing-support branch August 22, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants