0

I am experimenting with tools like Docker and nix to see if there is a modern solution to build environment dependency hell.

Docker has no knowledge or ability to cache packages downloaded within the (usually linux) environment inside the container; it does cache intermediate parts of the build for each line in your Dockerfile, but if your bloated dependency pulls in half of ubuntu from apt, Docker is going to download it from scratch any time you change anything above it in our Dockerfile.

Nix seems to have promising infrastructure for maintaining the dependency tree, as well as sharing/caching dependencies of any number of versions, but doesn't enforce isolation nearly as strongly; processes by default will still be able to access your whole tree; they're built to only go through the nix tree for shared libraries and such.

Is there some sane way to combine the benefits of nix and Docker (or some other existing tool) to have caching of binaries and encapsulation work at the same time?

Some ideas:

  • Docker + local ubuntu mirror + btrfs to achieve caching?
  • nix + chroot with a flag to keep the nix database shared?

Note, I'm interested in something language/ecosystem agnostic, and that has good coverage of open-source libraries.

Andrew Wagner
  • 22,677
  • 21
  • 86
  • 100
  • Update: I just found https://coderwall.com/p/pcg_rg/speed-up-your-installs-with-a-docker-ized-apt-cacher-ng – Andrew Wagner May 17 '16 at 14:10
  • 1
    nix can do chroot builds. On NixOS there are nix-containers which provide (to nearly the same extend) what you're probably looking for. – Daniel Jour May 31 '16 at 22:30
  • You can build images with Nix to achieve non-linear caching. You will need a deduplicating filesystem to recover sharing, so it is not optimal, but close. See https://stackoverflow.com/questions/43375880/how-to-build-a-docker-container-with-nix – Robert Hensing Apr 13 '17 at 12:05
  • @Robert, thanks for the response! I haven't done much more on this besides gaining some more experience with nix, but I lost steam when I couldn't get it to work for multiple users in a reasonable amount of time. – Andrew Wagner Apr 14 '17 at 08:07

0 Answers0