Accessing a self-hosted hex registry from livebook

I’ve been playing around with a self-hosted hex package registry, and it’s working well.

I’m interested in using one of my self-hosted packages inside a livebook, but see no way to accomplish this—neither the Livebook settings nor Mix.install/2 seem to have a way to declare additional registries to search for packages from.

I’m essentially looking for a way to accomplish mix hex.repo add <name> <url> for my Livebook runtime.

Does anyone know if this is possible? I have found nothing in mix, hex, or livebook docs/issues about this, but wanted to solicit the wisdom of the crowd before submitting a feature request.

2 Likes

How are you running Livebook? If you run with Escript and do mix hex.repo add, then I think Mix.install/2 should be able to pull packages from the repo with {:package, "~> 1.0", repo: "myrepo"}. For other deployments (Docker, Desktop) the Mix installation is separate from the system, perhaps you can try running System.shell("mix hex.repo add ...") in a Livebook session (any session, just once), so it adds package in the right context.

3 Likes

Running from Livebook Desktop, and adding the system invocation in my notebook setup before Mix.install works perfectly, thanks!

Awesome! Btw. I think doing it once should be enough, since then the repo is already added to the Mix config. That said, having it in the notebook makes sure it works in new environments (and you may want to use Livebook secrets for the repo keys).

1 Like

That was my next question, thanks! :smile: