Nix Reproducibility
One of the primary features of Nix is reproducibility. Visiting the homepage, “reproducible builds and deployments” is shown prominently above the fold, and the intending meaning of “reproducible” is shown just below.
Nix builds packages in isolation from each other. This ensures that they are reproducible and don’t have undeclared dependencies, so if a package works on one machine, it will also work on another.
In my experience, this is mostly true. I really like that Nix packages do not have undeclared dependencies. When I need to build software with really complicated dependencies, Nix is my preferred system for doing so.
It is not always true, however, because a system is only reproducible if all of the parts are reproducible. I have often experienced build failures when using Nix, even when using packages that work on other machines. The problem is that some part of the software that fails is not deterministic.
While continuing to learn Reflex FRP today, I once again ran into one of these situations. A build failed when a reflex-dom-core test suite failed. The actual error had scrolled past my terminal buffer, so all I saw was the following.
2 of 3 test suites (2 of 3 test cases) passed.
builder for '/nix/store/0hj3bdfkw7x9pbmc5yq81rzk9hgh89w9-reflex-dom-core-0.5.2.0.drv' failed with exit code 1
cannot build derivation '/nix/store/zmxzwvagr24fm5yp0g4hzgh69iwaiy7r-ghc-8.6.5-with-packages.drv': 1 dependencies couldn't be built
error: build of '/nix/store/zmxzwvagr24fm5yp0g4hzgh69iwaiy7r-ghc-8.6.5-with-packages.drv' failed
I wanted to see the actual error, so I decided to run
ob run
again and watch the terminal. The only command I ran
in between was hr
-t
, to mark the location in the terminal buffer. The reflex-dom-core
package was built and tested again, but this time it succeeded. There
must be a non-deterministic test in the test suite.
I am happy that the build succeeded so quickly. In the past, I have had build failures that I was unable to resolve.