Can nix-env -i Add pkg-config Files to My Default Profile?

I want to install a package to my profile using nix-env -i, but it doesn’t add the pkg-config files to my profile. When doing a nix-shell I can do that by adding nativeBuildInputs = [ pkgs.pkg-config ];, but how do I do that when installing a package to my environment instead of using nix-shell?

IIRC, the pkgconfig shell hook won’t be ran, so there’s no PKG_MODULE_PATH which will be set. you would have pkg-config on your path, but probably not give you any useful information.

@jtojnar would probably know better

I do have pkg-config installed on my system already, so that is covered, but I want the install of the nix packages to add their pkg-config files to .nix-profile/lib/pkgconfig so that my non-nix builds will pick it up ( because that dir can be in my PKG_MODULE_PATH outside of nix ).

That is entirely correct.

I will remind you that this is really discouraged for obvious reasons. But if you really want that and point PKG_MODULE_PATH to .nix-profile/lib/pkgconfig manually, you will need to add lib/pkgconfig to the environment’s pathsToLink and rebuild the profile.

Not sure if that can be done for imperative use of nix-env though. Declaratively, it will be something like this: FAQ - NixOS Wiki

1 Like