Shell.nix for a dotnet application using libadwaita

I’d like to fool around with the source of Denaro. There already seems to be a package in the unstable channel: nixpkgs/default.nix at 988cc958c57ce4350ec248d2d53087777f9e1949 · NixOS/nixpkgs · GitHub

Based on that my shell.nix file looks like this:

with import <nixpkgs> {};

mkShell {
  name = "dotnet-env";
  packages = [
    gtk4
    libadwaita
    pkg-config
    wrapGAppsHook4
    glib
    shared-mime-info
    python3
    desktop-file-utils
    gdk-pixbuf
  ];
}

But when I invoke dotnet run in the NickvisionMoney.GNOME folder the application will crash with System.DllNotFoundException: Unable to load shared library 'libgtk-4.so.1'.

For Rust and gjs it was enough to provide a nix-shell with the necessary dependencies. What am I missing here? Do I need some kind of shell hook?

.NET loads native libraries with dlopen, and adding dependencies to buildInputs/packages is not enough for dlopen to find those. Use this:

mkShell {
  inputsFrom = [ denaro ];
  shellHook = ''
    export LD_LIBRARY_PATH="${lib.makeLibraryPath denaro.runtimeDeps}:$LD_LIBRARY_PATH"
  '';
}
1 Like

Neat. TIL :slight_smile:
Thank you!