Replies: 5 comments 9 replies
-
@ipetkov you mention in #31 (comment):
and
I would love to hear them, if you would like to lay them out? |
Beta Was this translation helpful? Give feedback.
-
I have spent the past few days analyzing the situation myself, so here is what I have learned during this time:
Some problems I've encountered2) makes it quite hard to find out what the actual build graph is.Imagine you have a workspace with several crates, how do you even get to know what the current members are without having to import all of the sources. Potential solutions:
3) Makes it hard to guide cargo to a 'nix correct' situationIn an ideal world I would be able to do this:
Now, crane already does this for non-workspace crates, but in that situation its luckily fairly simple (but still tricky!), since one rarely use But several points are problematic as far as I understand?
What can we do?Now, my biggest problem is that I feel that this point to get closer to being able to handle this situation we'd need more support from the cargo project. But I don't want to dump this info on them, and ask of them 'to figure out the support' or anything like that. So my primary goal here would be what the exact requirements are of cargo, so that we (or I) could then chat with the cargo project so that we can work out a potential solution. Since you, @ipetkov, also have more experience with abstracting cargo in nix, I want to see what you think and/or any other ideas you might have? |
Beta Was this translation helpful? Give feedback.
-
Alright, @matthiasbeyer and I have made some progress on this! It actually works for a simple workspace!... except the final step where cargo falls over:
The general idea of what we did was the following:
Sadly the final final step doesn't work yet. But we are working on why this happens here, as:
crane/lib/setupHooks/inheritCargoArtifactsHook.sh Lines 35 to 43 in 7809d36 The investigation continues... |
Beta Was this translation helpful? Give feedback.
-
Huzzah! We solved the last problems for a first succesful test. And are now fixing the kinks! If you want to check it out, you can find it here: https://github.com/TheNeikos/crane-workspaces Once we feel its ready, I'll try to see if you are interested in integrating this solution. |
Beta Was this translation helpful? Give feedback.
-
We do something similar to crane-workspaces with our monorepo and crane but we are running into an issue where the shared dependencies nix artifact is huge and when building with remote builders it spends a good amount of time nix copying that shared artifact. I think a better approach is to have each dependency be its own path in the nix store so you don't have a giant workspace-deps nix store path and you could also get better individual dependency caching. I'm not entirely sure the best approach to doing this with crane but I wonder if |
Beta Was this translation helpful? Give feedback.
-
This is a continuation of #31, but it goes further and I don't want to disturb a perfectly fine solution for the asked question.
However, it is now a year later and the monorepo has grown...
And with it, we have now integrated nixos vm tests. Which means that to run the tests, we now need to use nix to build the software. And since any code change triggers a full rebuild of the whole (rust) part of the monorepo, tests take way longer than they should.
I can't show you the actual repo, but the construction is somewhat like this:
foo_{core,lib}
(we actually have something like 20+ crates, but that is the pattern)
Now, when we test one of the plugins, the 'theoretically best' build chain would be:
foo_{core,lib}
(unchanged) ->plugin_bar
(has changes) ->cli
(plugin_bar changed)But instead we rebuild every single crate, which is quite problematic as some of the plugins have a fairly large surface area and Rust is also not the fastest to compile for large programs.
I would say this is a fairly 'typical' setup for projects like these, but the twist is that the individual crates cannot be put on a registry. This leaves us with two options for potentially resolving this:
I don't think #1 is something we should be doing in our personal case (might work for others!), so I am very much interested in seeing #2 happen, if possible/wanted.
This is why I opened this Discussion, to talk about potential solutions to the problems that occur due to the cargo and nix paradigms.
I am also interested in implementing/experimenting with/for any solutions that might come up.
Beta Was this translation helpful? Give feedback.
All reactions