-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Generalize building of Elixir interpreter #26716
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
Conversation
/cc @gleber, @LnL7, @ericbmerritt, @yurrriq |
Nice! This was my next step, thanks for doing it! :) |
Glad I could help. I can also take a crack at LFE if you would prefer? |
#26668 should be merged before this. Once it is, I will need to make a couple modifications. |
Current state of PR built successfully built on NixOS with sandboxes: $ nix-shell -p nox --run "nox-review pr 26668" |
Oops, that comment was actually for wrong PR. Results for this PR are also positive: $ nix-shell -p nox --run "nox-review pr 26716" |
@ankhers my previous work on LFE might be helpful if you do. There should be a link on the old generalized Erlang PR. Please don't update to 1.3.0 in the process because there are some known issues and we're waiting on 1.3.1. |
@yurrriq Noted. Do you have any idea how long until 1.3.1 will be released? |
@rvirding has identified the problem and is working on a fix, but I'm not sure about the timeline. |
2480ce9
to
0e45d08
Compare
I just did a rebase from master. Unfortunately I do not seem to have Elixir being built for different version of Erlang. |
714ece0
to
4c305e8
Compare
I fixed the issue with the incorrect Erlang version being loaded for Elixir. I am not sure if this is the best solution or not. I am running |
50290c6
to
c2a7621
Compare
And today I am receiving the following error when trying to build Elixir with R19
I will look into it a little bit later. |
The various Elixir versions build with the given erlang versions. If anyone knows of a way to have the erlang and rebar packages that are in scope be passed into the generic builder instead of having to specify for each one, I would appreciate the help. |
elixir = if versionAtLeast (lib.getVersion erlang) "18" | ||
then callPackage ../interpreters/elixir { debugInfo = true; } | ||
else throw "Elixir requires at least Erlang/OTP R18."; | ||
elixir = defaultScope.elixir-1_4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can drop default scope.
from all the new code if you add rec
just before opening "{" of this block. This will also allow you to write inherit rebar erlang;
instead of erlang = ...;
and rebar = ...;
inside args of lib.callElixir
.
Another option is to replace defaultScope.
with self.
.
These have slightly different semantics, but in this case they seem to be equivalent.
callElixir = drv: vsn: args: | ||
let | ||
inherit (stdenv.lib) versionAtLeast; | ||
builder = callPackage ../../development/interpreters/elixir/generic-builder.nix args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can drop ../development
in this path, since you are already under development
directory
pkgs/top-level/beam-packages.nix
Outdated
@@ -49,6 +49,10 @@ rec { | |||
# access for example elixir built with different version of Erlang, use | |||
# `beam.packages.erlangR19.elixir`. | |||
elixir = packages.erlang.elixir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace these 4 lines with
inherit (packages.erlang) elixir elixir-1_5 elixir-1_4 elixir-1_3;
pkgs/top-level/beam-packages.nix
Outdated
@@ -49,6 +49,10 @@ rec { | |||
# access for example elixir built with different version of Erlang, use | |||
# `beam.packages.erlangR19.elixir`. | |||
elixir = packages.erlang.elixir; | |||
elixir-1_5 = packages.erlang.elixir-1_5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the naming convention for attributes is elixir_1_5
or elixir15
and since this is an rc release it should be suffixed to make that explicit.
debugInfo = true; | ||
}; | ||
|
||
elixir-1_4 = lib.callElixir ../interpreters/elixir/1.4.nix "18" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to add the otp version as an optional argument for the elixir builder instead, then it could be overridden by the specific elixir expression if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgive me if I am misunderstanding your comment here. But that OTP version ("18"
), is the minimum version required to build Elixir. It isn't the version to build Elixir with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also removed superfluous path segments from elixir generic builder
Rename attributes from elixir-1_x to elixir_1_x
Changed Elixir 1.5 to include the fact it is an rc release
5ddc8e8
to
cc09faa
Compare
inherit (stdenv.lib) getVersion versionAtLeast; | ||
|
||
in | ||
assert versionAtLeast (getVersion erlang) minimumOTPVersion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdenv.lib.getVersion
does not work at least for erlangR16 (I don't remember about other versions). That's the reason I have introduced erlang-specific version of this function here:
/* Erlang/OTP-specific version retrieval, returns 19 for OTP R19 */ |
Can you double check it works well for all Erlang versions present in Nixpkgs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I built all the three Elixir versions included in this PR against OTP 18, 19 and 20. I also made sure it failed when attempting to build on R17 and R16.
This is the results of nox-review
.
/nix/store/gmqllgyna6kav9zz770fkczlh928hd8f-erlang-20.0-odbc
/nix/store/5421cdrj4zf5dkqfld4pcba2jfjrk8k4-erlang-19.3-javac-odbc
/nix/store/hs7jj5niyx13awgi73kqdsb00a62jz8f-erlang-18.3.4.4-javac
/nix/store/gfks6rlfrg37k20gmw3by6j5pv32lwhi-erlang-16B03-1
/nix/store/b39vr4vay0cx9mvlzwb9a28yp3lc9gs6-erlang-17.5-javac-odbc
/nix/store/55alxr80yb0s0k4cm7a3svw7kh4rwz42-elixir-1.5.0-rc.0
/nix/store/dgi75xy4xngpjvn9ijzkabpp1ppwf5w6-erlang-17.5-odbc
/nix/store/8d2m82zrvq8r247zhx99yj63vmrb8zaw-erlang-19.3-javac
/nix/store/pmiwscdddsxyvc2la6fiygjh9nqgnr6q-erlang-20.0-javac-odbc
/nix/store/sjz5ijsvrysas3swr1aygay85sy6ayb4-erlang-17.5-javac
/nix/store/29gn1vapx5mqdka3cixh8flzgnspggwr-erlang-18.3.4.4-odbc
/nix/store/5b6djrg39bbrfd8k9dfpcsa8vrkygjpd-erlang-16B03-1-odbc
/nix/store/ddc3ix61gs6nml93wr1yddfawlyxpg0f-erlang-20.0-javac
/nix/store/b2c6whz71kxaa9jrg7zc25l8s1a1zcr6-elixir-1.3.4
/nix/store/dy1g580h1cy06gzh2pv2z99mf0c3kw4j-erlang-16B02-odbc
/nix/store/nmi33wz63dwld6xnxn7w70cpsbiljs9f-erlang-18.3.4.4-javac-odbc
/nix/store/asrc5783fmkjrvs1k6r2fbh1p5m6b51x-erlang-19.3-odbc
Result in /var/folders/lp/n8j6lzmj5dj34zgzb4zxw35c0000gn/T/nox-review-cooxkh3s
total 68
lrwxr-xr-x 1 woodjk staff 60 Jun 27 00:36 result -> /nix/store/gmqllgyna6kav9zz770fkczlh928hd8f-erlang-20.0-odbc
lrwxr-xr-x 1 woodjk staff 61 Jun 27 00:36 result-10 -> /nix/store/sjz5ijsvrysas3swr1aygay85sy6ayb4-erlang-17.5-javac
lrwxr-xr-x 1 woodjk staff 64 Jun 27 00:36 result-11 -> /nix/store/29gn1vapx5mqdka3cixh8flzgnspggwr-erlang-18.3.4.4-odbc
lrwxr-xr-x 1 woodjk staff 63 Jun 27 00:36 result-12 -> /nix/store/5b6djrg39bbrfd8k9dfpcsa8vrkygjpd-erlang-16B03-1-odbc
lrwxr-xr-x 1 woodjk staff 61 Jun 27 00:36 result-13 -> /nix/store/ddc3ix61gs6nml93wr1yddfawlyxpg0f-erlang-20.0-javac
lrwxr-xr-x 1 woodjk staff 56 Jun 27 00:36 result-14 -> /nix/store/b2c6whz71kxaa9jrg7zc25l8s1a1zcr6-elixir-1.3.4
lrwxr-xr-x 1 woodjk staff 61 Jun 27 00:36 result-15 -> /nix/store/dy1g580h1cy06gzh2pv2z99mf0c3kw4j-erlang-16B02-odbc
lrwxr-xr-x 1 woodjk staff 70 Jun 27 00:36 result-16 -> /nix/store/nmi33wz63dwld6xnxn7w70cpsbiljs9f-erlang-18.3.4.4-javac-odbc
lrwxr-xr-x 1 woodjk staff 60 Jun 27 00:36 result-17 -> /nix/store/asrc5783fmkjrvs1k6r2fbh1p5m6b51x-erlang-19.3-odbc
lrwxr-xr-x 1 woodjk staff 66 Jun 27 00:36 result-2 -> /nix/store/5421cdrj4zf5dkqfld4pcba2jfjrk8k4-erlang-19.3-javac-odbc
lrwxr-xr-x 1 woodjk staff 65 Jun 27 00:36 result-3 -> /nix/store/hs7jj5niyx13awgi73kqdsb00a62jz8f-erlang-18.3.4.4-javac
lrwxr-xr-x 1 woodjk staff 58 Jun 27 00:36 result-4 -> /nix/store/gfks6rlfrg37k20gmw3by6j5pv32lwhi-erlang-16B03-1
lrwxr-xr-x 1 woodjk staff 66 Jun 27 00:36 result-5 -> /nix/store/b39vr4vay0cx9mvlzwb9a28yp3lc9gs6-erlang-17.5-javac-odbc
lrwxr-xr-x 1 woodjk staff 61 Jun 27 00:36 result-6 -> /nix/store/55alxr80yb0s0k4cm7a3svw7kh4rwz42-elixir-1.5.0-rc.0
lrwxr-xr-x 1 woodjk staff 60 Jun 27 00:36 result-7 -> /nix/store/dgi75xy4xngpjvn9ijzkabpp1ppwf5w6-erlang-17.5-odbc
lrwxr-xr-x 1 woodjk staff 61 Jun 27 00:36 result-8 -> /nix/store/8d2m82zrvq8r247zhx99yj63vmrb8zaw-erlang-19.3-javac
lrwxr-xr-x 1 woodjk staff 66 Jun 27 00:36 result-9 -> /nix/store/pmiwscdddsxyvc2la6fiygjh9nqgnr6q-erlang-20.0-javac-odbc
I didn't use the Erlang specific getVersion
for two reasons.
- Elixir only builds on Erlang 18+. And as you point out, you wrote that function because of R16.
- I don't think it would have caused any issues, but using that version would have introduced a circular dependency. I'm not sure if this sort of thing is frowned upon in the Nix world.
I don't mind using the Erlang specific one if my second point is not considered a problem, or if we move the function elsewhere. I just figured it would be nice to use the standard set of functions where possible so that anyone looking at the code in the future would not have to lookup the definition of another function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you end up not using the Erlang-specific getVersion, then please delete it in this PR.
IMO the circular dependency is not a problem, since this is a lazy language - it is actually full of circular dependencies (at least at data level).
I think there might be a better solution - to make sure that erlangR16.version
is actually 16.3.1
and hide the fact that Erlang/OTP had funny versioning.
Feel free to choose any of the discussed solutions, I do not think this is important enough to stall this PR any longer.
|
||
for f in $out/bin/*; do | ||
b=$(basename $f) | ||
if [ $b == "mix" ]; then continue; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix your quoting everywhere.
"$b" = mix
is correct and shorter, for example. Also instead of using continue
, you can also just use !=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will have to forgive me, Bash is not my strong suite and this file was just a git mv
with the version specific information ripped out.
aside from the "$b" = mix
, what other types of quoting needs to be fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware of that. In that case, don't worry about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good, but please fix the quoting and the other concerns raised by the other reviewers.
@0xABAB, or anyone else. Would it be possible to get clarification on the last review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LnL7 If you have no further concerns, this can be merged.
Motivation for this change
This is a continuation of #26381 based on #17240
This only includes Elixir generalization. It also includes derivations for Elixir 1.3 and 1.4
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)