Use lib instead of pkgs.lib

Usage of pkgs.lib may cause infinite recursion
Merge pull request #5018 from ip1981/patch-1

Use lib instead of pkgs.lib