Granular overrides for individual attributes within a flake input?

What do I mean?

Consider foo/flake.nix:

{
  inputs = {
    nixpkgs = ...;
    baz = {
      url = "<url1>";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
}

And bar/flake.nix (The goal I am trying to achieve):

{
  inputs = barInputs: {
    nixpkgs = ...;
    foo = fooInputs: {
      url = "...";
      fooInputs.baz.url = "<url2>";
    };
  };
}

This isn’t possible now. The only way to do it is to create a new baz input in bar and make foo follow it:

{
  inputs = {
    nixpkgs = ...;
    baz = {
      url = "<url2>";
    };
    foo = {
      url = "...";
      inputs.baz.follows = "baz";
    };
  };
}

Do you see the problem in this?

In foo 's flake inputs, baz is following the foo/nixpkgs but if we want to keep that behaviour same in baz we will have to explicitly mention that:

{
  inputs = barInputs: {
    nixpkgs = ...;
    baz = {
      url = "<url2>";
      inputs.nixpkgs.follows = "foo/nixpkgs";
    };
    foo = {
      url = "...";
      inputs.baz.follows = "baz";
    };
  };
}

This can be too cumbersome as soon as the number of inputs to follow grows. I haven’t thought this through… maybe a module system for flake inputs can make things simpler?

This is why experienced Nixers often dislike flakes more than newbies.

There three “solutions”:

  1. Create every dependency of every dependency as a top level one and add follows like this (eew)
  2. Use nix-auto-follow to rewrite your lockfile to point all to the same versions of libs
  3. Stop using Flakes (But that doesn’t make it any easier to consume other peoples flakes with your instance of nixpkgs)

You can use 2 to verify 1 has been done properly (This is how I do it).

Flake inputs can’t be anything but an attrset for reasons so you’re out of luck trying to invent something here :\