Why does only one of my flake inputs get implicitly updated?

I use mach-nix in my flake-based system configuration; since mach-nix’s locked copy of pypi-deps-db is quite old, I update its pypi-deps-db input in my flake.nix:

  inputs.mach-nix.url = "github:DavHau/mach-nix";
  inputs.mach-nix.inputs.pypi-deps-db = {
    type = "github";
    owner = "DavHau";
    repo = "pypi-deps-db";
  };

I’ve noticed that whenever I home-manager switch, this pypi-deps-db input gets updated automatically:

warning: updating lock file '/home/ash/src/config/flake.lock':
• Updated input 'mach-nix/pypi-deps-db':
    'github:DavHau/pypi-deps-db/ed4433b11615fc5d84e349ad8f9f2f468165c876' (2022-08-11)
  → 'github:DavHau/pypi-deps-db/974e9b1cd1fec5d61db6e3ed21e65b2991fe693f' (2022-08-12)

This is different to all the other inputs to my flake, which I have to nix flake update or nix flake lock --update-input explicitly in order to update.

Why exactly is this happening? I’d rather not have to wait for a fresh pypi-deps-db to download every time I change something unrelated in my configuration…

I think the intended way of doing this is:

inputs.pypi-deps-db.url = "github:DavHau/pypi-deps-db";
inputs.mach-nix.url = "github:DavHau/mach-nix";
inputs.mach-nix.inputs.pypi-deps-db.follows = "pypi-deps-db";

This will set up a new input, which will work exactly like all other inputs, and make mach-nix’ input follow that one. It’s also how it’s documented here: nix flake

The behavior you’re seeing is odd though. I wasn’t aware that you could set the inputs directly without follows, but I also wouldn’t expect it to behave like this.

And since I can’t keep myself from commenting on this, I significantly prefer actually putting inputs in attrsets, much easier to read when you start messing with follows:

inputs = {
  pypi-deps-db.url = "github:DavHau/pypi-deps-db";
  mach-nix = {
    url = "github:DavHau/mach-nix";
    inputs.pypi-deps-db.follows = "pypi-deps-db";
  };
};
1 Like