Skip to content

Add Nix devshell flake#138

Merged
jamjamjon merged 1 commit into
jamjamjon:mainfrom
glasgow-haskell-omelette:nix
Sep 23, 2025
Merged

Add Nix devshell flake#138
jamjamjon merged 1 commit into
jamjamjon:mainfrom
glasgow-haskell-omelette:nix

Conversation

@glasgow-haskell-omelette

Copy link
Copy Markdown
Contributor

this is just here for convenience. feel free to reject it if so desired

@glasgow-haskell-omelette glasgow-haskell-omelette marked this pull request as ready for review September 22, 2025 06:06
@glasgow-haskell-omelette

Copy link
Copy Markdown
Contributor Author

did not mean to make this one a draft

@jamjamjon

Copy link
Copy Markdown
Owner

@glasgow-haskell-omelette Thanks for the contribution! I don't personally use Nix, but I can see how this
flake.devShell would be convenient for people who do.

A couple of notes regarding our setup:

  • Our project uses rust-toolchains.toml to pin Rust to version 1.85. The current
    flake setup will use the Rust version from nixos-unstable, which may be newer
    than 1.85. This is usually fine, but just wanted to make you aware.
  • Regarding onnxruntime: the Rust ort crate normally downloads its own version
    of the C library during build, including different versions if using CUDA,
    CoreML, or other execution providers. I'm not sure whether the Nix-provided
    onnxruntime in this devshell could interfere with that, and whether it also
    downloads the corresponding versions when using different execution providers.
    Could you clarify how this works in the flake setup?

I'm happy to merge this PR if the community is willing to maintain the devshell
as needed. Thanks again for putting this together!

@glasgow-haskell-omelette

glasgow-haskell-omelette commented Sep 23, 2025

Copy link
Copy Markdown
Contributor Author
  • Our project uses rust-toolchains.toml to pin Rust to version 1.85. The current
    flake setup will use the Rust version from nixos-unstable, which may be newer
    than 1.85. This is usually fine, but just wanted to make you aware.

The flake shouldn't actually depend on any specific Rust version. The only thing it does currently is provide an environment with the necessary libraries to avoid having to figure out what one needs to add - so not that much. Not sure how rustPlatform.bindgenHook interacts with different versions, but using it with a non-nixpkgs nightly release works just fine.

  • Regarding onnxruntime: the Rust ort crate normally downloads its own version
    of the C library during build, including different versions if using CUDA,
    CoreML, or other execution providers. I'm not sure whether the Nix-provided
    onnxruntime in this devshell could interfere with that, and whether it also
    downloads the corresponding versions when using different execution providers.
    Could you clarify how this works in the flake setup?

Good point. Adding a library like this is functionally more or less equivalent to just installing it on a normal distro, and so should not interfere with anything, and will really only do anything when using the "system" strategy.

CUDA and ROCm support for packages in Nixpkgs is generally managed through a central setting in the system's nixpkgs configuration, but can be overriden on a per-package basis. Unfortunately, there isn't a similar toggle for things like OpenVINO. The ONNXRuntime package in Nixpkgs also doesn't support ROCm - only CUDA.

@jamjamjon

Copy link
Copy Markdown
Owner

@glasgow-haskell-omelette Thanks for the clarification! I understand now that the flake mainly provides a convenient dev environment and doesn’t depend on a specific Rust version. It’s also good to know that the Nix-provided onnxruntime shouldn’t interfere with the Rust ort crate.

I’m happy to merge this PR, as long as the community is willing to maintain the devshell. Thanks for taking the time to do this!

@jamjamjon jamjamjon merged commit 101c9e2 into jamjamjon:main Sep 23, 2025
9 checks passed
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