cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.47k stars 252 forks source link

Deduplicate some Flake inputs #1128

Closed Cu3PO42 closed 2 weeks ago

Cu3PO42 commented 3 weeks ago

Hi! This is a PR in response to #1122.

I have specified some additional inputs.follows rules to de-duplicate shared dependencies.

devenv is still pulling three copies of nixpkgs into the lockfile. One is the actual input, the other two are used for regression tests by nix and pre-commit-hooks respectively. They should never be instantiated and downloaded, so I have chosen to leave them in, but you could also make the argument that they 'pollute' the lockfile and should be overriden as well. I'd be happy to change that.

Unfortunately, I was unable to resolve what I consider to be the biggest problem: devenv pulling in another copy of itself. Right now, devenv 1.0 includes a reference to the main branch of cachix, which includes a reference to the python-rewrite branch of devenv. Since that branch does not itself contain a reference to cachix, the chain stops there. But if you ever were to update the version of devenv used by cachix, you'd increase the length of the chain by one. If you then updated the version of cachix referenced by devenv, you'd end up with

devenv (new version) -> cachix (new version) -> devenv (1.0) -> cachix (older version) -> devenv (python rewrite)

This chain would be evergrowing.

It probably is possible to hack around this issue by removing the direct input references on one another and using flake-compat to construct mutually recursive flakes, but I'm not sure that should be the way forward.

I initially intended to resolve this by adding cachix.inputs.devenv.follows = "self", but Nix does not appear to accept this.

From any given Flake that includes devenv (or cachix) it is possible to resolve this by specifying both inputs and adding the necessary overrides, but that also means specifying all overrides that are included here. I would not consider that 'user-friendly'.