jlouis / enacl

Erlang bindings for NaCl / libsodium
MIT License
197 stars 59 forks source link

Fails at runtime in `nix develop` / `direnv` with `use flake` #64

Closed cognivore closed 2 years ago

cognivore commented 2 years ago

Not sure if this is an enacl issue, but with the following minimal flake.nix:

{
    inputs = {
        nixpkgs.url = "github:nixos/nixpkgs";
    };

    outputs = {self, nixpkgs}:
        let pkgs = nixpkgs.legacyPackages.x86_64-linux;
        in {
            defaultPackage.x86_64-linux = pkgs.hello;

            devShell.x86_64-linux =
                pkgs.mkShell { buildInputs = [
                    pkgs.elixir
                    pkgs.erlang
                    pkgs.libsodium
                ]; };
        };
}

trying to use an enacl function fails with:

21:21:01.386 [warn]  The on_load function for module enacl_nif returned:
{:error,
 {:load_failed,
  'Failed to load NIF library /home/sweater/github/cluster/_build/test/lib/enacl/priv/enacl_nif: \'libsodium.so.23: cannot open shared object file: No such file or directory\''}}
cognivore commented 2 years ago

Fixed by adding the following attribute to the argument of pkgs.mkShell:

LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.libsodium ];