Elm Alternative Package (Mirror) Live

As part of my work on an alternative package manager for Elm, I have updated its package index.

You should be able to run a build through it by doing the following:

> mv ~/.elm ~/.elm-old
> mitmdump --ssl-insecure -M '|https://package.elm-lang.org/|https://package.eco-elm.org/v1/'
> https_proxy=http://127.0.0.1:8080 elm make src/Main.elm

There is also a step needed to whitelist the mitmdump certificate authority on your local box to allow it to proxy an https endpoint - you can find instructions on how to do that here https://docs.mitmproxy.org/stable/concepts-certificates/. This is not something you should do without considering the security implications - I am ok doing it on my dev box, but not on CI through to production.

Moving your current ELM_HOME folder ~/.elm out of the way is recommended (or set a different value for ELM_HOME), since the .zip files on my package server are different again to the ones GitHub serves. They have been stripped of everything except src/**/*.elm + README.md + LICENSE + elm.json. That is why I put (Mirror) in brackets, because it is not an exact mirror.

Currently running on a minimal AWS infrastructure, so it is not very responsive, so don’t hit it too hard.

I would be interested in hearing if anyone else is able to get it to work? or what errors you encounter when trying.

Removing the need to use mitmdump would require hacking the Elm compiler, since it hard codes https://package.elm-lang.org/. I will try and publish a hacked compiler soon (with the publish CLI option disabled), to make reaching this package mirror simpler.

21 Likes

Thanks for posting this @rupert :bowing_man:

Thanks @rupert

I’m really glad to see this type of solution.

I wonder if your setup also supports routing from package.elm-lang.org so it could work even without mitm with something like custom DNS or simple entry in /etc/hosts file? I think that might seem to be slightly more user friendly for some users.

UPDATE: actually thinking about this more I think it might not be doable unless you would also have a cert for the domain (because of https) which you can’t have for obvious reasons.

Not sure either of those would work. /etc/hosts because the elm compiler already has package.elm-lang.org hard coded. And DNS because its https and the compiler is checking the certificate is correct.

It has always been the plan to do a modified compiler for this project.

@rupert elm hardcoding domain would not be a problem. That domain would just got resolved to your IP. But then the certificate for https would be a problem because you can’t have valid one for that url. There would be way around that by installing certs but at that point main complications would be still with installing certs probably making simplifications insignificant.

Anyway I’m happy to say I made it work with mitmproxy as described relatively easily.

1 Like

This is interesting if this means that we could have in-house packages.

That is the main reason for starting this project, as having in-house packages that are managed with semantic versioning is something that I would really like to make possible.

4 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.