Answers: <p>Unintuitively enough, you use a different command for that. <code>nix flake update</code> updates all inputs as you noticed, while you use</p>
  <pre class="lang-bash prettyprint-override"><code>nix flake lock --update-input &lt;name_of_input&gt;
  </code></pre>
  <p>to update only a single input. You can also chain several of these in a single command:</p>
  <pre class="lang-bash prettyprint-override"><code>nix flake lock --update-input nixpkgs --update-input nix
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-09-27T22:18:20.377Z
Answers: 2023-09-27T22:18:20.377Z
Answers: Hjulle
Body: <p>I have a Nix flake with several inputs whose URLs are remote git repositories. I want to update one input in <code>flake.lock</code>, but not the others; in particular, I want to avoid repinning <code>nixpkgs</code>.</p>
  <p>When I run <code>nix flake update</code>, all inputs are updated. This is probably desirable for correctness. However, I can subsequently roll back part of the changes to <code>flake.lock</code>, performing minor surgery, so that only one input is updated.</p>
  <p>Is there a blessed or safe way to update only one input? I would accept a way to update a given input and all of its transitive dependencies, if that is the only safe way.</p>
  
Tags: <nixos>
Title: How should I update a single input to a Nix flake?
UserDisplayName: Corbin
ThreadText: # How should I update a single input to a Nix flake?
  
  (Asked by: username_0 on 2023-09-17)
  
  I have a Nix flake with several inputs whose URLs are remote git repositories. I want to update one input in `flake.lock`, but not the others; in particular, I want to avoid repinning `nixpkgs`.
  
  When I run `nix flake update`, all inputs are updated. This is probably desirable for correctness. However, I can subsequently roll back part of the changes to `flake.lock`, performing minor surgery, so that only one input is updated.
  
  Is there a blessed or safe way to update only one input? I would accept a way to update a given input and all of its transitive dependencies, if that is the only safe way.
  
  **Tags:** nixos
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-09-27. Score: 5 | Accepted answer
  
  Unintuitively enough, you use a different command for that. `nix flake update` updates all inputs as you noticed, while you use
  
  ```bash
  nix flake lock --update-input <name_of_input>
  
  ```
  
  to update only a single input. You can also chain several of these in a single command:
  
  ```bash
  nix flake lock --update-input nixpkgs --update-input nix
  
  ```
  
  
  ---
  
  