How to setup libraries in configuration.nix

So I usually use nix-shell for development and include the dev libraries, for example:

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs; [
    pkgconfig
    cairo
    gobject-introspection
    gtk3
    libnotify
    tmux
    libappindicator
  ];
  shellHook = ''
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath[
    pkgs.cairo
    pkgs.gobject-introspection
    pkgs.gtk3
    pkgs.libnotify
    pkgs.libappindicator
  ]};
  '';
}

Here I am able to export the library path.
Similarly is it possible to export it from configuration.nix so that it would be available globally, the .so (dll files) from each library.
For example if I try to run protonvpn-gui (installed from pip) it gives me error that Gtk namespace is not found, but if I run from nix-shell(with the above config), it works, I want to run normally than from nix-shell.

Possible? Yes, of course, anything is possible. A good idea? No.

The more basic problem here is probably this: (installed from pip).

You’re generally going to have a bad time on nixos if you don’t commit to using nix for deployment of all your binaries. Nixos is explicitly built around the assumption that all executables remember exact paths to their dynamic libraries. There is no global library path. You could make one, but you’d be inventing it mostly from scratch.

Once you’re building the thing in nix, however, there are simple enough solutions to this sort of thing, like wrapping the executable, though usually the workings of stdenv and the helper functions built in top of it will get you this kind of stuff mostly for free.

1 Like
Hosted by Flying Circus.