Nix flake update - just a specific input

Hi everybody,

I have this in my flake:

{
  inputs =
    {
      ...
      foobar.url = "path:/some/thing";
      ...
    };
    ...

And I’m confused about -I option in nix flake update.

If I’m reading the man page correctly and I want to update ONLY that input and not for example nixpkgs, is -I option what I want?

As you can see I’m referring to another local flake in my flake and I change it often so I often need to run nix flake update. The problem is that I have bad internet and updates take loooong time to finish and I just want instantaneous update since I changed something locally and therefore no need to hit internet.

Thank you.

1 Like
nix flake lock --update-input foobar

More details: How to update a single flake input?

1 Like

Thank you very much @noah !

So what’s the use case for nix flake update -I? If I’m reading man page correctly then I might use it to update foobar from a different path?

nix flake update -I foorbar=path:/some/otherthing

1 Like

I don’t think the flake attributes can be overridden by the -I flag. The —include flag will have no effect in most flake-related commands. It exists to supplement lookups of “angle bracket paths” (used in traditional Nix files) rather than flake inputs.

The manual includes common options on every command, which is why you see it on the page for nix flake update.

That said, you could use —override-input which should do what you are asking, except it won’t update the lockfile.

1 Like

Another option you might consider: use a local clone of nixpkgs in your flake inputs. Then nix flake update will not hit the network. When you want something newer from nixpkgs, run git remote update on your clone. My flake.nix begins

  inputs = {
    nixpkgs.url = "git+file:///nix/nixpkgs?ref=upstream/nixos-23.05";
    nixos-hardware.url = "git+file:///nix/flake-cache/nixos-hardware.git";
  };
1 Like

Thank you very much both.

Btw. git+file is a good tip. I’d just use use path which probably wouldn’t take an advantage of version control.

Thank you!

In Nix 2.19, --update-input has been removed and there doesn’t seem to be possible to update a selected input with nix flake update.

reading the release notes for 2.19 reveals the new solution:

nix flake update does the same, but will update inputs.
- Passing no arguments will update all inputs of the current flake, just like it already did.
- Passing input names as arguments will ensure only those are updated. This replaces the functionality of nix flake lock --update-input
- To operate on a flake outside the current directory, you must now pass --flake path/to/flake.

see https://github.com/NixOS/nix/blob/f25c06d7a3289343887d09761c82356a3b6b441b/doc/manual/src/release-notes/rl-2.19.md?plain=1#L30 for more.

2 Likes

https://nixos.org/manual/nix/unstable/release-notes/rl-2.19

Passing input names as arguments will ensure only those are updated. This replaces the functionality of nix flake lock --update-input

Thanks, I was confused by the fact that “nix flake update” is taking inputs from 2.19, but it was not the case previously.

1 Like

Yes, the API makes more sense with 2.19.