Update flake input to specific revision

Is there a way to update a flake input to a specific revision, rather than just the latest revision? I know that I can do nix flake update --update-input nixpkgs, but is there something like nix-flake update --update-input --commit=<rev> nixpkgs? Thanks!

5 Likes

I figured this out. You can use --override-input for this. E.g.

nix flake update --override-input nixpkgs github:NixOS/nixpkgs/<rev>
17 Likes

2024 this would be

nix flake lock --override-input nixpkgs github:NixOS/nixpkgs/$rev
4 Likes

Be aware that this updates all other inputs as well. You can avoid that either by using @Lillecarl’s suggestion, or by adding an additional parameter to your command

nix flake update nixpkgs --override-input nixpkgs github:NixOS/nixpkgs/<rev>
                 ^^^^^^

you can also (at either extreme):

  • edit your flake inputs to refer to that specific revision
  • use --override-input once-off with specific commands, such as nix build