Understanding `lib.attrsets.getLib`?

I am having trouble understanding https://github.com/NixOS/nixpkgs/blob/f4a8d6d5324c327dcc2d863eb7f3cc06ad630df4/lib/attrsets.nix#L1060

/* Get a package's `lib` output.
     If the output does not exist, fallback to `.out` and then to the default.

       getLib pkgs.openssl
       => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-lib"

       getLib :: Derivation -> String
  getLib = getOutput "lib";

when I try getLib pkgs.openssl in nixrepl -f '<nixpkgs> then I do not get s string but a derivation?

Is here the documentation wrong?

Hum, maybe the type is indeed not accurate. But you can easily obtain a string by doing:

nix-repl> "${lib.getLib pkgs.openssl}"

For the documentation, you can maybe report it on the github repository or add a pull request.

Thanks: I reported it: lib.attrsets: Correct wrong documentation in `getLib` etc by gabyx · Pull Request #286518 · NixOS/nixpkgs · GitHub

1 Like