Recommendations for use of flakes' input-follows

What are the recommendations for the use of <aaa>.inputs.<bbb>.follows = "<ccc>";?

For example, let’s say my inputs contain

    nixpkgs     .url = "github:nixos/nixpkgs/nixos-21.11";
    rust-overlay.url = "github:oxalica/rust-overlay";
    flake-utils .url = "github:numtide/flake-utils";
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;

would it be good, bad or indifferent to also add

    flake-utils .inputs.nixpkgs.follows = "nixpkgs";
    rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
    flake-compat.inputs.nixpkgs.follows = "nixpkgs";


The naive idea being that this would help with consistency and, at least, minimize the size of the product by avoiding having multiple versions of nikpkgs being pulled in.

If this is at all useful, then

  1. Is there a smarter way of doing it than trying to list everything manually?
  2. How should you discover other, less obvious, inputs that might be shared?

I depends on the flake, if the rust overlay for instance just exposes an overlay then you won’t need the follows since the overlay will be applied to your “main” nixpkgs input anyways, I don’t think flake-compat depends on nixpkgs at all, flake-utils claims to be pure nix and thus shouldn’t require nixpkgs either.


So, in general, you have to reason about each individual case, which, in general, requires some knowledge of the internals of each.

1 Like

You need to do that anyway, because there is no guarantee nixpkgs is actually called nixpkgs in the upstream flake. There’s currently no way to avoid a cursory glance at a dependency flake’s inputs to my knowledge (and arguably you should take that glance anyway because you’re installing arbitrary code from GitHub). Thanks @kamadorueda :slight_smile:

Personally, I manually set a follows for each input’s nixpkgs, as well as other flakes that would be duplicated. This could cause breakage, but would be obvious at compile time and is easy to undo. If you’re not sure which flakes may duplicate something, a look through flake.lock can be a nice way to assert that down the line.

I agree this isn’t ideal though, it causes a fair bit of boilerplate, and might be unmaintainable if flakes become more fragmented one day. I’d love to know whether this limitation is intentional, since it is very reminiscent of how nix handles package dependencies; just without the easy self-references to undo the exponential version growth where appropriate.

nix flake info will list a graph so you know which follows need to be added:


$ nix flake info github:kamadorueda/machine

warning: 'nix flake info' is a deprecated alias for 'nix flake metadata'
Resolved URL:  github:kamadorueda/machine
Locked URL:    github:kamadorueda/machine/1c434757a1fee607743d0a69e76e450a88d1b738
Path:          /nix/store/0h8z7517vfzyr8hzjbha91w95z4dvlqs-source
Revision:      1c434757a1fee607743d0a69e76e450a88d1b738
Last modified: 2022-01-29 20:44:17
├───alejandra: github:kamadorueda/alejandra/b72274b052ae06cbe60a97d623829b1458369cc2
│   ├───fenix: github:nix-community/fenix/af56bbdd36b7644ea466cef5a4b1163d923296a7
│   │   ├───nixpkgs: github:nixos/nixpkgs/5bb20f9dc70e9ee16e21cc404b6508654931ce41
│   │   └───rust-analyzer-src: github:rust-analyzer/rust-analyzer/6634eaf13a7e3a2b30f98f6e69af952f2d760df4
│   ├───flakeCompat: github:edolstra/flake-compat/b7547d3eed6f32d06102ead8991ec52ab0a4f1a7
│   ├───flakeUtils follows input 'flakeUtils'
│   └───nixpkgs follows input 'nixpkgs'
├───fenix: github:nix-community/fenix/af56bbdd36b7644ea466cef5a4b1163d923296a7
│   ├───nixpkgs follows input 'nixpkgs'
│   └───rust-analyzer-src follows input 'rustAnalyzer'
├───flakeUtils: github:numtide/flake-utils/846b2ae0fc4cc943637d3d1def4454213e203cba
├───homeManager: github:nix-community/home-manager/acf824c9ed70f623b424c2ca41d0f6821014c67c
│   └───nixpkgs follows input 'nixpkgs'
├───makes: github:fluidattacks/makes/bbeaa4eba6a3e35a3c9d16b127a9d5b06a87699e
│   └───nixpkgs follows input 'nixpkgs'
├───nixosGenerators: github:nix-community/nixos-generators/296067b9c7a172d294831dec89d86847f30a7cfc
│   ├───nixlib: github:nix-community/nixpkgs.lib/28a5b0557f14124608db68d3ee1f77e9329e9dd5
│   └───nixpkgs follows input 'nixpkgs'
├───nixpkgs: github:nixos/nixpkgs/d9e21f284317f85b3476c0043f4efea87a226c3a
├───pythonOnNix: github:on-nix/python/2e735762c73651cffc027ca850b2a58d87d54b49
│   ├───flakeUtils follows input 'flakeUtils'
│   ├───makes follows input 'makes'
│   └───nixpkgs follows input 'nixpkgs'
└───rustAnalyzer: github:rust-analyzer/rust-analyzer/6634eaf13a7e3a2b30f98f6e69af952f2d760df4