General method of converting shell.nix solutions to global solutions

I’ve come across the issue in OpenSSL Dependency for Rust but I prefer to edit my /etc/nixos/configuration.nix file and have things installed globally instead of working with shell.nix files.

My nix is very weak, is there some trick for converting shell.nix solutions to global nixos solutions (other than actually taking my time and learning nix)?

From the wiki page on Rust, section “Building Rust crates that require external system libraries”:

Note that you need to use a nix-shell environment. Installing the Nix packages openssl or sqlite globally under systemPackages in NixOS or in nix-env is discouraged and doesn’t always work ( pkg-config may not be able to locate the libraries).

Which in turn links to FAQ/I installed a library but my compiler is not finding it. Why? - NixOS Wiki

It does smell footgun-ish to me to put it in the global configuration. (It might affect builds you don’t intend it to).

But sounds like what you’re after is to update the environment variables for native libs that Rust picks up, (e.g. PKG_CONFIG_PATH) in your system config to use libraries from pkgs.

1 Like