gak.dev
Loading...
Loading...
I'm still a nix newbie with so please forgive me if this is obvious, or if there's a better way.
I have a fairly fresh macOS system with nix-darwin with home-manager with a few config bits for zsh, fzf, git, ssh, etc.
Rust is installed with rustup, not managed by nix.
Running cargo install cargo-generate
gives me:
run pkg_config fail: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "openssl"` did not exit successfully: exit status: 1
error: could not find system library 'openssl' required by the 'openssl-sys' crate
--- stderr
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `openssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'openssl' found
Great. Just add openssl
to home.packages
, right? Just like an apt install
fix? Nope.
I tried a few different things and IIRC, the problem is that openssl is installed in a nix store path, and the build tools can't find it.
There were a few github issues and forum posts more or less giving this answer, but not that great for a nix newbie like me who needs it spelled out with a config example.
You need to create an environment variable for pkg_config to use:
home-manager.users.gak = { pkgs, ... }: {
home.packages = with pkgs; [
# ...
pkg-config
openssl
];
home.sessionVariables = {
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
};
# ...
}
After a darwin-rebuild switch
and starting a new shell, cargo install cargo-generate
works!
I've read that you can (and should?) use a shell.nix
or flake.nix
to do this, but it is so inconvenient for me,
especially for a once off build of a tool like cargo-generate
.