feat(nix): ❄️ add a flake with package, app and dev shell - #241
Conversation
|
Docs preview: https://pr-241.monoprop-docs.pages.dev |
Why not uv2nix?I evaluated uv2nix for this flake and decided against it.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #241 +/- ##
=======================================
Coverage 97.70% 97.70%
=======================================
Files 14 14
Lines 742 742
Branches 98 98
=======================================
Hits 725 725
Misses 12 12
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more. |
25ed113 to
ac35a4f
Compare
ac35a4f to
3d89440
Compare
1b9be29 to
ded799a
Compare
ded799a to
984f60c
Compare
9e16042 to
b9834aa
Compare
b9834aa to
58d3fd9
Compare
58d3fd9 to
51ce27b
Compare
Assisted-by: Pi:gpt-5.6-sol
Signed-off-by: Roberto Di Remigio Eikås <robertodr@users.noreply.github.com>
`nix build .#monoprop{,-mpi}` builds the bindings, `nix run` drops into a
Python interpreter with monoprop importable, and `nix develop` provides the
toolchain the DevContainer installs so `uv sync` and `just` work unchanged.
The packaged build turns off the C++ unit tests (they resolve msgpack-cxx
through a git fetch the sandbox denies) and `-march=native`, and pins the
version because setuptools-scm cannot read git metadata in the sandbox.
Assisted-by: GitHubCopilot:claude-opus-5
`[build-system] requires` no longer lists mpi4py unconditionally: it now comes from a scikit-build-core override keyed on the `monoprop_ENABLE_MPI` environment variable, which resolves it from PyPI. The build sandbox has no network, so the derivation supplies the store copy for the MPI variant only and keeps that variable unset, setting the CMake option directly instead. Assisted-by: ClaudeCode:claude-opus-5
Export composable serial and MPI packages, package the split nanobind backend, and source the stable sandbox version from VERSION. Keep Nix entrypoints out of Python sdists and validate release tags against the tracked version. Assisted-by: Pi:gpt-5.6-sol
Assisted-by: Pi:gpt-5.6-sol
51ce27b to
6788954
Compare
robertodr
left a comment
There was a problem hiding this comment.
LGTM, thank you @Panadestein.
|
as a follow-up, we can simplify a lot once these two PRs to
|
|
Panadestein
left a comment
There was a problem hiding this comment.
Thanks for the improvements @robertodr !



🤖 AI text below 🤖
Adds a Nix flake so Nix/NixOS users can build and hack on monoprop without installing the C++ toolchain, hwloc, Boost or MPI by hand.
Stacked on #314 — this branch is rebased onto
chore-mpi4py-build-req-dynamicallyand should merge after it.Outputs
nix developuv,just, Node.js, clang-tools, gdb, lcov, doxygennix build .#monopropnix build .#monoprop-mpimonoprop_ENABLE_MPI=ONnix runmonopropimportableInside
nix develop, the existinguv syncandjustworkflows apply unchanged. The shell setsUV_PYTHON_PREFERENCE=only-system(uv's managed interpreters expect a loader NixOS does not provide, and[tool.uv]pinsonly-managed) andLD_LIBRARY_PATHso manylinux wheels resolvelibstdc++.Blocker: the packages do not currently build
nix build .#monopropand.#monoprop-mpiboth fail inpypaBuildPhasewithUnmet dependencies: #243 pinnednanobind==3.0.0and addednanobind-backend>=1.0.0to[build-system] requires, but nixpkgs ships nanobind 2.13.0 and has nonanobind-backendat all. This predates the rebase — it arrived in this branch through its lastMerge branch 'main'and the validation below was never re-run against it. The flake needs the same kind of override it already applies to scikit-build-core before this can merge. The dev shell is unaffected.Deviations from the
uvbuildAll in
nix/monoprop.nixand documented in the building guide:monoprop_ENABLE_ARCH_FLAGSis off, since a store path may be substituted onto a machine other than the one that built it..override { enableArchFlags = true; }restores-march=native.monoprop_ENABLE_MPIenvironment switch, because that switch also appends mpi4py tobuild.requires— a PyPI resolution the sandbox denies. The store copy of mpi4py is supplied as a build input ofmonoprop-mpionly.Notes for reviewers
[build-system] requiresasks for>=1.0.3, so the flake overrides it with the 1.0.3 PyPI sdist. That override should be dropped once nixpkgs catches up.tools/generate-dispatch.pyreads.github/license-header.txtduringcmake --install, but.githubis insdist.exclude. The flake works around it by including that one file in the source set; an sdist-based install would presumably hit the same failure.Validation
On
x86_64-linux, before #243 landed:nix build .#monopropand.#monoprop-mpiboth compiled and passed the import check,nix flake checkpassed,nix runevaluated aMajoranaOperator, anduv syncinsidenix developbuilt the bindings against the Nix toolchain. All of that needs re-running once the nanobind override is in. Darwin andaarch64-linuxare exposed viaflake-utils.lib.eachDefaultSystembut untested.