Add pip library to image with dockerTools buildImage

I want to add a library to a docker image, normally on a Dockerfile it would be to just add pip install {library} to a new Dockerfile with the base image.

But I cannot get the same result in nix using dockerTools.buildImage.

This is my code so far:

  superset_image = lib.mkForce (pkgs.dockerTools.buildImage {
      name = "superset_clickhouse";
      tag = "latest";

      fromImage = pkgs.dockerTools.pullImage {
        imageName = "apachesuperset.docker.scarf.sh/apache/superset";
        imageDigest = "sha256:afcd2f63479e29da06944087a29e7788f9ecd0250f4611e52aee1c844187e3eb";
        sha256 = "sha256-STtunkPFJ1dO7vLkvk0zbLfLXUPbgYx2X5JR5+mYaHQ=";
      };

      extraCommands = ''
        pip install 'clickhouse-connect>=0.6.8'
      '';

      diskSize = 4000;
    });

I’ve also tried with runAsRoot = ‘’…‘’

The error message I get is:

      > /build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 15: pip: command not found

How can I add the library I want to the docker image?