I'm trying to build a Docker image with Nix at a pinned revision. The file works when it looks like this:

{ pkgs ? import <nixpkgs> { }

pkgs.dockerTools.buildImage {

But fails when it looks like this:

{ pkgs ? (import (builtins.fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/44fc3cb097324c9f9f93313dd3f103e78d722968.tar.gz"; sha256 = "0hxzigajiqjwxbk9bcbvgxq28drq1k2hgmzihs0c441i1wsbqchb";  }) {})

pkgs.dockerTools.buildImage {

The error is:

error: 'buildImage' at /nix/store/pyq9xfm1ikhd70dfzbg6fywyqgcvly1l-source/pkgs/build-support/docker/default.nix:491:5 called with unexpected argument 'copyToRoot'

Any suggestions on what I'm doing wrong?

1 Answer 1


So copyToRoot used to be called contents as changed few months ago in this commit https://github.com/NixOS/nixpkgs/commit/e007eb480c6041fd98b8f9e53bdac2ba82e4648c and your commit points to this old version (I guess it belongs to a different branch than master).

In a recent commit on master like 44fc3cb097324c9f9f93313dd3f103e78d72296 you should not have this issue as you can check https://github.com/NixOS/nixpkgs/blame/44fc3cb097324c9f9f93313dd3f103e78d722968/pkgs/build-support/docker/default.nix#L503

  • Thanks, that's really helpful - I'd grabbed the commit hash from the "nixos-22.05" channel, which presumably has not received the "copyToRoot" change. Is there a way to view the commit hash of whatever it is that "import <nixpkgs>" resolves?
    – Matt R
    Oct 23, 2022 at 18:58
  • 1
    Yes, see e.g. my answer there unix.stackexchange.com/a/721444/169695
    – tobiasBora
    Oct 24, 2022 at 7:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .