While it might be possible, it's not very practical.
The original Nix thesis [0] talks about using Nix as a low-level build system in Chapter 10.1. And the author of opam-nix* has made an attempt to use Nix as a build system [1]. However, dune is a complicated bit of software that's not easy to replicate, and Nix isn't particularly well suited to the task.
The original Nix thesis [0] talks about using Nix as a low-level build system in Chapter 10.1. And the author of opam-nix* has made an attempt to use Nix as a build system [1]. However, dune is a complicated bit of software that's not easy to replicate, and Nix isn't particularly well suited to the task.
[0] https://edolstra.github.io/pubs/phd-thesis.pdf
[1] https://gitlab.com/balsoft/tumbleweed
*Which is essentially functionality to use Nix as a dependency manger with opam-repository.