dockerTools.buildImage ADD/COPY equivalent

If, for example, I have a python script that I want to copy into a docker image how would I do that with dockerTools.buildImage? I’m looking for something like ADD or COPY in a normal Dockerfile.

You’re looking for contents

I haven’t tested this, but from the description, this should work:

buildImage {
  contents = [

and then should exist at / within the container

Paths will be added to the nixstore, (e.g. /nix/store/… then included as an input for the derivation


I solved by creating a new directory, putting my script there, then including ./directory in contents. Thanks!

Note to anyone in the future stuck on this: it needs to be in a directory, just specifying the filename will give you errors