Copy —from image the nix way

What’s the nix way of doing a copy from another image in a multistage style of build?

The scenario is that I have a base container that contains some artifacts (pre-built) that I use to copy some files into the final image. I can’t find any examole that does that. I’m also fairly new in nix so probably there’s a concept that I’m missing.

I think the difference is that nix does not build container images imperatively in a container like docker does. You simply describe the derivations whose end-results you want in the final container image and any intermediate builds just happen in a nix sandbox on the build machine, not in an intermediate container or such.

So in this case, I think you’d write a derivation that produces the files that you need as its output, and then you’d depend on that derivation in the derivation for your final image.

The derivation that outputs the files can then use a fetcher or such to grab that base image and extract the files from it (or grab the files in another way of they are available directly somewhere online or such).

1 Like