Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add erlang modules #11651

Merged
merged 17 commits into from Dec 15, 2015
Merged

Add erlang modules #11651

merged 17 commits into from Dec 15, 2015

Conversation

gleber
Copy link
Contributor

@gleber gleber commented Dec 12, 2015

Hello Nix community

This is rebase of #11614

I am working on getting Erlang packages into Nix and here's my first stab at the problem. The approach is similar to what is done for Haskell. Here are main points:

  • use Hex.pm as a source of tarballs (that's the only reasonable package respository for Erlang AFAIK)
  • use rebar3 (beta-quality version of rebar Erlang built tool which works with Hex.pm)
  • aim at automatically importing all of newest packages on Hex (including their transitive closures) use not-yet-developed set of tools

This establishes basic build functions and provides 5 Erlang packages and 1 rebar3 plugin. Implemented features:

  • buildHex which automates definition of Erlang packages to be fetched from Hex.pm CDN
  • support building packages which depend on other Erlang packages
  • support adding rebar3 plugins for compilation of packages
  • support building of packages with ports (using rebar3-pc plugin)

Rebar3 depends on a concept of registry, which is usually fetched from S3. I've created a separate github repo in which I plan to snapshot that single file from S3 (to be done automatically using

Rebar3 is imported separately from rebar2 since they are very different. @the-kenny

Further work:

  • automate creation of pkgs/development/erlang-modules/hex/*.nix files based on rebar.config
  • fetch all packages from hex.pm and create .nix files for them
  • figure out how to deal with conflicting dependencies and diamond dependency graph
  • figure out how if to provide multiple versions of the same package
  • implement support for Elixir
  • implement support for nix-shell using ERL_LIBS
  • instigate discussion with Erlang community about some sort of LTS package set
  • and much more along the way...

I'd love to hear some initial comments on the code to get guidance. This is my first Nixpkgs contribution.

Thanks!

@sjmackenzie @peti @7c6f434c @pSub @copumpkin

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @vcunat, @civodul and @ip1981 to be potential reviewers

@jagajaga
Copy link
Member

cc @manpages

@peti
Copy link
Member

peti commented Dec 12, 2015

None of the Erlang packages have a meta attribute, i.e. there's no homepage URL, no short description, and -- most importantly -- no meta.platforms. I've inherited that latter attribute from Erlang in 7fb8050e402f699e068842c65697f08669e54669 to make these packages compile on Hydra: http://hydra.cryp.to/jobset/nixpkgs/erlang-updates.

@peti
Copy link
Member

peti commented Dec 12, 2015

According to http://hydra.cryp.to/jobset/nixpkgs/erlang-updates, rebar3-3.0.0-beta.4 won't compile. Consequently, none of the packages compile either.

@gleber
Copy link
Contributor Author

gleber commented Dec 12, 2015

@peti i, thank you for taking a look. I've tested it with the following command and it worked for me:

$ nix-build ~/code/erl/nixpkgs/ -v -A erlangPackages 2>&1 | ix
http://ix.io/mLs

How can i test it on Hydra? Do I need to set up my own Hydra for that?

@peti
Copy link
Member

peti commented Dec 12, 2015

Are you building with chroot isolation enabled? If your build succeeds in a chroot environment, then it's almost certainly going to succeed on Hydra as well.

@sjmackenzie
Copy link
Contributor

I've tested this with nix.useChroot = true; and the build succeeds. (@peti)

@sjmackenzie
Copy link
Contributor

@gleber, typically you'll need to setup hydra yourself, which can be a bit of a headache. We've had a noble yet tentative step up by @aszlig to be Hydra's release manager, so Hydra will be incorporated into NixOS' module infrastructure (via configuration.nix). Which will automate Hydra greatly. Though you probably don't need Hydra at this stage.

@gleber
Copy link
Contributor Author

gleber commented Dec 13, 2015

Looks like rebar3 bootstrap script is not hermetic as I thought:

===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"1.11.0">>})
===> Successfully downloaded https://s3.amazonaws.com/s3.hex.pm/tarballs/rebar3_hex-1.11.0.tar
===> Downloaded package, caching at ./.cache/rebar3/hex/default/packages/rebar3_hex-1.11.0.tar

I will work on making sure it doesn't fetch anything.

There are some packages on Hex which have custom hex-specific names, but
inside there's a base project name.

Remove most packages andadd ibrowse, meck, jiffy
If compilePorts is enabled plugin "pc" is added to the rebar.config
during postPatch. This makes rebar3 compile download the plugin, hence
added TODO.
Allow specifying pluginDeps for buildHex listing rebar3 plugins which
are required for given package to be built by rebar3.
This allows to avoid fetching registry file from S3 at build time,
making the build hermetic and much faster. Automatic tools will be used
to update said external repo content when Hex packages are
imported/update.
Adds "meta" for meck package as a test.
This will allow to reuse this code to fetch rebar3's dependencies to
ensure it's hermetic build.
This makes rebar3 build a bit more hermetic. Next stage is to pull in
rebar3 plugins dependencies for bootstrap to pick up.
@gleber
Copy link
Contributor Author

gleber commented Dec 15, 2015

@peti @sjmackenzie @RumataEstor I've made rebar3 compilation hermetic and cleaned up branch history. Please take a look again.

@gleber
Copy link
Contributor Author

gleber commented Dec 15, 2015

And the build now works on my NixOS done like this:

nix-build ~/code/nixpkgs/ -vv -A erlangPackages --option build-use-chroot true

@peti
Copy link
Member

peti commented Dec 15, 2015

Okay, all builds succeed now: http://hydra.cryp.to/eval/746730.

@peti
Copy link
Member

peti commented Dec 15, 2015

I think it's fine to merge the current state into master so that everyone who's interested in the subject can experiment with it.

peti added a commit that referenced this pull request Dec 15, 2015
@peti peti merged commit 82c673d into NixOS:master Dec 15, 2015
@peti
Copy link
Member

peti commented Dec 15, 2015

@gleber, at some point, it might be a good idea to post some kind of announcement to the nix-dev mailing list to ensure that people are aware of the work you've been doing. Also, user documentation in doc/* would be very welcome at some point.

@sjmackenzie
Copy link
Contributor

sjmackenzie commented Dec 15, 2015 via email

@copumpkin
Copy link
Member

🍻

@gleber
Copy link
Contributor Author

gleber commented Dec 15, 2015

Thanks, Peter. I've created a tracking issue which will remind me about docs: #11748

I will subscribe to nix-dev and let people know about this effort.

@gleber gleber deleted the add-erlang-modules branch December 15, 2015 19:37
@domenkozar
Copy link
Member

@gleber awesome work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants