Skip to content
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

Flakes: builtin function to flatten inputs using follows #4753

Open
FRidh opened this issue Apr 28, 2021 · 6 comments
Open

Flakes: builtin function to flatten inputs using follows #4753

FRidh opened this issue Apr 28, 2021 · 6 comments

Comments

@FRidh
Copy link
Member

FRidh commented Apr 28, 2021

Is your feature request related to a problem? Please describe.
Having to specify inputs.foo.inputs.bar.follows everywhere can become tedious. Sometimes it is needed because packages need to be upgraded in lockstep.

Describe the solution you'd like
A builtin function that, given a set of inputs, would set the follows of each input to the other inputs. Essentially, this function would flatten the inputs tree as shown by nix flake metadata as much as possible. Users can choose to apply the function on the entire set of inputs, or on one or more subsets.

Describe alternatives you've considered
While it is possible to implement the function in Nix directly, it is not possible to share such function (would require copying) or actually even use it, because Nix doesn't allow it.

Maybe a function likes this needs to take parameters to exclude certain inputs from being followed. I don't have this use case but I can imagine it.

Additional context
This may also be desirable as the whole dependency tree of a flake grows, and there will be many "copies" of Nixpkgs and/or other flakes.

@gytis-ivaskevicius
Copy link
Contributor

I'd be down with an alternative as shown in the picture.
image
Currently, let/in syntax is not allowed in a flake.nix file. Not sure why that is the case but there probably is some sort of reasoning behind it :/

@kanashimia
Copy link
Member

kanashimia commented Jun 5, 2021

Currently, let/in syntax is not allowed in a flake.nix file. Not sure why that is the case but there probably is some sort of reasoning behind it :/

Reason: #3075
Related issue: #3966
It is a major annoyance indeed.

Basically having any function on the flake attributes is impossible right now, by design.

@DieracDelta
Copy link
Member

DieracDelta commented Jun 6, 2021

I've also run into this problem a bunch and it is quite annoying to manually need to specify everywhere. I quite like the solution @gytis-ivaskevicius has proposed.

@gytis-ivaskevicius
Copy link
Contributor

gytis-ivaskevicius commented Jun 6, 2021

@DieracDelta, to implement it in the way that edolstra would be happy with - this would need to be done which is probably somewhat complex #3966 (comment), so yeah.. Don't put too much hope in this solution

@nrdxp
Copy link
Contributor

nrdxp commented Sep 27, 2021

I think, given the current implementation of flakes, it may be easier to implement this on the cli level. So maybe something like nix flake follows nixpkgs would search the dependencies of every flake recursively, and for any flake that has a nixpkgs input, set it to follow the root flake's nixpkgs.

@stale
Copy link

stale bot commented Apr 16, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Apr 16, 2022
@stale stale bot removed the stale label Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants