-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
mix2nix: init at 0.1.2 #121555
mix2nix: init at 0.1.2 #121555
Conversation
@petabyteboy you might be interested |
First review. This might take a bit of time, but feel free to ask me for help with anything. I want to try to make this as easy as possible for you! First positive thing, it builds without a problem! :-) I do think there will be a problem with usage though. I've removed buildMix in that PR https://github.com/NixOS/nixpkgs/pull/112477/files I've tested the generations of the deps.nix, it works as expected! (just like you mentioned in the readme, we can figure out the git deps later.). One thing that would be good though is to show how it might be used to build a project. I'm adding here for reference other efforts at doing this |
One more thing regarding the current state of things. |
The reason I relied so heavily on the buildMix helper is that it let me define a set of packages that follow a pattern familiar to most other nix packages, then list the dependencies with beamDeps. I was working off of the stable Nixpkgs documentation, so I wasn't aware it was being removed. An example of a (very simple) phoenix project that uses this is at https://git.imnotsoup.com/inkhorn. You can see from the default.nix file that it uses the buildMix helper, except it overrides the installPhase and adds a postBuild step to create a release. Personally, I find buildMix to be an intuitive and useful way of describing mix builds. But I will take some time to catch up on the discussions around why it is being removed. I will also try to get familiar with MixRelease and fetchMixDeps. |
I removed it, but only because It didn't properly build a release for a mix project, and I thought it was not being used. I would say here, we can bring it back, we just have to test that each piece is actually being used and perhaps document it. Let me know if you want more information on anything. |
By just copying and pasting the old files, I get this error on building my project
I'm going to do some more testing to try to figure out how a potentially new |
I am seeing similar errors with both cowboy_telemetry and telemetry_poller. In both cases, they are not able to find telemetry, even though telemetry builds fine and is symlinked into the build path for the dependent package. Both packages use buildRebar3, which may be a starting point for finding the problem. fetch-mix-deps (and fetch-rebar-deps) is a clever and practical solution. Still, I'd to hate to give up on an approach that creates a separate derivation for each hex package because of build failures of a few (or even many) individual packages. |
Before giving any more attention to mix2nix, I am going to:
|
I completely agree! Let's make this approach work! The only thing I think would be great, would be to start from a minimal buildMix and add things from there. Just to try to get rid of unused stuff that might be uneeded at this point. I'm going to investigate further on my side as well, let's share findings here. Thank you so much for taking this on! |
Ok, I think I have a fix for the problem. I wrote about the gist of the fix there, but here is a brief description. I think the last step is to symlink dependencies in One more thing that we might want to have a look at is the way phases are defined inside
is not very idiomatic no?
Let me know if anything. |
One more thing. I haven't been through all the different implementations that I put a link to here. Maybe we should go through them and try to integrate what can be integrated? This is just a thought, I'm not sure I have the motivation for this myself. Maybe we can just try to get feedback from the people who implemented the other versions? |
Also, it feels a little weird that mix-bootstrap is written in erlang and not Elixir. Maybe I'm being overzealous here. |
Oh, one more thing I noticed. |
I just tested and just adding
inside mix-release won't work directly. It seems that the symlinked dependencies are not compiled. |
I think for for mix-release, it should work if you first build the release, then copy the result to $out, instead of doing it all on one line. |
I'm not against a flag for including only prod dependencies, but I don't think it is a priority. mix2nix creates a package definition for dev dependencies, but if you do not need them, you can simply not list them in your default.nix file. I intentionally did not want mix2nix to try to write the user's default.nix file, which is a big difference between it and some of the similar projects. |
@happysalada I am a bit confused. As far as I know For |
@gleber thanks a lot for this clarification. I wonder where the |
@happysalada @gleber The |
Opened #122633 to gather feedback :) |
Moving |
@gleber thanks a lot for the explanation! |
src = fetchFromGitHub { | ||
owner = "ydlr"; | ||
repo = "mix2nix"; | ||
rev = "b153a252f0689d3f6919e16c2df2fb3b6bcc9d2a"; |
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.
this needs to be updated to the version after the fix for ssl_fun
thing
I've tested, moving elixir to nativeBuildInputs. |
@NixOS/beam this PR introduces mix2nix, a tool for generating a deps.nix file from a mix.lock. Usage is not immediately clear, but there should be a following PR to integrate it into mixRelease and update the docs. |
Just a quick note to say there were some changes since the initial mix2nix release. I tested with a private app and with the elixir_ls repo. I didn't see a problem. |
@ydlr I tried fixing a conflict from github, however github still shows that there is a conflict. Sorry to ask you this, but when you have a moment, can you rebase off master? |
Thanks, @ydlr! I'll leave this for @happysalada to merge, but lgtm. |
Motivation for this change
Mix2nix is a tool for generating nix expressions from a mix.lock file. It makes developing elixir applications with nix a little easier.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)