Adding gnu-cobol into a devShell doesn't allow me to execute cobc

I want to use gnu-cobol in a devShell so I created the following flake:

  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";

  outputs = {nixpkgs, ...}: let
    system = "x86_64-linux";
    pkgs = import nixpkgs {inherit system;};
  in {
    devShells.${system}.default = pkgs.mkShell {
      packages = [pkgs.gnu-cobol];
      shellHook = ''
        ls ${pkgs.gnu-cobol}       # contains a bin directory
        ls ${pkgs.gnu-cobol}/bin   # contains a cobc executable
        ${pkgs.gnu-cobol}/bin/cobc # works
        cobc                       # cobc not found
$ nix develop --ignore-environment
bin  share
cobc  cob-config  cobcrun
cobc: error: no input files
cobc: command not found

This however doesn’t allow me to run cobc in the shell.

Adding export PATH=${pkgs.gnu-cobol}/bin:$PATH to the shellHook would solve the issue however that seems like a hack.

I thought that a devShell includes the /bin directory from each package automatically.

Welcome to the joy of multi-output-derivations…

I have no clue why it works in the interpolation, but after I used pkgs.gnu-cobol.bin in packages, I was able to access cobc in the shell.

You are right!

So because of this nix develop doesn’t pick up the bin output so I have to manually call it via gnu-cobol.bin?