1

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?

Matt R
  • 375
  • 4
  • 10

1 Answers1

2

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

tobiasBora
  • 3,376
  • 2
  • 23
  • 34
  • 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 " resolves? – Matt R Oct 23 '22 at 18:58
  • 1
    Yes, see e.g. my answer there https://unix.stackexchange.com/a/721444/169695 – tobiasBora Oct 24 '22 at 07:19