-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
More intelligent subflake locking. #6352
Description
Is your feature request related to a problem? Please describe.
flake.nix:
{
inputs.child.url = "path:./child";
outputs = {self, child}: {
inherit child;
};
}child/flake.nix:
{
outputs = {self}: {
foo = 1;
};
}$ nix eval .#child.foo
1
$ # so far, so good
$ sed -ie 's/1/2/' child/flake.nix
$ nix eval .#child.foo
warning: Git tree '/mnt/persist/share/data/tejing/work/tmpflake' is dirty
1
$ # huh, ok, maybe the dirty tree support doesn't extend that far.
$ # I guess that's at least kind of understandable
$ git commit -am 'change foo' &>/dev/null
$ nix eval .#child.foo
1
$ # this is super unintuitive. it really should be 2 at this point
$ nix flake update --commit-lock-file &>/dev/null
$ nix eval .#child.foo
2
$ # finally!
Describe the solution you'd like
Nix should recognize that the subflake is already locked by the parent flake's rev, and thus doesn't need its hash put into flake.lock at all, removing any possibility of a parent and child from different commits interacting. Ideally the dirty tree case should work too.
Describe alternatives you've considered
Nix could try to keep the hash in flake.lock up to date somehow, but it fundamentally doesn't have a hook into the proper time to do that, since git commit doesn't call nix.
The parent flake could invoke the child by builtins.getFlake, rather than as an input, but currently all methods of doing that suffer from similar problems, and you wouldn't have access to input overriding functionality.