-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
follows
attribute of flake inputs seems broken as is
#4808
Comments
I think this setup describes the behavior you are thinking of. {
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs";
}
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.A.url = "http://example/A.git";
inputs.A.inputs.nixpkgs.follows = "nixpkgs";
}
{
inputs.B.url = "http://example/B.git";
outputs = { self, B }:
let
inherit (B.inputs) nixpkgs;
in
{
package = nixpkgs.hello;
};
} |
I had not thought of doing what you are doing in It looks like other issues I mentioned still remain, but I will have to take a closer look at that and try it out in code. My main concern with those issues is that that follows is confusing/difficult to use in any flake but |
follow
attribute of flake inputs seems broken as isfollows
attribute of flake inputs seems broken as is
When I wrote this issue I was not sure if this is a bug with how things are specified or with how they are implemented. I now found an inconsistency where some cases
All of this is very close to @mvnetbiz's code, but here I added
Now if we look at the output of
we can see that both of the
is resolved relative to C, which is what I have been complaining about, while
is resolved relative to B, which is what I would have expected in both cases. This also means that the line
has to be present in C, while declaring A (the target of the You can find my PoC with this code here: https://github.com/mschwaig/broken_follows_poc Thanks @mvnetbiz referring to a specific version of a transitive dependency works how you described it. |
@mschwaig
mean in
? |
I marked this as stale due to inactivity. → More info |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/1000-instances-of-nixpkgs/17347/23 |
I don't think what you are describing is happening, at least with the latest stable version of nix (
You seem to confirm this to some degree in your last comment
And you gave an example with three flakes. In there, you are creating a circular follows between I had to made the following changes:
So now we have the following
If we run
For flake C, it shows the circular follows as I expected. Note that flake C doesn't have to have an input named
To summarize, the problem described in this issue doesn't happen with the latest version of nix, so I think the issue can be closed. |
Thanks for taking a look at this. I saw some tests in nix recently that made me think this got fixed, but did not find the time to reply or revisit this issue to verify until now.
@12Boti yes, thanks. That was an error.
@ilkecan yes thanks. I went through what you wrote and also verified it locally myself. This is indeed fixed now. I managed to find the PR that added those tests which should be the PR that fixed the issue: #4641 So thanks to @citadelcore and everyone else who got that PR merged. I think that was an important issue to solve. |
Thanks @12Boti for pointing this out here: NixOS/nix#4808 (comment)
I think the current semantics of the
follows
attribute of flake inputs are broken.It looks like how the implementation behaves matches with what is specified in the Flake RFC NixOS/rfcs#49.
I am not sure if this is a bug in the specification or a bug in the implementation. Maybe it's also totally fine, but I personally do not understand when and how to use
follows
outside of the root flake with the current semantics.It would be great if someone could point out where I'm going wrong or validate my view.
Let's say we are working on flake B with the flakes A and nixpkgs as dependencies.
A and B both depend on different version of nixpkgs in the listing above.
If this works B can reduce the closure size by doing the following.
This works fine, but now if someone else tries to use B as an input for C we get the following situation.
I now want to focus on the issues the author of C has when using B.
The problems I see are:
The only way to specify 'give me exactly the version of nixpkgs that B was published with' in C is by using the hash from B's flake.lock file. (Is this true? Am I missing something?)EDIT: not true, thanks @mvnetbizThe workflow that B used for adding A does something different when C tries to add B, which seems bad.
They may get a compile error if they do not have nixpkgs as an input already.
Then they will probably add
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixpkgs-unstable
and get some arbitrary version of nixpkgs.
If that does not work they have to do non-trivial extra work to get what B published originally to check if that works.
On the other hand when B added A they first got the verbatim thing and then tweaked it with the
follows
. That tweak might have looked like change with a defined scope, but it was not.It seems like both of those problems will interact and get worse for larger dependency trees.
Making naming annoying and reproducibility difficult to 'get right'.
This makes me think
follows
is only usable in root flakes right now.Fixed semantics
Let's look at the last step again with alternative semantics where the targets of follows are resolved relative to the flake that contains the follows attribute.
follows
attribute.Adding B as an input to C behaves just like adding A as an input to B, because the impact of any follows is contained to the flake where it is declared and its dependencies.
Is there some usage/benefit of the current semantics that I am missing?
Is what I am proposing broken in some way?
I have been using the term root flake from the Flake RFC here, which uses root flake and top-level flake in some places, but I don't think it defines those terms. That seems like a possible source of the issue.
I hope that this is the right place to bring this up.
Thanks for all the great work on Flakes.
The text was updated successfully, but these errors were encountered: