Skip to content

build(rust): add support for Nix build environment#1738

Merged
gilcu3 merged 15 commits intomainfrom
dsharifi/add-nix-env-support
Jan 14, 2026
Merged

build(rust): add support for Nix build environment#1738
gilcu3 merged 15 commits intomainfrom
dsharifi/add-nix-env-support

Conversation

@DSharifi
Copy link
Contributor

@DSharifi DSharifi commented Jan 11, 2026

closes #1753

Edit:
Note to reviewers, the python environment is explicitly disabled in this PR, as I want to follow up with a proper setup that has the full pytest environment included.

@DSharifi DSharifi marked this pull request as ready for review January 12, 2026 12:05
@DSharifi DSharifi self-assigned this Jan 12, 2026
gilcu3
gilcu3 previously approved these changes Jan 13, 2026
Copy link
Contributor

@gilcu3 gilcu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, tested and worked on my env. Left some questions

EDIT: cargo-shear failed because probably you are using a newer version. Please sync versions with the ones used in CI, we can update them later in sync

README.md Outdated

This repository includes a [flake.nix](flake.nix) file that provides a reproducible development environment using Nix. This environment pre-configures the Rust toolchain, LLVM/Clang tools, NEAR CLI tools, and all necessary system dependencies.
Prerequisites
- **Nix**: Install Nix with [Flakes enabled](https://nixos.wiki/wiki/Flakes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least on arch, the nix daemon must be running as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you have to perform a step to start nix daemon?

Copy link
Contributor Author

@DSharifi DSharifi Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you install it through AUR? I think it's recommended to use the script installer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix recommends the script installer, and arch recommends their package

extra/nix 2.33.0-1 [installed]

and I prefer pacman to handle stuff, so I use the distro package, which requires the nix-daemon running.

pbeza
pbeza previously approved these changes Jan 13, 2026
@DSharifi DSharifi changed the title build: add support for Nix build environment build(rust): add support for Nix build environment Jan 14, 2026
@DSharifi DSharifi dismissed stale reviews from pbeza and gilcu3 via 6e35f7e January 14, 2026 08:19
Comment on lines +147 to +148
zizmor
binaryen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to pin versions of these tools to follow ci, I tried cargo make and it failed because of that. new zizmor versions are less permissive. Same happens with these tools:

cargo-binstall
cargo-deny
cargo-insta
cargo-make
cargo-nextest
cargo-shear
cargo-sort

Copy link
Contributor

@pbeza pbeza Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’d be nice to enforce in CI that these tools use the same versions as defined in .github/workflows/ci.yml. I can open a follow-up issue if we want to tackle this separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding it now. But it would be the wrong way to go about it to keep enforcing the 1;1 mapping.

If we want to maintain that, then CI might as well use nix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned to CI versions except the three packages that are not on CI, so I'll go with latest versions here:

  • cargo-binstall is not pinned to a specific version on CI, so keeping that one as is.
  • cargo-insta (the CLI tool) doesn't exist on CI. The cargo dependency is same as in Cargo.toml.
  • cargo-make not on CI

Copy link
Contributor

@pbeza pbeza Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding it now. But it would be the wrong way to go about it to keep enforcing the 1;1 mapping.

Why’s that? 🤔

If we want to maintain that, then CI might as well use nix

Why not unify the environment this way? 🤔 We’d finally be able to run CI checks locally in exactly the same way as on remote CI. I actually like this idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding it now. But it would be the wrong way to go about it to keep enforcing the 1;1 mapping.

Why’s that? 🤔

Because it adds maintenance overhead to have two update versions for packages in two places. It's easy to miss, and it also causes maintenance burden for whatever script we create to check this.

If we want to maintain that, then CI might as well use nix

Why not? 🤔

You're right to question why not. I 'd like to do this at some point. Then developers and CI have the exact same environment, but it's out of scope for this PR.

I wanted to start small with introducing a flake.nix file to just have a working dev environment as a first step of adding nix support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right to question why not. I 'd like to do this at some point. Then developers and CI have the exact same environment, but it's out of scope for this PR.

I created an issue for it: #1760.

@DSharifi DSharifi enabled auto-merge January 14, 2026 10:21
@DSharifi DSharifi added this pull request to the merge queue Jan 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 14, 2026
@gilcu3 gilcu3 added this pull request to the merge queue Jan 14, 2026
Merged via the queue into main with commit 9900caf Jan 14, 2026
15 checks passed
@gilcu3 gilcu3 deleted the dsharifi/add-nix-env-support branch January 14, 2026 11:04
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.

Create dev environment for rust

3 participants