Open kindaro opened 5 years ago
Nixpkgs does not install headers and pkgconfig meta by default - only runtime dependencies are made available in $HOME/.nix-profile. If you need a development environment like you would get in a Nix builder, you can use nix-shell:
$ nix-shell -p systemd pkgconfig --run 'echo $PKG_CONFIG_PATH'
@matthewbauer Is this documented? I was just scrolling through issues and saw this. The distinction between nix-env and nix-shell is subtle but rather important, especially for new nixos users...
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Just ran into this. Thought I was going crazy. Figured it must be something Nix is doing so I went searching for issues. I don't know if it's possible, but maybe nix-env
can output a warning and link to https://nixos.wiki/wiki/FAQ/Libraries when a user tries to install libraries?
Related issue: https://github.com/NixOS/nixpkgs/issues/41825.
I marked this as stale due to inactivity. → More info
The command from https://github.com/NixOS/nixpkgs/issues/64530#issuecomment-509695590 does not set PKG_CONFIG_PATH:
$ nix-shell -p systemd pkgconfig --run 'echo $PKG_CONFIG_PATH'
@tv42 it now sets PKG_CONFIG_PATH_FOR_TARGET
as part of improved cross-compilation support. Nonetheless, pkg-config works correctly:
$ nix-shell -p systemd pkgconfig --run 'pkg-config --libs libsystemd'
-L/nix/store/zc9r3iin18bccr3sjgwsgd6snp8g9g27-systemd-249.7/lib -lsystemd
It doesn't seem like pkg-config is picking up anything?
$ nix shell nixpkgs#systemd nixpkgs#pkgconfig nixpkgs#zlib -c pkg-config --list-all
[ no output ]
Seems to be a difference between nix-shell
and nix shell
:
$ nix-shell -p systemd pkgconfig --run 'pkg-config --libs libsystemd'
-L/nix/store/cfqfzy5k6l7b2f3bxy2zdhp9sjiw8ijd-systemd-249.5/lib -lsystemd
$ nix shell nixpkgs#systemd nixpkgs#pkgconfig -c pkg-config --libs libsystemd
Package libsystemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsystemd.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libsystemd' found
It doesn't seem like pkg-config is picking up anything?
$ nix shell nixpkgs#systemd nixpkgs#pkgconfig nixpkgs#zlib -c pkg-config --list-all [ no output ]
Seems to be a difference between
nix-shell
andnix shell
:$ nix-shell -p systemd pkgconfig --run 'pkg-config --libs libsystemd' -L/nix/store/cfqfzy5k6l7b2f3bxy2zdhp9sjiw8ijd-systemd-249.5/lib -lsystemd $ nix shell nixpkgs#systemd nixpkgs#pkgconfig -c pkg-config --libs libsystemd Package libsystemd was not found in the pkg-config search path. Perhaps you should add the directory containing `libsystemd.pc' to the PKG_CONFIG_PATH environment variable No package 'libsystemd' found
It seems to me that this should be another issue (possibly a nix issue?), since this issue is concerned with documenting pkg-config behaviour (or lackthereof) in nix-env
and nix-shell
, not nix-shell
andnix shell
. Curious behaviour, though. The same problem occurs with nix develop
.
Seems numtide devshells remove a lot of the usual hooks which would ordinarily handle this. It probably works with the normal mkShell
. Speaking of which... https://discourse.nixos.org/t/flakes-how-to-make-pkg-config-work-with-nix-shell/16305/2
It seems documenting "it does not work" is much less useful than making it work, though. And nix shell
/nix develop
is the future, isn't it? Probably more bang for buck fixing it there.
"It does not work" and that is not an issue, is that it ?
I just ran into this problem --- is there a way to just add the proper setup hooks to your profile.nix/home.nix directly (I don't use nix-shell
)?
Issue description
I need to have some libraries, such as
libsystemd
, available and visible withpkg-config
to do my programming. Unfortunately, I discover thatpkg-config --list-all
output is completely blank. I can fix it by an appropriate assignment ofPKG_CONFIG_PATH
, but I would expect it to work out of the box.Steps to reproduce
Install Nix and then install
systemd
andpkg-config
vianix-env
.Technical details