Pnpm is not accessible in the docker image

Hi all,

I am a newbie here. I am trying to set up a small dev environment, and already successfully set up nix-shell. But after all, I need support GitLab CI for it. So, after some research, I decided to build a docker image with the same list of dependencies as nix-shell has. After all, I got the image, but somehow pnpm is not in /bin and is not assessable.

"pnpm": executable file not found in $PATH

What would be the easiest way to solve/workaround this issue in the nix way?

Here are my nix files.

source.nix

{
  nixpkgs = fetchTarball {
    name   = "nixpkgs-unstable-on-december-9-2022";
    url    = "https://github.com/NixOS/nixpkgs/archive/aaac4123e3e33e779af54361a244857d029a64dd.tar.gz";
    sha256 = "1ziz5yajnnc3nlfyzw3kbll5k0p7ba07k70vqpcxfxc1cl7wfw47";
  };
}

dependencies.nix

pkgs: with pkgs; [
  go-task
  awscli2
  pulumi-bin
  nodejs
  nodePackages.pnpm
  esbuild
]

docker.nix

let
  source = import ./source.nix;

  pkgs = import source.nixpkgs {};

  dependencies = import ./dependencies.nix pkgs;

  extra = with pkgs; [
    bash
    coreutils
  ];

in pkgs.dockerTools.buildLayeredImage {
  name = "shell-ci";
  tag = "latest";
  created = "now";
  contents = dependencies ++ extra;
  config   = {
    Cmd = [ "${pkgs.bash}/bin/bash" ];
  };
}

Simple buildImage works correctly.

docker.nix

in pkgs.dockerTools.buildImage {
  name = "shell-ci";
  tag = "latest";
  created = "now";

  copyToRoot = pkgs.buildEnv {
    name = "shell-ci-root";
    paths = dependencies ++ extra;
    pathsToLink = [ "/bin" ];
  };

  config = {
    Cmd = [
      "${pkgs.bash}/bin/bash"
    ];
  };
}