Sharing devenv.lock in monorepos
Based on a comment I found in #2209 this does not seem possible (referenced below)
The more general question: How can I inherit the exact versions from one devenv in a monorepo in a second devenv.
Is there a way of doing this that i am missing (apart from ref-linking the urls in the devenv.yaml). And what are the technical blockers to make this possible?
My exact use case: The monorepo structure (simplified):
- parent
- devenv.nix (let's call it P)
- frontend
- devenv.nix (let's call it F)
- backend
- devenv.nix (let's call it B)
F sets up everything to run frontend, B backend.
P contains all the wiring to allow devenv up to run the whole repo locally. This is extremely valuable and reproducible.
However, now we still have a script in the parent to update all devenvs in lockstep, to make sure the nixpkgs version of F is the same as P, otherwise F often does not compile in P.
Since different teams might manage F and B, keeping P in sync is potentially brittle and the only non-manual workaround would be a github action to relock all devenvs collectively. Which is not really what we want.
The docs say:
!!! warn "Locked inputs and follows"
"Follows" are fetched and re-locked using the URI of the followed inputs. The external project's lock file will not constrain the revision.
For example, it's common to reference
nixpkgs-unstablewithout specifying a revision. The input is locked to a specific revision when fetched and this information is saved to either adevenv.lockorflake.lockfile.Following this input from another project will re-fetch the latest revison, which may be different from the lcoked revision used in the original project.
This is the comment referencing the commit where this doc was added.
It's a feature of Nix Flakes. Instead of providing a
url, you can usefollowsto reference any other input by name, including their nested inputs.I've added this information to the docs: bee405dc72a23f93002fdda03046177995d9bb01
Originally posted by @sandydoo in #2209
Source: cachix/devenv