Open DavHau opened 4 years ago
Interop with existing tools is important. Not everyone has nix, so if random people try to run the application they should at least be able to use their usual workflow (if it works). If they want a very reproducible env, then they should use the nix tooling. Can we get mach-nix to output the flat list of requirements and their versions (ala pip freeze)? That way people using pip get the nearest approximation of the nix env and mach-nix should be happy as well. Maybe something like having a requirements string in mach-nix which specifies the top level packages, and a requirements.txt which is generated by mach-nix from that which is the flat version.
Problem
While maintaining a flat list of requirements is needed for tools like pip to increase reproducibility, the same rule doesn't apply for mach-nix. Since mach-nix' dependency resolution is deterministic, flat requirements do not contribute to reproducibility.
Mach-nix works best if only top-level requirements are specified, for the following reasons:
General reasons against manually maintaining flat requirements are:
Despite all that, users often input flat requirements to mach-nix, probably because one of those reasons:
Solution
If we were able to automatically transform a flat set of requirements into a top-level-only set of requirements, we would automatically reduce the chance of conflicts.
I have the following simple algorithm in mind: For each item inside the flat requirements list:
One side effect of this is, that the resolved dependency graph of the new set of requirements might contain different versions for sub dependencies compared to the original flat requirements.
Therefore this optimization should probably not be done by default. But I propose to implement it as: